#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 log(int);
double ldf_Bin(int normalize, int x, double pi) {
  if (x) {
    return (((log(pi)) < -300) ? (-300)
                               : ((((log(pi)) > 300) ? (300) : (log(pi)))));
  } else {
    return (((log(1 - pi)) < -300)
                ? (-300)
                : ((((log(1 - pi)) > 300) ? (300) : (log(1 - pi)))));
  }
}


x86 assembly (clang, -O0):
<ldf_Bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b4 <ldf_Bin+0xa4>
cvttsd2si -0x18(%rbp),%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xebe(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    115e <ldf_Bin+0x4e>
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a5 <ldf_Bin+0x95>
cvttsd2si -0x18(%rbp),%edi
call   1030 <log@plt>
movsd  0xea0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118c <ldf_Bin+0x7c>
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    119b <ldf_Bin+0x8b>
cvttsd2si -0x18(%rbp),%edi
call   1030 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125a <ldf_Bin+0x14a>
movsd  0xe4c(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f1 <ldf_Bin+0xe1>
movsd  0xe19(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1250 <ldf_Bin+0x140>
movsd  0xe0f(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  0xe01(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122b <ldf_Bin+0x11b>
movsd  0xdef(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1246 <ldf_Bin+0x136>
movsd  0xdd5(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldf_Bin>:
push   %rbx
test   %esi,%esi
je     111b <ldf_Bin+0xb>
cvttsd2si %xmm0,%ebx
jmp    112b <ldf_Bin+0x1b>
movsd  0xeed(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
mov    %ebx,%edi
call   1030 <log@plt>
movapd %xmm0,%xmm1
movsd  0xec2(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     115d <ldf_Bin+0x4d>
mov    %ebx,%edi
call   1030 <log@plt>
movapd %xmm0,%xmm1
movsd  0xeb1(%rip),%xmm0
ucomisd %xmm0,%xmm1
jbe    115f <ldf_Bin+0x4f>
pop    %rbx
ret
mov    %ebx,%edi
pop    %rbx
jmp    1030 <log@plt>

LLVM IR (-O0):
define double @ldf_Bin(i32 %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %3
%11 = load double, double* %7
%12 = fptosi double %11 to i32
%13 = call double @log(i32 %12)
%14 = fcmp olt double %13, -3.000000e+02
br i1 %14, label %15, label %16
15: ; preds = %10
br label %28
16: ; preds = %10
%17 = load double, double* %7
%18 = fptosi double %17 to i32
%19 = call double @log(i32 %18)
%20 = fcmp ogt double %19, 3.000000e+02
br i1 %20, label %21, label %22
21: ; preds = %16
br label %26
22: ; preds = %16
%23 = load double, double* %7
%24 = fptosi double %23 to i32
%25 = call double @log(i32 %24)
br label %26
26: ; preds = %22, %21
%27 = phi double [ 3.000000e+02, %21 ], [ %25, %22 ]
br label %28
28: ; preds = %26, %15
%29 = phi double [ -3.000000e+02, %15 ], [ %27, %26 ]
store double %29, double* %4
br label %53
30: ; preds = %3
%31 = load double, double* %7
%32 = fsub double 1.000000e+00, %31
%33 = fptosi double %32 to i32
%34 = call double @log(i32 %33)
%35 = fcmp olt double %34, -3.000000e+02
br i1 %35, label %36, label %37
36: ; preds = %30
br label %51
37: ; preds = %30
%38 = load double, double* %7
%39 = fsub double 1.000000e+00, %38
%40 = fptosi double %39 to i32
%41 = call double @log(i32 %40)
%42 = fcmp ogt double %41, 3.000000e+02
br i1 %42, label %43, label %44
43: ; preds = %37
br label %49
44: ; preds = %37
%45 = load double, double* %7
%46 = fsub double 1.000000e+00, %45
%47 = fptosi double %46 to i32
%48 = call double @log(i32 %47)
br label %49
49: ; preds = %44, %43
%50 = phi double [ 3.000000e+02, %43 ], [ %48, %44 ]
br label %51
51: ; preds = %49, %36
%52 = phi double [ -3.000000e+02, %36 ], [ %50, %49 ]
store double %52, double* %4
br label %53
53: ; preds = %51, %28
%54 = load double, double* %4
ret double %54
}

LLVM IR (-O2):
define double @ldf_Bin(i32 %0, i32 %1, double %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = fptosi double %2 to i32
%7 = tail call double @log(i32 %6)
%8 = fcmp olt double %7, -3.000000e+02
br i1 %8, label %23, label %9
9: ; preds = %5
%10 = tail call double @log(i32 %6)
%11 = fcmp ogt double %10, 3.000000e+02
br i1 %11, label %23, label %20
12: ; preds = %3
%13 = fsub double 1.000000e+00, %2
%14 = fptosi double %13 to i32
%15 = tail call double @log(i32 %14)
%16 = fcmp olt double %15, -3.000000e+02
br i1 %16, label %23, label %17
17: ; preds = %12
%18 = tail call double @log(i32 %14)
%19 = fcmp ogt double %18, 3.000000e+02
br i1 %19, label %23, label %20
20: ; preds = %17, %9
%21 = phi i32 [ %6, %9 ], [ %14, %17 ]
%22 = tail call double @log(i32 %21)
br label %23
23: ; preds = %20, %12, %17, %5, %9
%24 = phi double [ -3.000000e+02, %5 ], [ 3.000000e+02, %9 ], [ -3.000000e+02, %12 ], [ 3.000000e+02, %17 ], [ %22, %20 ]
ret double %24
}