#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 fact(int);
int facttail(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int n;
  for (n = 0; n <= 13; n++) {
    fprintf(stdout, "%2d! recursive: %-10d ", n, fact(n));
    fprintf(stdout, "tail recursive: %-10d\n", facttail(n, 1));
  }
  return 0;
}


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   $0xd,-0x14(%rbp)
jg     11c1 <main+0x91>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <fact@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1040 <facttail@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2ea1(%rip),%r12
lea    0xeba(%rip),%r14
lea    0xeca(%rip),%r15
xor    %ebp,%ebp
nop
mov    (%r12),%ebx
mov    %ebp,%edi
call   1050 <fact@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12),%ebx
mov    %ebp,%edi
mov    $0x1,%esi
call   1040 <facttail@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0xe,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [23 x i8] c"%2d! recursive: %-10d \00"
@.str.1 = [23 x i8] c"tail recursive: %-10d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %11, %3 ]
%5 = load i32, i32* @stdout
%6 = tail call i32 @fact(i32 %4)
%7 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @facttail(i32 %4, i32 1)
%10 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 14
br i1 %12, label %13, label %3
13: ; preds = %3
ret i32 0
}