#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int EXIT_SUCCESS;
long fac(int);
int /*<<< orphan*/ printf(char *, int, long);
int main(int argc, char *argv[]) {
  int nval;
  for (nval = 0; nval <= 20; nval++) {
    long int fval = fac(nval);
    printf("fac(%2d) = %ld\n", nval, fval);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jg     1174 <main+0x54>
mov    -0x14(%rbp),%edi
call   1030 <fac@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1030 <fac@plt>
lea    0xed1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x2,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x3,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x4,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x5,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x6,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x7,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x8,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x9,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xb,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xc,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xd,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xe,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xf,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x10,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x11,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x12,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x13,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x14,%edi
call   1030 <fac@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"fac(%2d) = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 20
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %6
%13 = call i64 @fac(i32 %12)
store i64 %13, i64* %7
%14 = load i32, i32* %6
%15 = load i64, i64* %7
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %14, i64 %15)
br label %17
17: ; preds = %11
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %8
20: ; preds = %8
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@.str = [16 x i8] c"fac(%2d) = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @fac(i32 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i64 %3)
%5 = tail call i64 @fac(i32 1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1, i64 %5)
%7 = tail call i64 @fac(i32 2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 2, i64 %7)
%9 = tail call i64 @fac(i32 3)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 3, i64 %9)
%11 = tail call i64 @fac(i32 4)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 4, i64 %11)
%13 = tail call i64 @fac(i32 5)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 5, i64 %13)
%15 = tail call i64 @fac(i32 6)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 6, i64 %15)
%17 = tail call i64 @fac(i32 7)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 7, i64 %17)
%19 = tail call i64 @fac(i32 8)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 8, i64 %19)
%21 = tail call i64 @fac(i32 9)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 9, i64 %21)
%23 = tail call i64 @fac(i32 10)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 10, i64 %23)
%25 = tail call i64 @fac(i32 11)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 11, i64 %25)
%27 = tail call i64 @fac(i32 12)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 12, i64 %27)
%29 = tail call i64 @fac(i32 13)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 13, i64 %29)
%31 = tail call i64 @fac(i32 14)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 14, i64 %31)
%33 = tail call i64 @fac(i32 15)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 15, i64 %33)
%35 = tail call i64 @fac(i32 16)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 16, i64 %35)
%37 = tail call i64 @fac(i32 17)
%38 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 17, i64 %37)
%39 = tail call i64 @fac(i32 18)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 18, i64 %39)
%41 = tail call i64 @fac(i32 19)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 19, i64 %41)
%43 = tail call i64 @fac(i32 20)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 20, i64 %43)
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}