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


x86 assembly (clang, -O0):
<ln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jg     1191 <ln+0x81>
mov    -0x14(%rbp),%edi
movsd  0xec7(%rip),%xmm0
call   1030 <dpow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x14(%rbp),%edi
call   1030 <dpow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112c <ln+0x1c>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln>:
push   %rbx
sub    $0x20,%rsp
addsd  0xee3(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
movsd  0xed4(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm2,0x18(%rsp)
movsd  %xmm0,(%rsp)
movsd  0xead(%rip),%xmm0
mov    %ebx,%edi
call   1030 <dpow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <dpow@plt>
movsd  0x18(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
addsd  0xe70(%rip),%xmm2
add    $0x1,%ebx
cmp    $0x33,%ebx
jne    1140 <ln+0x30>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @ln(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 1, i32* %4
br label %5
5: ; preds = %21, %1
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 50
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load i32, i32* %4
%10 = call double @dpow(double -1.000000e+00, i32 %9)
%11 = load double, double* %2
%12 = fsub double %11, 1.000000e+00
%13 = load i32, i32* %4
%14 = call double @dpow(double %12, i32 %13)
%15 = fmul double %10, %14
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
%19 = load double, double* %3
%20 = fadd double %19, %18
store double %20, double* %3
br label %21
21: ; preds = %8
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %5
%25 = load double, double* %3
ret double %25
}

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