#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 /*<<< orphan*/ div_factor(char *, char *, char *);
int /*<<< orphan*/ factorial_calc(char *, int);
int /*<<< orphan*/ factorial_mul(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse_digits(char *);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  char answer[50] = {0};
  char factorial_forty[50] = {'1'};
  char factorial_twenty[50] = {'1'};
  char factorial_product[50] = {'0'};
  factorial_calc(factorial_twenty, 20);
  factorial_calc(factorial_forty, (20 + (20)));
  factorial_mul(factorial_twenty, factorial_product);
  reverse_digits(factorial_forty);
  reverse_digits(factorial_product);
  div_factor(factorial_forty, factorial_product, answer);
  printf("Answer: %s\n", answer);
  float stop = timeit();
  printf("Time: %f\n", stop - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
movb   $0x31,-0x90(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
movb   $0x31,-0xd0(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
movb   $0x30,-0x110(%rbp)
lea    -0xd0(%rbp),%rdi
mov    $0x14,%esi
call   1070 <factorial_calc@plt>
lea    -0x90(%rbp),%rdi
mov    $0x28,%esi
call   1070 <factorial_calc@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <factorial_mul@plt>
lea    -0x90(%rbp),%rdi
call   1040 <reverse_digits@plt>
lea    -0x110(%rbp),%rdi
call   1040 <reverse_digits@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1090 <div_factor@plt>
lea    -0x50(%rbp),%rsi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <timeit@plt>
movss  %xmm0,-0x114(%rbp)
ff
movss  -0x114(%rbp),%xmm0
ff
subss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd7c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
xor    %eax,%eax
call   1070 <timeit@plt>
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movw   $0x0,0x100(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movw   $0x0,0xc0(%rsp)
movb   $0x31,0x90(%rsp)
31
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movw   $0x0,0x80(%rsp)
movb   $0x31,0x50(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x40(%rsp)
movb   $0x30,0x10(%rsp)
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x14,%esi
call   1060 <factorial_calc@plt>
lea    0x90(%rsp),%r15
mov    %r15,%rdi
mov    $0x28,%esi
call   1060 <factorial_calc@plt>
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <factorial_mul@plt>
mov    %r15,%rdi
call   1040 <reverse_digits@plt>
mov    %rbx,%rdi
call   1040 <reverse_digits@plt>
lea    0xd0(%rsp),%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <div_factor@plt>
lea    0xd9b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <timeit@plt>
subss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd85(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Answer: %s\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
%9 = alloca [50 x i8]
%10 = alloca [50 x i8]
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call float (...) @timeit()
store float %12, float* %6
%13 = bitcast [50 x i8]* %7 to i8*
%14 = bitcast [50 x i8]* %8 to i8*
%15 = bitcast i8* %14 to <{ i8, [49 x i8] }>*
%16 = getelementptr inbounds <{ i8, [49 x i8] }>, <{ i8, [49 x i8] }>* %15, i32 0, i32 0
store i8 49, i8* %16
%17 = bitcast [50 x i8]* %9 to i8*
%18 = bitcast i8* %17 to <{ i8, [49 x i8] }>*
%19 = getelementptr inbounds <{ i8, [49 x i8] }>, <{ i8, [49 x i8] }>* %18, i32 0, i32 0
store i8 49, i8* %19
%20 = bitcast [50 x i8]* %10 to i8*
%21 = bitcast i8* %20 to <{ i8, [49 x i8] }>*
%22 = getelementptr inbounds <{ i8, [49 x i8] }>, <{ i8, [49 x i8] }>* %21, i32 0, i32 0
store i8 48, i8* %22
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%24 = call i32 @factorial_calc(i8* %23, i32 20)
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%26 = call i32 @factorial_calc(i8* %25, i32 40)
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%29 = call i32 @factorial_mul(i8* %27, i8* %28)
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%31 = call i32 @reverse_digits(i8* %30)
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%33 = call i32 @reverse_digits(i8* %32)
%34 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%37 = call i32 @div_factor(i8* %34, i8* %35, i8* %36)
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = call float (...) @timeit()
store float %40, float* %11
%41 = load float, float* %11
%42 = load float, float* %6
%43 = fsub float %41, %42
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Answer: %s\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca [50 x i8]
%6 = alloca [50 x i8]
%7 = tail call float (...) @timeit()
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
store i8 49, i8* %9
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
store i8 49, i8* %10
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
store i8 48, i8* %11
%12 = call i32 @factorial_calc(i8* %10, i32 20)
%13 = call i32 @factorial_calc(i8* %9, i32 40)
%14 = call i32 @factorial_mul(i8* %10, i8* %11)
%15 = call i32 @reverse_digits(i8* %9)
%16 = call i32 @reverse_digits(i8* %11)
%17 = call i32 @div_factor(i8* %9, i8* %11, i8* %8)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%19 = call float (...) @timeit()
%20 = fsub float %19, %7
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %21)
ret i32 0
}