#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
float fmaf(float, float, float);
float frexpf(float, scalar_t__ *);
float my_logf(float a) {
  float m, r, s, t, i, f;
  int32_t e;
  if ((a > 0.0f) && (a <= 3.40e+38f)) {
    m = frexpf(a, &e);
    if (m < 0.666666667f) {
      m = m + m;
      e = e - 1;
    }
    i = (float)e;
    f = m - 1.0f;
    s = f * f;
    r = fmaf(-0.130187988f, f, 0.140889585f);
    t = fmaf(-0.121489584f, f, 0.139809534f);
    r = fmaf(r, s, t);
    r = fmaf(r, f, -0.166845024f);
    r = fmaf(r, f, 0.200121149f);
    r = fmaf(r, f, -0.249996364f);
    r = fmaf(r, f, 0.333331943f);
    r = fmaf(r, f, -0.500000000f);
    r = fmaf(r, s, f);
    r = fmaf(i, 0.693147182f, r);
    return r;
  }
  return 0.0f;
}


x86 assembly (clang, -O0):
<my_logf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    12e7 <my_logf+0x1c7>
movss  0xeba(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     12e7 <my_logf+0x1c7>
movss  -0x8(%rbp),%xmm0
lea    -0x28(%rbp),%rdi
call   1040 <frexpf@plt>
movss  %xmm0,-0xc(%rbp)
movss  0xe99(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1190 <my_logf+0x70>
movss  -0xc(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
cvtsi2ssq -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe88(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xe5b(%rip),%xmm1
movss  0xe57(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xe34(%rip),%xmm1
movss  0xe30(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  0xdf3(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  0xdd3(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  0xdb3(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  0xd93(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  0xd73(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  0xd3a(%rip),%xmm1
call   1030 <fmaf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12ef <my_logf+0x1cf>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_logf>:
sub    $0x18,%rsp
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1266 <my_logf+0x146>
movss  0xec8(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     1266 <my_logf+0x146>
lea    0x10(%rsp),%rdi
call   1040 <frexpf@plt>
movss  0xeb1(%rip),%xmm1
xor    %eax,%eax
ucomiss %xmm0,%xmm1
seta   %al
mov    0x10(%rsp),%rcx
movaps %xmm0,%xmm1
ja     116d <my_logf+0x4d>
movss  0xe9b(%rip),%xmm1
sub    %rax,%rcx
cvtsi2ss %rcx,%xmm2
movss  %xmm2,0xc(%rsp)
addss  %xmm1,%xmm0
addss  0xe85(%rip),%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
movss  0xe6f(%rip),%xmm1
movss  0xe6b(%rip),%xmm2
call   1030 <fmaf@plt>
movss  %xmm0,0x8(%rsp)
movss  0xe5c(%rip),%xmm1
movss  0xe58(%rip),%xmm2
movss  (%rsp),%xmm0
call   1030 <fmaf@plt>
movaps %xmm0,%xmm2
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0xe36(%rip),%xmm2
movss  (%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0xe28(%rip),%xmm2
movss  (%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0xe1a(%rip),%xmm2
movss  (%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0xe0c(%rip),%xmm2
movss  (%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0xdfe(%rip),%xmm2
movss  (%rsp),%xmm1
call   1030 <fmaf@plt>
movss  0x4(%rsp),%xmm1
movss  (%rsp),%xmm2
call   1030 <fmaf@plt>
movaps %xmm0,%xmm2
movss  0xddd(%rip),%xmm1
movss  0xc(%rsp),%xmm0
add    $0x18,%rsp
jmp    1030 <fmaf@plt>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @my_logf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i64
store float %0, float* %3
%11 = load float, float* %3
%12 = fcmp ogt float %11, 0.000000e+00
br i1 %12, label %13, label %66
13: ; preds = %1
%14 = load float, float* %3
%15 = fcmp ole float %14, 0x47EFF933C0000000
br i1 %15, label %16, label %66
16: ; preds = %13
%17 = load float, float* %3
%18 = call float @frexpf(float %17, i64* %10)
store float %18, float* %4
%19 = load float, float* %4
%20 = fcmp olt float %19, 0x3FE5555560000000
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load float, float* %4
%23 = load float, float* %4
%24 = fadd float %22, %23
store float %24, float* %4
%25 = load i64, i64* %10
%26 = sub nsw i64 %25, 1
store i64 %26, i64* %10
br label %27
27: ; preds = %21, %16
%28 = load i64, i64* %10
%29 = sitofp i64 %28 to float
store float %29, float* %8
%30 = load float, float* %4
%31 = fsub float %30, 1.000000e+00
store float %31, float* %9
%32 = load float, float* %9
%33 = load float, float* %9
%34 = fmul float %32, %33
store float %34, float* %6
%35 = load float, float* %9
%36 = call float @llvm.fma.f32(float 0xBFC0AA0000000000, float %35, float 0x3FC208AB80000000)
store float %36, float* %5
%37 = load float, float* %9
%38 = call float @llvm.fma.f32(float 0xBFBF19F100000000, float %37, float 0x3FC1E54760000000)
store float %38, float* %7
%39 = load float, float* %5
%40 = load float, float* %6
%41 = load float, float* %7
%42 = call float @llvm.fma.f32(float %39, float %40, float %41)
store float %42, float* %5
%43 = load float, float* %5
%44 = load float, float* %9
%45 = call float @llvm.fma.f32(float %43, float %44, float 0xBFC55B2D80000000)
store float %45, float* %5
%46 = load float, float* %5
%47 = load float, float* %9
%48 = call float @llvm.fma.f32(float %46, float %47, float 0x3FC99D91E0000000)
store float %48, float* %5
%49 = load float, float* %5
%50 = load float, float* %9
%51 = call float @llvm.fma.f32(float %49, float %50, float 0xBFCFFFE180000000)
store float %51, float* %5
%52 = load float, float* %5
%53 = load float, float* %9
%54 = call float @llvm.fma.f32(float %52, float %53, float 0x3FD5554F80000000)
store float %54, float* %5
%55 = load float, float* %5
%56 = load float, float* %9
%57 = call float @llvm.fma.f32(float %55, float %56, float -5.000000e-01)
store float %57, float* %5
%58 = load float, float* %5
%59 = load float, float* %6
%60 = load float, float* %9
%61 = call float @llvm.fma.f32(float %58, float %59, float %60)
store float %61, float* %5
%62 = load float, float* %8
%63 = load float, float* %5
%64 = call float @llvm.fma.f32(float %62, float 0x3FE62E4300000000, float %63)
store float %64, float* %5
%65 = load float, float* %5
store float %65, float* %2
br label %67
66: ; preds = %13, %1
store float 0.000000e+00, float* %2
br label %67
67: ; preds = %66, %27
%68 = load float, float* %2
ret float %68
}

LLVM IR (-O2):
define float @my_logf(float %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = fcmp ogt float %0, 0.000000e+00
%5 = fcmp ole float %0, 0x47EFF933C0000000
%6 = and i1 %4, %5
br i1 %6, label %7, label %28
7: ; preds = %1
%8 = call float @frexpf(float %0, i64* %2)
%9 = fcmp olt float %8, 0x3FE5555560000000
%10 = load i64, i64* %2
%11 = sext i1 %9 to i64
%12 = add nsw i64 %10, %11
%13 = select i1 %9, float %8, float -0.000000e+00
%14 = fadd float %8, %13
%15 = sitofp i64 %12 to float
%16 = fadd float %14, -1.000000e+00
%17 = fmul float %16, %16
%18 = tail call float @llvm.fma.f32(float %16, float 0xBFC0AA0000000000, float 0x3FC208AB80000000)
%19 = tail call float @llvm.fma.f32(float %16, float 0xBFBF19F100000000, float 0x3FC1E54760000000)
%20 = tail call float @llvm.fma.f32(float %18, float %17, float %19)
%21 = tail call float @llvm.fma.f32(float %20, float %16, float 0xBFC55B2D80000000)
%22 = tail call float @llvm.fma.f32(float %21, float %16, float 0x3FC99D91E0000000)
%23 = tail call float @llvm.fma.f32(float %22, float %16, float 0xBFCFFFE180000000)
%24 = tail call float @llvm.fma.f32(float %23, float %16, float 0x3FD5554F80000000)
%25 = tail call float @llvm.fma.f32(float %24, float %16, float -5.000000e-01)
%26 = tail call float @llvm.fma.f32(float %25, float %17, float %16)
%27 = tail call float @llvm.fma.f32(float %15, float 0x3FE62E4300000000, float %26)
br label %28
28: ; preds = %1, %7
%29 = phi float [ %27, %7 ], [ 0.000000e+00, %1 ]
ret float %29
}