#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
unsigned long long factorial(unsigned long long);
unsigned long long fibunacci(unsigned long long);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main() {
  unsigned long long numberToCheck;
  scanf("%llu", &numberToCheck);
  pid_t forkResult;
  forkResult = fork();
  if (forkResult == 0) {
    numberToCheck = factorial(numberToCheck);
    printf("Result of factorial: %llu\n", numberToCheck);
    return 0;
  } else if (forkResult < 0) {
    return 69;
  } else {
    numberToCheck = fibunacci(numberToCheck);
    printf("Result of fibunacci: %llu\n", numberToCheck);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ae <main+0x5e>
mov    -0x10(%rbp),%rdi
call   1030 <factorial@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <main+0x99>
cmpq   $0x0,-0x18(%rbp)
jge    11c5 <main+0x75>
movl   $0x45,-0x4(%rbp)
jmp    11e9 <main+0x99>
mov    -0x10(%rbp),%rdi
call   1060 <fibunacci@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1198 <main+0x48>
js     11b8 <main+0x68>
mov    0x8(%rsp),%rdi
call   1060 <fibunacci@plt>
mov    %rax,0x8(%rsp)
lea    0xe94(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    11bd <main+0x6d>
mov    0x8(%rsp),%rdi
call   1030 <factorial@plt>
mov    %rax,0x8(%rsp)
lea    0xe57(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
jmp    11bd <main+0x6d>
mov    $0x45,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [27 x i8] c"Result of factorial: %llu\0A\00"
@.str.2 = [27 x i8] c"Result of fibunacci: %llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%5 = call i64 (...) @fork()
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i64, i64* %2
%10 = call i64 @factorial(i64 %9)
store i64 %10, i64* %2
%11 = load i64, i64* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %11)
store i32 0, i32* %1
br label %22
13: ; preds = %0
%14 = load i64, i64* %3
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 69, i32* %1
br label %22
17: ; preds = %13
%18 = load i64, i64* %2
%19 = call i64 @fibunacci(i64 %18)
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %20)
store i32 0, i32* %1
br label %22
22: ; preds = %17, %16, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [27 x i8] c"Result of factorial: %llu\0A\00"
@.str.2 = [27 x i8] c"Result of fibunacci: %llu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i64, i64* %1
%8 = call i64 @factorial(i64 %7)
store i64 %8, i64* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %8)
br label %16
10: ; preds = %0
%11 = icmp slt i64 %4, 0
br i1 %11, label %16, label %12
12: ; preds = %10
%13 = load i64, i64* %1
%14 = call i64 @fibunacci(i64 %13)
store i64 %14, i64* %1
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %14)
br label %16
16: ; preds = %10, %12, %6
%17 = phi i32 [ 0, %6 ], [ 0, %12 ], [ 69, %10 ]
ret i32 %17
}