#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 */
scalar_t__ FP_Cmp(float, double);
float __addsf3(float, float const);
float __divsf3(float, int /*<<< orphan*/);
int /*<<< orphan*/ __floatsisf(int);
float __mulsf3(float, double);
double __negsf2(float);
float __subsf3(float, float const);
float FP_Log(float x) {
  const float log_2 = (float)0.69314718;
  int n;
  float answer, top, add;
  add = 0.0;
  while (FP_Cmp(x, 16.0) > 0) {
    x = __mulsf3(x, (float)0.0625);
    add = __addsf3(add, (float)(log_2 * 4));
  }
  while (FP_Cmp(x, 1.5) > 0) {
    x = __mulsf3(x, 0.5);
    add = __addsf3(add, log_2);
  }
  while (FP_Cmp(x, 0.5) < 0) {
    x = __mulsf3(x, 2.0);
    add = __subsf3(add, log_2);
  }
  x = __subsf3(x, 1.0);
  answer = 0.0;
  top = -1.0;
  for (n = 1; n < 14; ++n) {
    top = __mulsf3(top, __negsf2(x));
    answer = __addsf3(answer, __divsf3(top, __floatsisf(n)));
  }
  return __addsf3(answer, add);
}


x86 assembly (clang, -O0):
<FP_Log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xe7b(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
call   1070 <FP_Cmp@plt>
cmp    $0x0,%rax
jle    11e1 <FP_Log+0x71>
movss  -0x4(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe3a(%rip),%xmm1
call   1090 <__addsf3@plt>
movss  %xmm0,-0x18(%rbp)
jmp    1192 <FP_Log+0x22>
jmp    11e6 <FP_Log+0x76>
movss  -0x4(%rbp),%xmm0
movsd  0xe25(%rip),%xmm1
call   1070 <FP_Cmp@plt>
cmp    $0x0,%rax
jle    1235 <FP_Log+0xc5>
movss  -0x4(%rbp),%xmm0
movsd  0xe11(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xdda(%rip),%xmm1
call   1090 <__addsf3@plt>
movss  %xmm0,-0x18(%rbp)
jmp    11e6 <FP_Log+0x76>
jmp    123a <FP_Log+0xca>
movss  -0x4(%rbp),%xmm0
movsd  0xdd9(%rip),%xmm1
call   1070 <FP_Cmp@plt>
cmp    $0x0,%rax
jge    1289 <FP_Log+0x119>
movss  -0x4(%rbp),%xmm0
movsd  0xdc5(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xd86(%rip),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,-0x18(%rbp)
jmp    123a <FP_Log+0xca>
movss  -0x4(%rbp),%xmm0
movss  0xd72(%rip),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xd54(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0xe,-0xc(%rbp)
jge    1334 <FP_Log+0x1c4>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
call   1080 <__negsf2@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
call   1060 <__mulsf3@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <__floatsisf@plt>
movss  -0x20(%rbp),%xmm0
mov    %eax,%edi
call   1030 <__divsf3@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
call   1090 <__addsf3@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12bc <FP_Log+0x14c>
movss  -0x10(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1090 <__addsf3@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FP_Log>:
push   %rbx
sub    $0x10,%rsp
movsd  0xe83(%rip),%xmm1
movss  %xmm0,(%rsp)
call   1070 <FP_Cmp@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
jle    11e9 <FP_Log+0x79>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  0xe60(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
movss  0xe68(%rip),%xmm1
call   1090 <__addsf3@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movsd  0xe28(%rip),%xmm1
call   1070 <FP_Cmp@plt>
movss  (%rsp),%xmm0
test   %rax,%rax
jg     11a0 <FP_Log+0x30>
jmp    11f4 <FP_Log+0x84>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movsd  0xe14(%rip),%xmm1
movss  %xmm0,(%rsp)
call   1070 <FP_Cmp@plt>
test   %rax,%rax
jle    1259 <FP_Log+0xe9>
movss  (%rsp),%xmm0
movsd  0xe00(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
movss  0xdfc(%rip),%xmm1
call   1090 <__addsf3@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movsd  0xdc8(%rip),%xmm1
call   1070 <FP_Cmp@plt>
movss  (%rsp),%xmm0
test   %rax,%rax
jg     1210 <FP_Log+0xa0>
jmp    125e <FP_Log+0xee>
movss  (%rsp),%xmm0
movsd  0xdb2(%rip),%xmm1
movss  %xmm0,(%rsp)
call   1070 <FP_Cmp@plt>
test   %rax,%rax
js     127c <FP_Log+0x10c>
movss  (%rsp),%xmm0
jmp    12d7 <FP_Log+0x167>
movss  (%rsp),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0xd88(%rip),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
movss  0xd7c(%rip),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movsd  0xd50(%rip),%xmm1
call   1070 <FP_Cmp@plt>
movss  (%rsp),%xmm0
test   %rax,%rax
js     1290 <FP_Log+0x120>
movss  0xd51(%rip),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,0x8(%rsp)
mov    $0x1,%ebx
xorps  %xmm0,%xmm0
movss  0xd3a(%rip),%xmm1
movss  %xmm1,(%rsp)
nop
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
call   1080 <__negsf2@plt>
movaps %xmm0,%xmm1
movss  (%rsp),%xmm0
call   1060 <__mulsf3@plt>
movss  %xmm0,(%rsp)
mov    %ebx,%edi
call   1040 <__floatsisf@plt>
movss  (%rsp),%xmm0
mov    %eax,%edi
call   1030 <__divsf3@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
call   1090 <__addsf3@plt>
add    $0x1,%ebx
cmp    $0xe,%ebx
jne    1300 <FP_Log+0x190>
movss  0x4(%rsp),%xmm1
add    $0x10,%rsp
pop    %rbx
jmp    1090 <__addsf3@plt>

LLVM IR (-O0):
define float @FP_Log(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %2
store float 0x3FE62E4300000000, float* %3
store float 0.000000e+00, float* %7
br label %8
8: ; preds = %12, %1
%9 = load float, float* %2
%10 = call i64 @FP_Cmp(float %9, double 1.600000e+01)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load float, float* %2
%14 = call float @__mulsf3(float %13, double 6.250000e-02)
store float %14, float* %2
%15 = load float, float* %7
%16 = call float @__addsf3(float %15, float 0x40062E4300000000)
store float %16, float* %7
br label %8
17: ; preds = %8
br label %18
18: ; preds = %22, %17
%19 = load float, float* %2
%20 = call i64 @FP_Cmp(float %19, double 1.500000e+00)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load float, float* %2
%24 = call float @__mulsf3(float %23, double 5.000000e-01)
store float %24, float* %2
%25 = load float, float* %7
%26 = call float @__addsf3(float %25, float 0x3FE62E4300000000)
store float %26, float* %7
br label %18
27: ; preds = %18
br label %28
28: ; preds = %32, %27
%29 = load float, float* %2
%30 = call i64 @FP_Cmp(float %29, double 5.000000e-01)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load float, float* %2
%34 = call float @__mulsf3(float %33, double 2.000000e+00)
store float %34, float* %2
%35 = load float, float* %7
%36 = call float @__subsf3(float %35, float 0x3FE62E4300000000)
store float %36, float* %7
br label %28
37: ; preds = %28
%38 = load float, float* %2
%39 = call float @__subsf3(float %38, float 1.000000e+00)
store float %39, float* %2
store float 0.000000e+00, float* %5
store float -1.000000e+00, float* %6
store i32 1, i32* %4
br label %40
40: ; preds = %54, %37
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 14
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load float, float* %6
%45 = load float, float* %2
%46 = call double @__negsf2(float %45)
%47 = call float @__mulsf3(float %44, double %46)
store float %47, float* %6
%48 = load float, float* %5
%49 = load float, float* %6
%50 = load i32, i32* %4
%51 = call i32 @__floatsisf(i32 %50)
%52 = call float @__divsf3(float %49, i32 %51)
%53 = call float @__addsf3(float %48, float %52)
store float %53, float* %5
br label %54
54: ; preds = %43
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %40
57: ; preds = %40
%58 = load float, float* %5
%59 = load float, float* %7
%60 = call float @__addsf3(float %58, float %59)
ret float %60
}

LLVM IR (-O2):
define float @FP_Log(float %0) {
%2 = tail call i64 @FP_Cmp(float %0, double 1.600000e+01)
%3 = icmp sgt i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %9, %1
%5 = phi float [ %0, %1 ], [ %12, %9 ]
%6 = phi float [ 0.000000e+00, %1 ], [ %13, %9 ]
%7 = tail call i64 @FP_Cmp(float %5, double 1.500000e+00)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %21, label %16
9: ; preds = %1, %9
%10 = phi float [ %13, %9 ], [ 0.000000e+00, %1 ]
%11 = phi float [ %12, %9 ], [ %0, %1 ]
%12 = tail call float @__mulsf3(float %11, double 6.250000e-02)
%13 = tail call float @__addsf3(float %10, float 0x40062E4300000000)
%14 = tail call i64 @FP_Cmp(float %12, double 1.600000e+01)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %9, label %4
16: ; preds = %21, %4
%17 = phi float [ %5, %4 ], [ %24, %21 ]
%18 = phi float [ %6, %4 ], [ %25, %21 ]
%19 = tail call i64 @FP_Cmp(float %17, double 5.000000e-01)
%20 = icmp slt i64 %19, 0
br i1 %20, label %28, label %35
21: ; preds = %4, %21
%22 = phi float [ %25, %21 ], [ %6, %4 ]
%23 = phi float [ %24, %21 ], [ %5, %4 ]
%24 = tail call float @__mulsf3(float %23, double 5.000000e-01)
%25 = tail call float @__addsf3(float %22, float 0x3FE62E4300000000)
%26 = tail call i64 @FP_Cmp(float %24, double 1.500000e+00)
%27 = icmp sgt i64 %26, 0
br i1 %27, label %21, label %16
28: ; preds = %16, %28
%29 = phi float [ %32, %28 ], [ %18, %16 ]
%30 = phi float [ %31, %28 ], [ %17, %16 ]
%31 = tail call float @__mulsf3(float %30, double 2.000000e+00)
%32 = tail call float @__subsf3(float %29, float 0x3FE62E4300000000)
%33 = tail call i64 @FP_Cmp(float %31, double 5.000000e-01)
%34 = icmp slt i64 %33, 0
br i1 %34, label %28, label %35
35: ; preds = %28, %16
%36 = phi float [ %17, %16 ], [ %31, %28 ]
%37 = phi float [ %18, %16 ], [ %32, %28 ]
%38 = tail call float @__subsf3(float %36, float 1.000000e+00)
br label %39
39: ; preds = %35, %39
%40 = phi float [ -1.000000e+00, %35 ], [ %44, %39 ]
%41 = phi float [ 0.000000e+00, %35 ], [ %47, %39 ]
%42 = phi i32 [ 1, %35 ], [ %48, %39 ]
%43 = tail call double @__negsf2(float %38)
%44 = tail call float @__mulsf3(float %40, double %43)
%45 = tail call i32 @__floatsisf(i32 %42)
%46 = tail call float @__divsf3(float %44, i32 %45)
%47 = tail call float @__addsf3(float %41, float %46)
%48 = add nuw nsw i32 %42, 1
%49 = icmp eq i32 %48, 14
br i1 %49, label %50, label %39
50: ; preds = %39
%51 = tail call float @__addsf3(float %47, float %37)
ret float %51
}