Created
August 3, 2011 01:12
-
-
Save DrFrankenstein/1121671 to your computer and use it in GitHub Desktop.
I thought it would become iterative in some way.
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
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01 | |
TITLE C:\Users\Carl Tessier\Documents\Visual Studio 2008\Projects\ctest\ctest\main.c | |
.686P | |
.XMM | |
include listing.inc | |
.model flat | |
INCLUDELIB OLDNAMES | |
PUBLIC ??_C@_02DPKJAMEF@?$CFd?$AA@ ; `string' | |
EXTRN @__security_check_cookie@4:PROC | |
EXTRN __imp__printf:PROC | |
; COMDAT ??_C@_02DPKJAMEF@?$CFd?$AA@ | |
CONST SEGMENT | |
??_C@_02DPKJAMEF@?$CFd?$AA@ DB '%d', 00H ; `string' | |
; Function compile flags: /Ogtp | |
; File c:\users\carl tessier\documents\visual studio 2008\projects\ctest\ctest\main.c | |
CONST ENDS | |
; COMDAT _isOdd | |
_TEXT SEGMENT | |
_n$ = 8 ; size = 4 | |
_isOdd PROC ; COMDAT | |
; 4 : static int isOdd(int n) { return n == 0 ? 0 : isEven(n-1); } | |
push ebp | |
mov ebp, esp | |
mov eax, DWORD PTR _n$[ebp] | |
test eax, eax | |
jne SHORT $LN3@isOdd | |
pop ebp | |
ret 0 | |
$LN3@isOdd: | |
dec eax | |
jne SHORT $LN7@isOdd | |
mov eax, 1 | |
pop ebp | |
ret 0 | |
$LN7@isOdd: | |
dec eax | |
push eax | |
call _isOdd | |
add esp, 4 | |
pop ebp | |
ret 0 | |
_isOdd ENDP | |
; Function compile flags: /Ogtp | |
_TEXT ENDS | |
; COMDAT _isEven | |
_TEXT SEGMENT | |
_n$ = 8 ; size = 4 | |
_isEven PROC ; COMDAT | |
; 3 : static int isEven(int n) { return n == 0 ? 1 : isOdd(n-1); } | |
push ebp | |
mov ebp, esp | |
mov eax, DWORD PTR _n$[ebp] | |
dec eax | |
jne SHORT $LN10@isEven | |
pop ebp | |
ret 0 | |
$LN10@isEven: | |
dec eax | |
jne SHORT $LN18@isEven | |
mov eax, 1 | |
pop ebp | |
ret 0 | |
$LN18@isEven: | |
push eax | |
call _isEven | |
add esp, 4 | |
pop ebp | |
ret 0 | |
_isEven ENDP | |
_TEXT ENDS | |
PUBLIC _main | |
; Function compile flags: /Ogtp | |
; COMDAT _main | |
_TEXT SEGMENT | |
_main PROC ; COMDAT | |
; 8 : printf("%d", isEven(73347)); | |
push 73345 ; 00011e81H | |
call _isEven | |
push eax | |
push OFFSET ??_C@_02DPKJAMEF@?$CFd?$AA@ | |
call DWORD PTR __imp__printf | |
add esp, 12 ; 0000000cH | |
; 9 : return 0; | |
xor eax, eax | |
; 10 : } | |
ret 0 | |
_main ENDP | |
_TEXT ENDS | |
END |
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
int printf(char* fmt, ...); | |
static int isOdd(int); | |
static int isEven(int n) { return n == 0 ? 1 : isOdd(n-1); } | |
static int isOdd(int n) { return n == 0 ? 0 : isEven(n-1); } | |
int main(void) | |
{ | |
printf("%d", isEven(73347)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment