; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE F:\WKSPS\C\d.c .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES _DATA SEGMENT $SG81286 DB '%u', 00H ORG $+1 $SG81293 DB 'i=%u', 09H, 'sum(i)=%e', 09H, 'time consuming=%ldns', 0aH DB 00H _DATA ENDS PUBLIC _get_cpu_time EXTRN __imp__QueryPerformanceCounter@4:PROC EXTRN __imp__QueryPerformanceFrequency@4:PROC EXTRN __alldiv:PROC EXTRN __allmul:PROC _BSS SEGMENT ?li@?1??get_cpu_time@@9@9 DQ 01H DUP (?) ; `get_cpu_time'::`2'::li ; Function compile flags: /Ogtpy _BSS ENDS _TEXT SEGMENT _linow$ = -8 ; size = 8 _get_cpu_time PROC ; File f:\wksps\c\d.c ; Line 5 sub esp, 8 push esi ; Line 8 xor esi, esi ; Line 10 push OFFSET ?li@?1??get_cpu_time@@9@9 mov DWORD PTR _linow$[esp+16], esi mov DWORD PTR _linow$[esp+20], esi mov DWORD PTR ?li@?1??get_cpu_time@@9@9, esi mov DWORD PTR ?li@?1??get_cpu_time@@9@9+4, esi call DWORD PTR __imp__QueryPerformanceFrequency@4 ; Line 11 lea eax, DWORD PTR _linow$[esp+12] push eax call DWORD PTR __imp__QueryPerformanceCounter@4 ; Line 12 mov ecx, DWORD PTR _linow$[esp+16] mov edx, DWORD PTR _linow$[esp+12] push esi push 1000000000 ; 3b9aca00H push ecx push edx call __allmul mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9+4 push ecx mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9 push ecx push edx push eax call __alldiv pop esi ; Line 13 add esp, 8 ret 0 _get_cpu_time ENDP _TEXT ENDS PUBLIC __real@3ff0000000000000 PUBLIC __real@41f0000000000000 PUBLIC _recursion_factorial EXTRN __fltused:DWORD ; COMDAT __real@3ff0000000000000 CONST SEGMENT __real@3ff0000000000000 DQ 03ff0000000000000r ; 1 CONST ENDS ; COMDAT __real@41f0000000000000 CONST SEGMENT __real@41f0000000000000 DQ 041f0000000000000r ; 4.29497e+009 ; Function compile flags: /Ogtpy CONST ENDS _TEXT SEGMENT tv129 = 8 ; size = 4 _n$ = 8 ; size = 4 _recursion_factorial PROC ; Line 16 push esi ; Line 17 mov esi, DWORD PTR _n$[esp] cmp esi, 1 je SHORT $LN2@recursion_ test esi, esi je SHORT $LN2@recursion_ ;; term condi end ; Line 20 lea eax, DWORD PTR [esi-1] push eax call _recursion_factorial ;; sub recur end add esp, 4 mov DWORD PTR tv129[esp], esi fild DWORD PTR tv129[esp] ;; type coercion test esi, esi jns SHORT $LN6@recursion_ fadd QWORD PTR __real@41f0000000000000 $LN6@recursion_: fmulp ST(1), ST(0) pop esi ; Line 21 ret 0 $LN2@recursion_: ; Line 18 fld1 pop esi ; Line 21 ret 0 _recursion_factorial ENDP _TEXT ENDS PUBLIC _sum ; Function compile flags: /Ogtpy _TEXT SEGMENT $T81329 = -8 ; size = 8 tv133 = 8 ; size = 4 _n$ = 8 ; size = 4 _sum PROC ; Line 25 mov edx, DWORD PTR _n$[esp-4] sub esp, 8 cmp edx, 1 je SHORT $LN1@sum test edx, edx je SHORT $LN1@sum ;; term cond ; Line 27 lea ecx, DWORD PTR [edx-1] push ecx call _recursion_factorial mov DWORD PTR tv133[esp+8], edx fild DWORD PTR tv133[esp+8] test edx, edx jns SHORT $LN10@sum fadd QWORD PTR __real@41f0000000000000 $LN10@sum: fmulp ST(1), ST(0) push ecx fstp QWORD PTR $T81329[esp+16] call _sum fadd QWORD PTR $T81329[esp+16] add esp, 8 ; Line 28 add esp, 8 ret 0 $LN1@sum: ; Line 26 fld1 ; Line 28 add esp, 8 ret 0 _sum ENDP _TEXT ENDS PUBLIC _main EXTRN _printf:PROC EXTRN _scanf:PROC ; Function compile flags: /Ogtpy _TEXT SEGMENT _n$ = -28 ; size = 4 tv164 = -24 ; size = 4 $T81351 = -24 ; size = 8 _linow$81335 = -16 ; size = 8 _linow$81341 = -8 ; size = 8 _main PROC ; Line 31 push ebp mov ebp, esp and esp, -64 ; ffffffc0H sub esp, 48 ; 00000030H push ebx push ebp push esi push edi ; Line 35 lea eax, DWORD PTR _n$[esp+64] push eax push OFFSET $SG81286 call _scanf add esp, 8 cmp eax, -1 je $LN32@main xor ebx, ebx npad 6 $LL8@main: cmp DWORD PTR _n$[esp+64], ebx jbe $LN32@main ;; scanf end ; Line 37 xor esi, esi npad 4 $LL6@main: ; Line 39 mov edi, DWORD PTR __imp__QueryPerformanceFrequency@4 push OFFSET ?li@?1??get_cpu_time@@9@9 mov DWORD PTR _linow$81335[esp+68], ebx ;; 68 for push ^ mov DWORD PTR _linow$81335[esp+72], ebx mov DWORD PTR ?li@?1??get_cpu_time@@9@9, ebx mov DWORD PTR ?li@?1??get_cpu_time@@9@9+4, ebx call edi ;; init li lea ecx, DWORD PTR _linow$81335[esp+64] push ecx call DWORD PTR __imp__QueryPerformanceCounter@4 ;; w linow mov edx, DWORD PTR _linow$81335[esp+68] mov eax, DWORD PTR _linow$81335[esp+64] push ebx push 1000000000 ; 3b9aca00H push edx push eax call __allmul ;; 64bit mul mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9+4 push ecx mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9 push ecx push edx push eax call __alldiv ;; resu in edx:eax ; Line 42 push OFFSET ?li@?1??get_cpu_time@@9@9 mov ebp, eax ;; start time, cropped mov DWORD PTR _linow$81341[esp+68], ebx mov DWORD PTR _linow$81341[esp+72], ebx mov DWORD PTR ?li@?1??get_cpu_time@@9@9, ebx mov DWORD PTR ?li@?1??get_cpu_time@@9@9+4, ebx call edi ;; init li again lea edx, DWORD PTR _linow$81341[esp+64] push edx call DWORD PTR __imp__QueryPerformanceCounter@4 ;; w linow mov eax, DWORD PTR _linow$81341[esp+68] mov ecx, DWORD PTR _linow$81341[esp+64] push ebx push 1000000000 ; 3b9aca00H push eax push ecx call __allmul mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9+4 push ecx mov ecx, DWORD PTR ?li@?1??get_cpu_time@@9@9 push ecx push edx push eax call __alldiv ;; now computed mov edi, eax ;; cropped resu to edi ; Line 44 cmp esi, 1 je SHORT $LN17@main cmp esi, ebx je SHORT $LN17@main ;; factorial term cond check lea ecx, DWORD PTR [esi-1] push ecx call _recursion_factorial ;; sub factorial call mov edx, esi mov DWORD PTR tv164[esp+68], edx fild DWORD PTR tv164[esp+68] ;; type coercion on i? test edx, edx jns SHORT $LN34@main fadd QWORD PTR __real@41f0000000000000 $LN34@main: fmulp ST(1), ST(0) ;; fact(i) in top push ecx fstp QWORD PTR $T81351[esp+72] ;; old son call _sum fadd QWORD PTR $T81351[esp+72] ;; son(i) in top add esp, 8 jmp SHORT $LN19@main $LN17@main: fld1 $LN19@main: sub edi, ebp ;; elapsed mov eax, 274877907 ; 10624dd3H imul edi sar edx, 6 mov eax, edx shr eax, 31 ; 0000001fH add eax, edx push eax ;; elapsed sub esp, 8 fstp QWORD PTR [esp] ;; sum(i) push esi ;; i push OFFSET $SG81293 ;; printf fmt string call _printf add esi, 10 ; 0000000aH add esp, 20 ; 00000014H cmp esi, DWORD PTR _n$[esp+64] ;; cmp i with n jbe $LL6@main ;; again ; Line 35 lea ecx, DWORD PTR _n$[esp+64] push ecx push OFFSET $SG81286 call _scanf ;; change n add esp, 8 cmp eax, -1 jne $LL8@main ;; n changed, back again $LN32@main: ; Line 48 pop edi xor eax, eax pop esi pop ebp pop ebx mov esp, ebp pop ebp ret 0 _main ENDP _TEXT ENDS END