#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 factorial_loop(int);
int factorial_recursive(int);
int /*<<< orphan*/ fail();
int /*<<< orphan*/ pass();
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int recursive_result, loop_result;
  recursive_result = factorial_recursive(10);
  printf("%d! = %d (recursive)\n", 10, recursive_result);
  loop_result = factorial_loop(10);
  printf("%d! = %d (loop)\n", 10, loop_result);
  if (recursive_result == loop_result) {
    pass();
  } else {
    fail();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1070 <factorial_recursive@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe8a(%rip),%rdi
mov    $0xa,%esi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <factorial_loop@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    0xe7f(%rip),%rdi
mov    $0xa,%esi
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11b9 <main+0x69>
mov    $0x0,%al
call   1050 <pass@plt>
jmp    11c0 <main+0x70>
mov    $0x0,%al
call   1040 <fail@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%edi
call   1070 <factorial_recursive@plt>
mov    %eax,%ebx
lea    0xe9a(%rip),%rdi
mov    $0xa,%esi
mov    %eax,%edx
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <factorial_loop@plt>
mov    %eax,%ebp
lea    0xe91(%rip),%rdi
mov    $0xa,%esi
mov    %eax,%edx
call   1060 <printf@plt>
xor    %eax,%eax
cmp    %ebp,%ebx
jne    119e <main+0x4e>
call   1050 <pass@plt>
jmp    11a3 <main+0x53>
call   1040 <fail@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%d! = %d (recursive)\0A\00"
@.str.1 = [17 x i8] c"%d! = %d (loop)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @factorial_recursive(i32 10)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 10, i32 %5)
%7 = call i32 @factorial_loop(i32 10)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (...) @pass()
br label %17
15: ; preds = %0
%16 = call i32 (...) @fail()
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [22 x i8] c"%d! = %d (recursive)\0A\00"
@.str.1 = [17 x i8] c"%d! = %d (loop)\0A\00"
define i32 @main() {
%1 = tail call i32 @factorial_recursive(i32 10)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 10, i32 %1)
%3 = tail call i32 @factorial_loop(i32 10)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 %3)
%5 = icmp eq i32 %1, %3
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 (...) @pass()
br label %10
8: ; preds = %0
%9 = tail call i32 (...) @fail()
br label %10
10: ; preds = %8, %6
ret i32 0
}