#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 get_base(double, double);
int /*<<< orphan*/ isfinite(double);
int pow(double, int);
double log_unbin(int bin, double error_slope, double error_offset) {
  if (!isfinite(error_slope) || !isfinite(error_offset)) {
    return 0;
  }
  double base = get_base(error_slope, error_offset);
  double min_input;
  if (base <= 1 + error_offset * 3.0 / 10.) {
    min_input = bin * 2 * (error_slope + error_offset) * 3.0;
  } else {
    min_input = (pow(base, bin * 3.0) - 1) * error_offset / error_slope;
  }
  return min_input;
}


x86 assembly (clang, -O0):
<log_unbin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
je     116b <log_unbin+0x3b>
movsd  -0x20(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    1178 <log_unbin+0x48>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122d <log_unbin+0xfd>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <get_base@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe77(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  0xe62(%rip),%xmm0
divsd  %xmm0,%xmm2
movsd  0xe4e(%rip),%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     11ee <log_unbin+0xbe>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe30(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1223 <log_unbin+0xf3>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe10(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_unbin>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,(%rsp)
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
call   1040 <isfinite@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
je     11db <log_unbin+0xab>
movsd  (%rsp),%xmm0
call   1040 <isfinite@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
je     11db <log_unbin+0xab>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <get_base@plt>
movsd  0xe83(%rip),%xmm1
mulsd  (%rsp),%xmm1
divsd  0xe7e(%rip),%xmm1
addsd  0xe7e(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11b7 <log_unbin+0x87>
lea    (%rbx,%rbx,2),%edi
call   1050 <pow@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
jmp    11db <log_unbin+0xab>
add    %ebx,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xe29(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @log_unbin(i32 %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %6
%11 = call i32 @isfinite(double %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load double, double* %7
%15 = call i32 @isfinite(double %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13, %3
store double 0.000000e+00, double* %4
br label %52
18: ; preds = %13
%19 = load double, double* %6
%20 = load double, double* %7
%21 = call double @get_base(double %19, double %20)
store double %21, double* %8
%22 = load double, double* %8
%23 = load double, double* %7
%24 = fmul double %23, 3.000000e+00
%25 = fdiv double %24, 1.000000e+01
%26 = fadd double 1.000000e+00, %25
%27 = fcmp ole double %22, %26
br i1 %27, label %28, label %37
28: ; preds = %18
%29 = load i32, i32* %5
%30 = mul nsw i32 %29, 2
%31 = sitofp i32 %30 to double
%32 = load double, double* %6
%33 = load double, double* %7
%34 = fadd double %32, %33
%35 = fmul double %31, %34
%36 = fmul double %35, 3.000000e+00
store double %36, double* %9
br label %50
37: ; preds = %18
%38 = load double, double* %8
%39 = load i32, i32* %5
%40 = sitofp i32 %39 to double
%41 = fmul double %40, 3.000000e+00
%42 = fptosi double %41 to i32
%43 = call i32 @pow(double %38, i32 %42)
%44 = sub nsw i32 %43, 1
%45 = sitofp i32 %44 to double
%46 = load double, double* %7
%47 = fmul double %45, %46
%48 = load double, double* %6
%49 = fdiv double %47, %48
store double %49, double* %9
br label %50
50: ; preds = %37, %28
%51 = load double, double* %9
store double %51, double* %4
br label %52
52: ; preds = %50, %17
%53 = load double, double* %4
ret double %53
}

LLVM IR (-O2):
define double @log_unbin(i32 %0, double %1, double %2) {
%4 = tail call i32 @isfinite(double %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %28, label %6
6: ; preds = %3
%7 = tail call i32 @isfinite(double %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %6
%10 = tail call double @get_base(double %1, double %2)
%11 = fmul double %2, 3.000000e+00
%12 = fdiv double %11, 1.000000e+01
%13 = fadd double %12, 1.000000e+00
%14 = fcmp ugt double %10, %13
br i1 %14, label %21, label %15
15: ; preds = %9
%16 = shl nsw i32 %0, 1
%17 = sitofp i32 %16 to double
%18 = fadd double %1, %2
%19 = fmul double %18, %17
%20 = fmul double %19, 3.000000e+00
br label %28
21: ; preds = %9
%22 = mul i32 %0, 3
%23 = tail call i32 @pow(double %10, i32 %22)
%24 = add nsw i32 %23, -1
%25 = sitofp i32 %24 to double
%26 = fmul double %25, %2
%27 = fdiv double %26, %1
br label %28
28: ; preds = %15, %21, %3, %6
%29 = phi double [ 0.000000e+00, %6 ], [ 0.000000e+00, %3 ], [ %20, %15 ], [ %27, %21 ]
ret double %29
}