#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 umath_double_pow(double, int);
double umath_double_log(double x) {
  int i;
  double result = 0.0;
  for (i = 1; i != 10; i++) {
    result += (1.0 / i) * (umath_double_pow((x - 1.0) / x, i));
  }
  return result;
}


x86 assembly (clang, -O0):
<umath_double_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
je     1192 <umath_double_log+0x82>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xebd(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
subsd  %xmm1,%xmm0
divsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1030 <umath_double_pow@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112c <umath_double_log+0x1c>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<umath_double_log>:
sub    $0x18,%rsp
movsd  0xee4(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
mov    $0x1,%edi
call   1030 <umath_double_pow@plt>
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xeaa(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x3,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe8e(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x4,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe72(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x5,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe56(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x6,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe3a(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x7,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe1e(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x8,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xe02(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x9,%edi
call   1030 <umath_double_pow@plt>
mulsd  0xde6(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @umath_double_log(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store double %0, double* %2
store double 0.000000e+00, double* %4
store i32 1, i32* %3
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sitofp i32 %9 to double
%11 = fdiv double 1.000000e+00, %10
%12 = load double, double* %2
%13 = fsub double %12, 1.000000e+00
%14 = load double, double* %2
%15 = fdiv double %13, %14
%16 = load i32, i32* %3
%17 = call double @umath_double_pow(double %15, i32 %16)
%18 = load double, double* %4
%19 = call double @llvm.fmuladd.f64(double %11, double %17, double %18)
store double %19, double* %4
br label %20
20: ; preds = %8
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %5
%24 = load double, double* %4
ret double %24
}

LLVM IR (-O2):
define double @umath_double_log(double %0) {
%2 = fadd double %0, -1.000000e+00
%3 = fdiv double %2, %0
%4 = tail call double @umath_double_pow(double %3, i32 1)
%5 = fadd double %4, 0.000000e+00
%6 = tail call double @umath_double_pow(double %3, i32 2)
%7 = tail call double @llvm.fmuladd.f64(double %6, double 5.000000e-01, double %5)
%8 = tail call double @umath_double_pow(double %3, i32 3)
%9 = tail call double @llvm.fmuladd.f64(double %8, double 0x3FD5555555555555, double %7)
%10 = tail call double @umath_double_pow(double %3, i32 4)
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.500000e-01, double %9)
%12 = tail call double @umath_double_pow(double %3, i32 5)
%13 = tail call double @llvm.fmuladd.f64(double %12, double 2.000000e-01, double %11)
%14 = tail call double @umath_double_pow(double %3, i32 6)
%15 = tail call double @llvm.fmuladd.f64(double %14, double 0x3FC5555555555555, double %13)
%16 = tail call double @umath_double_pow(double %3, i32 7)
%17 = tail call double @llvm.fmuladd.f64(double %16, double 0x3FC2492492492492, double %15)
%18 = tail call double @umath_double_pow(double %3, i32 8)
%19 = tail call double @llvm.fmuladd.f64(double %18, double 1.250000e-01, double %17)
%20 = tail call double @umath_double_pow(double %3, i32 9)
%21 = tail call double @llvm.fmuladd.f64(double %20, double 0x3FBC71C71C71C71C, double %19)
ret double %21
}