Created
March 21, 2015 00:06
-
-
Save makestuff/ee1e8e97d959ad97e396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
static inline int do_loop(unsigned long i, unsigned long end) { | |
return (i < end) ? printf("loop %lu\n", i), do_loop(i+1, end) : 0; | |
} | |
int main(int argc, char *argv[]) { | |
return do_loop(0, strtoul(argv[1], NULL, 10)); | |
(void)argc; | |
} | |
main: | |
leal 4(%esp), %ecx | |
andl $-16, %esp | |
pushl -4(%ecx) | |
pushl %ebp | |
movl %esp, %ebp | |
pushl %esi | |
pushl %ebx | |
pushl %ecx | |
xorl %ebx, %ebx | |
subl $16, %esp | |
movl 4(%ecx), %eax | |
pushl $10 | |
pushl $0 | |
pushl 4(%eax) | |
call strtoul | |
addl $16, %esp | |
testl %eax, %eax | |
movl %eax, %esi | |
je .L7 | |
.p2align 4,,10 | |
.p2align 3 | |
.L5: | |
subl $8, %esp | |
pushl %ebx | |
pushl $.LC0 | |
addl $1, %ebx | |
call printf | |
addl $16, %esp | |
cmpl %esi, %ebx | |
jne .L5 | |
.L7: | |
leal -12(%ebp), %esp | |
xorl %eax, %eax | |
popl %ecx | |
popl %ebx | |
popl %esi | |
popl %ebp | |
leal -4(%ecx), %esp | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment