#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 factorial(int);
int pow(double, int);
double my_acos(double length) {
  double radian = (3.14159265 / 2);
  double temp = 0;
  int i;
  for (i = 0; i < 10; i++) {
    temp += ((factorial(2 * i) /
              (pow(2, (2 * (double)i)) * pow(factorial(i), 2.0))) *
             (pow(length, (2 * (double)i + 1)) / (2 * (double)i + 1)));
  }
  return (radian - temp);
}


x86 assembly (clang, -O0):
<my_acos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1219 <my_acos+0xf9>
mov    -0x1c(%rbp),%edi
shl    $0x1,%edi
call   1030 <factorial@plt>
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xea0(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe90(%rip),%xmm0
call   1040 <pow@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <factorial@plt>
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  -0x38(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe3e(%rip),%xmm2
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <pow@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
cvtsi2sdl -0x1c(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe17(%rip),%xmm3
addsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <my_acos+0x29>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_acos>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x28(%rsp)
mov    %ebx,%edi
call   1030 <factorial@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%edi
movsd  0xe91(%rip),%xmm0
call   1040 <pow@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1030 <factorial@plt>
mov    $0x2,%edi
call   1040 <pow@plt>
imul   %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xe5d(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%edi
movsd  0x20(%rsp),%xmm0
call   1040 <pow@plt>
movsd  0x28(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe13(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebp
add    $0x2,%ebx
cmp    $0xa,%ebp
jne    1140 <my_acos+0x20>
movsd  0xdfe(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @my_acos(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %2
store double 0x3FF921FB53C8D4F1, double* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %5
br label %6
6: ; preds = %37, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = load i32, i32* %5
%11 = mul nsw i32 2, %10
%12 = call double @factorial(i32 %11)
%13 = load i32, i32* %5
%14 = sitofp i32 %13 to double
%15 = fmul double 2.000000e+00, %14
%16 = fptosi double %15 to i32
%17 = call i32 @pow(double 2.000000e+00, i32 %16)
%18 = load i32, i32* %5
%19 = call double @factorial(i32 %18)
%20 = call i32 @pow(double %19, i32 2)
%21 = mul nsw i32 %17, %20
%22 = sitofp i32 %21 to double
%23 = fdiv double %12, %22
%24 = load double, double* %2
%25 = load i32, i32* %5
%26 = sitofp i32 %25 to double
%27 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %26, double 1.000000e+00)
%28 = fptosi double %27 to i32
%29 = call i32 @pow(double %24, i32 %28)
%30 = sitofp i32 %29 to double
%31 = load i32, i32* %5
%32 = sitofp i32 %31 to double
%33 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %32, double 1.000000e+00)
%34 = fdiv double %30, %33
%35 = load double, double* %4
%36 = call double @llvm.fmuladd.f64(double %23, double %34, double %35)
store double %36, double* %4
br label %37
37: ; preds = %9
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %6
40: ; preds = %6
%41 = load double, double* %3
%42 = load double, double* %4
%43 = fsub double %41, %42
ret double %43
}

LLVM IR (-O2):
define double @my_acos(double %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %22, %2 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %21, %2 ]
%5 = shl nuw nsw i32 %3, 1
%6 = tail call double @factorial(i32 %5)
%7 = sitofp i32 %3 to double
%8 = fmul double %7, 2.000000e+00
%9 = fptosi double %8 to i32
%10 = tail call i32 @pow(double 2.000000e+00, i32 %9)
%11 = tail call double @factorial(i32 %3)
%12 = tail call i32 @pow(double %11, i32 2)
%13 = mul nsw i32 %12, %10
%14 = sitofp i32 %13 to double
%15 = fdiv double %6, %14
%16 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double 1.000000e+00)
%17 = fptosi double %16 to i32
%18 = tail call i32 @pow(double %0, i32 %17)
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, %16
%21 = tail call double @llvm.fmuladd.f64(double %15, double %20, double %4)
%22 = add nuw nsw i32 %3, 1
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %2
24: ; preds = %2
%25 = fsub double 0x3FF921FB53C8D4F1, %21
ret double %25
}