#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 */
double cos(double);
double cosApprox(double);
int factorial(int);
double power(double, int);
int /*<<< orphan*/ printProduct(double, double);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  double x, y;
  x = 0.1;
  printf("cos(%f) = %f ~ %f.\n", x, cos(x), cosApprox(x));
  x = 2.1;
  printf("cos(%f) = %f ~ %f.\n", x, cos(x), cosApprox(x));
  x = 4.1;
  printf("cos(%f) = %f ~ %f.\n", x, cos(x), cosApprox(x));
  int i;
  for (i = 11; i <= 14; i = i + 1)
    printf("%d! = %d.\n", i, factorial(i));
  y = 3.4;
  printProduct(x, y);
  i = 3;
  y = power(x, i);
  printf("i = %d.\n", i);
  printf("power(%f, %d) = %f.\n", x, i, y);
  printf("i = %d.\n", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1080 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <cosApprox@plt>
mov    -0x4c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
lea    0xe71(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe4a(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1080 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <cosApprox@plt>
mov    -0x3c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
lea    0xe2a(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xdfb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1080 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <cosApprox@plt>
mov    -0x2c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
lea    0xde3(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movl   $0xb,-0x1c(%rbp)
cmpl   $0xe,-0x1c(%rbp)
jg     1284 <main+0x124>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <factorial@plt>
mov    -0x50(%rbp),%esi
mov    %eax,%edx
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124b <main+0xeb>
movsd  0xd8c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1060 <printProduct@plt>
movl   $0x3,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <power@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cvttsd2si -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
lea    0xd6a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movsd  0xea3(%rip),%xmm0
call   1070 <cosApprox@plt>
movaps %xmm0,%xmm1
lea    0xecc(%rip),%rbx
movsd  0xe94(%rip),%xmm0
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe88(%rip),%xmm0
call   1070 <cosApprox@plt>
movaps %xmm0,%xmm1
movsd  0xe80(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe71(%rip),%xmm0
call   1070 <cosApprox@plt>
movaps %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xb,%edi
call   1040 <factorial@plt>
lea    0xe6d(%rip),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xc,%edi
call   1040 <factorial@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xd,%edi
call   1040 <factorial@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xe,%edi
call   1040 <factorial@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xde7(%rip),%xmm1
movsd  0xdcf(%rip),%xmm0
call   1060 <printProduct@plt>
movsd  0xdc2(%rip),%xmm0
mov    $0x3,%edi
call   1030 <power@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xde2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd5(%rip),%rdi
mov    $0x4,%esi
mov    $0x3,%edx
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"cos(%f) = %f ~ %f.\0A\00"
@.str.1 = [11 x i8] c"%d! = %d.\0A\00"
@.str.2 = [9 x i8] c"i = %d.\0A\00"
@.str.3 = [21 x i8] c"power(%f, %d) = %f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
store double 1.000000e-01, double* %2
%5 = load double, double* %2
%6 = fptosi double %5 to i32
%7 = load double, double* %2
%8 = call double @cos(double %7)
%9 = load double, double* %2
%10 = call double @cosApprox(double %9)
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %6, double %8, double %10)
store double 2.100000e+00, double* %2
%12 = load double, double* %2
%13 = fptosi double %12 to i32
%14 = load double, double* %2
%15 = call double @cos(double %14)
%16 = load double, double* %2
%17 = call double @cosApprox(double %16)
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %13, double %15, double %17)
store double 4.100000e+00, double* %2
%19 = load double, double* %2
%20 = fptosi double %19 to i32
%21 = load double, double* %2
%22 = call double @cos(double %21)
%23 = load double, double* %2
%24 = call double @cosApprox(double %23)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %20, double %22, double %24)
store i32 11, i32* %4
br label %26
26: ; preds = %34, %0
%27 = load i32, i32* %4
%28 = icmp sle i32 %27, 14
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* %4
%31 = load i32, i32* %4
%32 = call i32 @factorial(i32 %31)
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %32)
br label %34
34: ; preds = %29
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %26
37: ; preds = %26
store double 3.400000e+00, double* %3
%38 = load double, double* %2
%39 = load double, double* %3
%40 = call i32 @printProduct(double %38, double %39)
store i32 3, i32* %4
%41 = load double, double* %2
%42 = load i32, i32* %4
%43 = call double @power(double %41, i32 %42)
store double %43, double* %3
%44 = load i32, i32* %4
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load double, double* %2
%47 = fptosi double %46 to i32
%48 = load i32, i32* %4
%49 = load double, double* %3
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 %48, double %49)
%51 = load i32, i32* %4
%52 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"cos(%f) = %f ~ %f.\0A\00"
@.str.1 = [11 x i8] c"%d! = %d.\0A\00"
@.str.2 = [9 x i8] c"i = %d.\0A\00"
@.str.3 = [21 x i8] c"power(%f, %d) = %f.\0A\00"
define i32 @main() {
%1 = tail call double @cosApprox(double 1.000000e-01)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 0, double 0x3FEFD712F9A817C1, double %1)
%3 = tail call double @cosApprox(double 2.100000e+00)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2, double 0xBFE027B304989ECA, double %3)
%5 = tail call double @cosApprox(double 4.100000e+00)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 4, double 0xBFE264F5306A2D6A, double %5)
%7 = tail call i32 @factorial(i32 11)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 11, i32 %7)
%9 = tail call i32 @factorial(i32 12)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 12, i32 %9)
%11 = tail call i32 @factorial(i32 13)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 13, i32 %11)
%13 = tail call i32 @factorial(i32 14)
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 14, i32 %13)
%15 = tail call i32 @printProduct(double 4.100000e+00, double 3.400000e+00)
%16 = tail call double @power(double 4.100000e+00, i32 3)
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 3)
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 3, double %16)
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 3)
ret i32 0
}