#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 */
float frexp(float, int *);
float log(float arg) {
  static float log2 = 0.693147180559945309e0;
  static float sqrto2 = 0.707106781186547524e0;
  static float p0 = -.240139179559210510e2;
  static float p1 = 0.309572928215376501e2;
  static float p2 = -.963769093368686593e1;
  static float p3 = 0.421087371217979714e0;
  static float q0 = -.120069589779605255e2;
  static float q1 = 0.194809660700889731e2;
  static float q2 = -.891110902798312337e1;
  float x, z, zsq, temp;
  int exp;
  if (arg <= 0.) {
    return -1e42;
  }
  x = frexp(arg, &exp);
  while (x < 0.5) {
    x = x * 2;
    exp = exp - 1;
  }
  if (x < sqrto2) {
    x = 2 * x;
    exp = exp - 1;
  }
  z = (x - 1) / (x + 1);
  zsq = z * z;
  temp = ((p3 * zsq + p2) * zsq + p1) * zsq + p0;
  temp = temp / (((1.0 * zsq + q2) * zsq + q1) * zsq + q0);
  temp = temp * z + exp * log2;
  return (temp);
}


x86 assembly (clang, -O0):
<log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1145 <log+0x35>
movss  0xed5(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12dd <log+0x1cd>
movss  -0x8(%rbp),%xmm0
lea    -0x1c(%rbp),%rdi
call   1030 <frexp@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe97(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1193 <log+0x83>
movss  0xe8d(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <log+0x48>
movss  -0xc(%rbp),%xmm1
movss  0x2e8c(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    11c4 <log+0xb4>
movss  0xe57(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe3b(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xe2f(%rip),%xmm1
addss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0x2e3a(%rip),%xmm0
movss  -0x14(%rbp),%xmm2
movss  0x2e29(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm2
movss  0x2e10(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm2
movss  0x2df7(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x2de8(%rip),%xmm2
cvtss2sd %xmm2,%xmm2
addsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm3
movss  0x2dcb(%rip),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm3
movss  0x2daa(%rip),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
cvtsi2ssl -0x1c(%rbp),%xmm1
mulss  0x2d62(%rip),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log>:
push   %rax
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jae    11ff <log+0xef>
lea    0x4(%rsp),%rdi
call   1030 <frexp@plt>
mov    0x4(%rsp),%eax
movss  0xed1(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    114c <log+0x3c>
nopl   0x0(%rax,%rax,1)
addss  %xmm0,%xmm0
add    $0xffffffff,%eax
ucomiss %xmm0,%xmm1
ja     1140 <log+0x30>
movss  0xeb4(%rip),%xmm1
xor    %ecx,%ecx
ucomiss %xmm0,%xmm1
seta   %cl
jbe    1162 <log+0x52>
addss  %xmm0,%xmm0
movss  0xea2(%rip),%xmm1
addss  %xmm0,%xmm1
addss  0xe9a(%rip),%xmm0
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movss  0xe8b(%rip),%xmm2
mulss  %xmm0,%xmm2
addss  0xe83(%rip),%xmm2
mulss  %xmm0,%xmm2
addss  0xe7b(%rip),%xmm2
mulss  %xmm0,%xmm2
addss  0xe73(%rip),%xmm2
cvtss2sd %xmm0,%xmm0
movsd  0xe6f(%rip),%xmm3
addsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
addsd  0xe67(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  0xe63(%rip),%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
divsd  %xmm3,%xmm0
cvtsd2ss %xmm0,%xmm0
sub    %ecx,%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
mulss  0xe2f(%rip),%xmm2
mulss  %xmm1,%xmm0
addss  %xmm2,%xmm0
pop    %rax
ret
movss  0xdf9(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@log.log2 = internal global float 0x3FE62E4300000000
@log.sqrto2 = internal global float 0x3FE6A09E60000000
@log.p0 = internal global float 0xC038039020000000
@log.p1 = internal global float 0x403EF51120000000
@log.p2 = internal global float 0xC023467F60000000
@log.p3 = internal global float 0x3FDAF31880000000
@log.q0 = internal global float 0xC028039020000000
@log.q1 = internal global float 0x40337B20A0000000
@log.q2 = internal global float 0xC021D27CE0000000
define float @log(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store float %0, float* %3
%9 = load float, float* %3
%10 = fpext float %9 to double
%11 = fcmp ole double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %1
store float 0xFFF0000000000000, float* %2
br label %80
13: ; preds = %1
%14 = load float, float* %3
%15 = call float @frexp(float %14, i32* %8)
store float %15, float* %4
br label %16
16: ; preds = %20, %13
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = fcmp olt double %18, 5.000000e-01
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load float, float* %4
%22 = fmul float %21, 2.000000e+00
store float %22, float* %4
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %8
br label %16
25: ; preds = %16
%26 = load float, float* %4
%27 = load float, float* @log.sqrto2
%28 = fcmp olt float %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load float, float* %4
%31 = fmul float 2.000000e+00, %30
store float %31, float* %4
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %8
br label %34
34: ; preds = %29, %25
%35 = load float, float* %4
%36 = fsub float %35, 1.000000e+00
%37 = load float, float* %4
%38 = fadd float %37, 1.000000e+00
%39 = fdiv float %36, %38
store float %39, float* %5
%40 = load float, float* %5
%41 = load float, float* %5
%42 = fmul float %40, %41
store float %42, float* %6
%43 = load float, float* @log.p3
%44 = load float, float* %6
%45 = load float, float* @log.p2
%46 = call float @llvm.fmuladd.f32(float %43, float %44, float %45)
%47 = load float, float* %6
%48 = load float, float* @log.p1
%49 = call float @llvm.fmuladd.f32(float %46, float %47, float %48)
%50 = load float, float* %6
%51 = load float, float* @log.p0
%52 = call float @llvm.fmuladd.f32(float %49, float %50, float %51)
store float %52, float* %7
%53 = load float, float* %7
%54 = fpext float %53 to double
%55 = load float, float* %6
%56 = fpext float %55 to double
%57 = load float, float* @log.q2
%58 = fpext float %57 to double
%59 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %56, double %58)
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = load float, float* @log.q1
%63 = fpext float %62 to double
%64 = call double @llvm.fmuladd.f64(double %59, double %61, double %63)
%65 = load float, float* %6
%66 = fpext float %65 to double
%67 = load float, float* @log.q0
%68 = fpext float %67 to double
%69 = call double @llvm.fmuladd.f64(double %64, double %66, double %68)
%70 = fdiv double %54, %69
%71 = fptrunc double %70 to float
store float %71, float* %7
%72 = load float, float* %7
%73 = load float, float* %5
%74 = load i32, i32* %8
%75 = sitofp i32 %74 to float
%76 = load float, float* @log.log2
%77 = fmul float %75, %76
%78 = call float @llvm.fmuladd.f32(float %72, float %73, float %77)
store float %78, float* %7
%79 = load float, float* %7
store float %79, float* %2
br label %80
80: ; preds = %34, %12
%81 = load float, float* %2
ret float %81
}

LLVM IR (-O2):
define float @log(float %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = fcmp ugt float %0, 0.000000e+00
br i1 %4, label %5, label %40
5: ; preds = %1
%6 = call float @frexp(float %0, i32* %2)
%7 = load i32, i32* %2
%8 = fcmp olt float %6, 5.000000e-01
br i1 %8, label %9, label %15
9: ; preds = %5, %9
%10 = phi float [ %12, %9 ], [ %6, %5 ]
%11 = phi i32 [ %13, %9 ], [ %7, %5 ]
%12 = fmul float %10, 2.000000e+00
%13 = add nsw i32 %11, -1
%14 = fcmp olt float %12, 5.000000e-01
br i1 %14, label %9, label %15
15: ; preds = %9, %5
%16 = phi i32 [ %7, %5 ], [ %13, %9 ]
%17 = phi float [ %6, %5 ], [ %12, %9 ]
%18 = fcmp olt float %17, 0x3FE6A09E60000000
%19 = fmul float %17, 2.000000e+00
%20 = sext i1 %18 to i32
%21 = add nsw i32 %16, %20
%22 = select i1 %18, float %19, float %17
%23 = fadd float %22, -1.000000e+00
%24 = fadd float %22, 1.000000e+00
%25 = fdiv float %23, %24
%26 = fmul float %25, %25
%27 = tail call float @llvm.fmuladd.f32(float %26, float 0x3FDAF31880000000, float 0xC023467F60000000)
%28 = tail call float @llvm.fmuladd.f32(float %27, float %26, float 0x403EF51120000000)
%29 = tail call float @llvm.fmuladd.f32(float %28, float %26, float 0xC038039020000000)
%30 = fpext float %29 to double
%31 = fpext float %26 to double
%32 = fadd double %31, 0xC021D27CE0000000
%33 = tail call double @llvm.fmuladd.f64(double %32, double %31, double 0x40337B20A0000000)
%34 = tail call double @llvm.fmuladd.f64(double %33, double %31, double 0xC028039020000000)
%35 = fdiv double %30, %34
%36 = fptrunc double %35 to float
%37 = sitofp i32 %21 to float
%38 = fmul float %37, 0x3FE62E4300000000
%39 = tail call float @llvm.fmuladd.f32(float %36, float %25, float %38)
br label %40
40: ; preds = %1, %15
%41 = phi float [ %39, %15 ], [ 0xFFF0000000000000, %1 ]
ret float %41
}