#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__ clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ factorial(int);
int /*<<< orphan*/ printf(char *, int, int, ...);
int main() {
  clock_t prgstart, prgende;
  unsigned int i;
  printf("%d! = %lld\n", 20, factorial(20));
  prgstart = clock();
  for (i = 0; i < 1000; i++) {
    factorial(20);
  }
  prgende = clock();
  printf("Laufzeit (%d x %d!): %.3fms\n", 1000, 20,
         (float)(prgende - prgstart) / CLOCKS_PER_SEC * 1000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x14,%edi
call   1030 <factorial@plt>
mov    %eax,%edx
lea    0xeb2(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jae    1195 <main+0x65>
mov    $0x14,%edi
call   1030 <factorial@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <main+0x40>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e34(%rip),%rax
divss  (%rax),%xmm0
movss  0xe40(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x14,%edx
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x14,%edi
call   1030 <factorial@plt>
lea    0xec0(%rip),%rdi
mov    $0x14,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
mov    $0x3e8,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x14,%edi
call   1030 <factorial@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %rbx,%rax
cvtsi2ss %rax,%xmm0
mov    0x2e53(%rip),%rax
divss  (%rax),%xmm0
mulss  0xe5f(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe64(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x14,%edx
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d! = %lld\0A\00"
@.str.1 = [29 x i8] c"Laufzeit (%d x %d!): %.3fms\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @factorial(i32 20)
%6 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 20, i32 %5)
%7 = call i64 (...) @clock()
store i64 %7, i64* %2
store i32 0, i32* %4
br label %8
8: ; preds = %13, %0
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, 1000
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call i32 @factorial(i32 20)
br label %13
13: ; preds = %11
%14 = load i32, i32* %4
%15 = add i32 %14, 1
store i32 %15, i32* %4
br label %8
16: ; preds = %8
%17 = call i64 (...) @clock()
store i64 %17, i64* %3
%18 = load i64, i64* %3
%19 = load i64, i64* %2
%20 = sub nsw i64 %18, %19
%21 = sitofp i64 %20 to float
%22 = load float, float* @CLOCKS_PER_SEC
%23 = fdiv float %21, %22
%24 = fmul float %23, 1.000000e+03
%25 = fpext float %24 to double
%26 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1000, i32 20, double %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d! = %lld\0A\00"
@.str.1 = [29 x i8] c"Laufzeit (%d x %d!): %.3fms\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main() {
%1 = tail call i32 @factorial(i32 20)
%2 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 20, i32 %1)
%3 = tail call i64 (...) @clock()
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %7, %4 ]
%6 = tail call i32 @factorial(i32 20)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 1000
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i64 (...) @clock()
%11 = sub nsw i64 %10, %3
%12 = sitofp i64 %11 to float
%13 = load float, float* @CLOCKS_PER_SEC
%14 = fdiv float %12, %13
%15 = fmul float %14, 1.000000e+03
%16 = fpext float %15 to double
%17 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1000, i32 20, double %16)
ret i32 0
}