All pastes #24263 Raw Edit

Anonymous

public text v1 · immutable
#24263 ·published 2005-09-29 23:58 UTC
rendered paste body
        .file   "fact.c"
        .text
        .p2align 2,,3
.globl factorial
        .type   factorial, @function
factorial:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        movl    8(%ebp), %eax
        cmpl    $1, %eax
        jle     .L3
        movl    %eax, %edx
        movl    $1, %eax
        movl    $1, %ebx
        jmp     .L5
        .p2align 2,,3
.L10:
        movl    %ecx, %edx
.L5:
        leal    -1(%edx), %ecx
        imull   %edx, %eax
        cmpl    %ebx, %ecx
        jne     .L10
        popl    %ebx
        leave
        ret
.L3:
        movl    $1, %eax
        popl    %ebx
        leave
        ret
        .size   factorial, .-factorial
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "%d\n"
        .text
        .p2align 2,,3
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        pushl   %ecx
        andl    $-16, %esp
        subl    $28, %esp
        movl    12(%ebp), %eax
        pushl   4(%eax)
        call    atoi
        movl    %eax, %ebx
        popl    %eax
        popl    %edx
        pushl   %ebx
        pushl   $.LC0
        call    printf
        pushl   %ebx
        call    factorial
        addl    $12, %esp
        pushl   %eax
        pushl   $.LC0
        call    printf
        movl    $1, %eax
        movl    -4(%ebp), %ebx
        leave
        ret
        .size   main, .-main