#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 dpow(double, int);
double arctan(double n) {
  double sum = 0;
  int i;
  for (i = 0; i <= 30; i++) {
    sum += dpow(-1, i) * dpow(n, 2 * i + 1) / (2 * i + 1);
  }
  return sum;
}


x86 assembly (clang, -O0):
<arctan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
jg     118c <arctan+0x7c>
mov    -0x14(%rbp),%edi
movsd  0xebf(%rip),%xmm0
call   1030 <dpow@plt>
mov    %eax,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1030 <dpow@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112c <arctan+0x1c>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arctan>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  0xec3(%rip),%xmm0
mov    %ebx,%edi
call   1030 <dpow@plt>
mov    %eax,%r14d
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
call   1030 <dpow@plt>
imul   %r14d,%eax
cltd
idiv   %ebp
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%ebx
add    $0x2,%ebp
cmp    $0x3f,%ebp
jne    1130 <arctan+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @arctan(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 30
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = load i32, i32* %4
%10 = call i32 @dpow(double -1.000000e+00, i32 %9)
%11 = load double, double* %2
%12 = load i32, i32* %4
%13 = mul nsw i32 2, %12
%14 = add nsw i32 %13, 1
%15 = call i32 @dpow(double %11, i32 %14)
%16 = mul nsw i32 %10, %15
%17 = load i32, i32* %4
%18 = mul nsw i32 2, %17
%19 = add nsw i32 %18, 1
%20 = sdiv i32 %16, %19
%21 = sitofp i32 %20 to double
%22 = load double, double* %3
%23 = fadd double %22, %21
store double %23, double* %3
br label %24
24: ; preds = %8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @arctan(double %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %13, %2 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %12, %2 ]
%5 = tail call i32 @dpow(double -1.000000e+00, i32 %3)
%6 = shl nuw nsw i32 %3, 1
%7 = or i32 %6, 1
%8 = tail call i32 @dpow(double %0, i32 %7)
%9 = mul nsw i32 %8, %5
%10 = sdiv i32 %9, %7
%11 = sitofp i32 %10 to double
%12 = fadd double %4, %11
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 31
br i1 %14, label %15, label %2
15: ; preds = %2
ret double %12
}