#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(int);
int fibonacci(int);
int gcd(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int n0 = factorial(0);
  int n1 = factorial(1);
  int n5 = factorial(5);
  int n10 = factorial(10);
  printf("\nFactorials:\n0! = %d\n1! = %d\n5! = %d\n10! = %d\n", n0, n1, n5,
         n10);
  printf("\nGreatest common divisor of 20 and 4 is %d", gcd(20, 4));
  printf("\nGreatest common divisor of 259 and 111 is %d", gcd(259, 111));
  printf("\nThe 5th fibonacci number is %d", fibonacci(5));
  printf("\nThe 10th fibonacci number is %d", fibonacci(10));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1030 <factorial@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1030 <factorial@plt>
mov    %eax,-0xc(%rbp)
mov    $0x5,%edi
call   1030 <factorial@plt>
mov    %eax,-0x10(%rbp)
mov    $0xa,%edi
call   1030 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x14,%edi
mov    $0x4,%esi
call   1060 <gcd@plt>
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x103,%edi
mov    $0x6f,%esi
call   1060 <gcd@plt>
mov    %eax,%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
call   1050 <fibonacci@plt>
mov    %eax,%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1050 <fibonacci@plt>
mov    %eax,%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1030 <factorial@plt>
mov    %eax,%r14d
mov    $0x1,%edi
call   1030 <factorial@plt>
mov    %eax,%ebp
mov    $0x5,%edi
call   1030 <factorial@plt>
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <factorial@plt>
lea    0xe89(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x14,%edi
mov    $0x4,%esi
call   1060 <gcd@plt>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x103,%edi
mov    $0x6f,%esi
call   1060 <gcd@plt>
lea    0xe9d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x5,%edi
call   1050 <fibonacci@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1050 <fibonacci@plt>
lea    0xeb7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0AFactorials:\0A0! = %d\0A1! = %d\0A5! = %d\0A10! = %d\0A\00"
@.str.1 = [43 x i8] c"\0AGreatest common divisor of 20 and 4 is %d\00"
@.str.2 = [46 x i8] c"\0AGreatest common divisor of 259 and 111 is %d\00"
@.str.3 = [32 x i8] c"\0AThe 5th fibonacci number is %d\00"
@.str.4 = [33 x i8] c"\0AThe 10th fibonacci number is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @factorial(i32 0)
store i32 %6, i32* %2
%7 = call i32 @factorial(i32 1)
store i32 %7, i32* %3
%8 = call i32 @factorial(i32 5)
store i32 %8, i32* %4
%9 = call i32 @factorial(i32 10)
store i32 %9, i32* %5
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12, i32 %13)
%15 = call i32 @gcd(i32 20, i32 4)
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @gcd(i32 259, i32 111)
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 @fibonacci(i32 5)
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 @fibonacci(i32 10)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"\0AFactorials:\0A0! = %d\0A1! = %d\0A5! = %d\0A10! = %d\0A\00"
@.str.1 = [43 x i8] c"\0AGreatest common divisor of 20 and 4 is %d\00"
@.str.2 = [46 x i8] c"\0AGreatest common divisor of 259 and 111 is %d\00"
@.str.3 = [32 x i8] c"\0AThe 5th fibonacci number is %d\00"
@.str.4 = [33 x i8] c"\0AThe 10th fibonacci number is %d\00"
define i32 @main() {
%1 = tail call i32 @factorial(i32 0)
%2 = tail call i32 @factorial(i32 1)
%3 = tail call i32 @factorial(i32 5)
%4 = tail call i32 @factorial(i32 10)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %3, i32 %4)
%6 = tail call i32 @gcd(i32 20, i32 4)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @gcd(i32 259, i32 111)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @fibonacci(i32 5)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = tail call i32 @fibonacci(i32 10)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %12)
ret i32 0
}