#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 HUGE_VAL;
double NAN;
double log(double);
double logit(double x) {
  if (x != x) {
    return x;
  }
  if (x < 0.0 || x > 1.0) {
    return NAN;
  }
  if (x == 0.0) {
    return -HUGE_VAL;
  }
  if (x == 1.0) {
    return HUGE_VAL;
  }
  return log(x / (1.0 - x));
}


x86 assembly (clang, -O0):
<logit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1138 <logit+0x28>
jp     1138 <logit+0x28>
jmp    1147 <logit+0x37>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1217 <logit+0x107>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     116c <logit+0x5c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1181 <logit+0x71>
mov    0x2e85(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1217 <logit+0x107>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c5 <logit+0xb5>
jp     11c5 <logit+0xb5>
mov    0x2e40(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1217 <logit+0x107>
movsd  -0x10(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11f7 <logit+0xe7>
jp     11f7 <logit+0xe7>
mov    0x2df7(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1217 <logit+0x107>
movsd  -0x10(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logit>:
ucomisd %xmm0,%xmm0
jp     1154 <logit+0x44>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1149 <logit+0x39>
ucomisd 0xed8(%rip),%xmm0
ja     1149 <logit+0x39>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1155 <logit+0x45>
jp     1155 <logit+0x45>
mov    0x2ea3(%rip),%rax
movsd  (%rax),%xmm0
xorps  0xec8(%rip),%xmm0
ret
mov    0x2ea8(%rip),%rax
movsd  (%rax),%xmm0
ret
ucomisd 0xea3(%rip),%xmm0
jne    116a <logit+0x5a>
jp     116a <logit+0x5a>
mov    0x2e78(%rip),%rax
jmp    1150 <logit+0x40>
movsd  0xe8e(%rip),%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm1,%xmm0
jmp    1030 <log@plt>

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@HUGE_VAL = global double 0.000000e+00
define double @logit(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = load double, double* %3
%6 = fcmp une double %4, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load double, double* %3
store double %8, double* %2
br label %34
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %3
%14 = fcmp ogt double %13, 1.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %12, %9
%16 = load double, double* @NAN
store double %16, double* %2
br label %34
17: ; preds = %12
%18 = load double, double* %3
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load double, double* @HUGE_VAL
%22 = fneg double %21
store double %22, double* %2
br label %34
23: ; preds = %17
%24 = load double, double* %3
%25 = fcmp oeq double %24, 1.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load double, double* @HUGE_VAL
store double %27, double* %2
br label %34
28: ; preds = %23
%29 = load double, double* %3
%30 = load double, double* %3
%31 = fsub double 1.000000e+00, %30
%32 = fdiv double %29, %31
%33 = call double @log(double %32)
store double %33, double* %2
br label %34
34: ; preds = %28, %26, %20, %15, %7
%35 = load double, double* %2
ret double %35
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@HUGE_VAL = global double 0.000000e+00
define double @logit(double %0) {
%2 = fcmp uno double %0, 0.000000e+00
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = fcmp olt double %0, 0.000000e+00
%5 = fcmp ogt double %0, 1.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = load double, double* @NAN
br label %22
9: ; preds = %3
%10 = fcmp oeq double %0, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = load double, double* @HUGE_VAL
%13 = fneg double %12
br label %22
14: ; preds = %9
%15 = fcmp oeq double %0, 1.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = load double, double* @HUGE_VAL
br label %22
18: ; preds = %14
%19 = fsub double 1.000000e+00, %0
%20 = fdiv double %0, %19
%21 = tail call double @log(double %20)
br label %22
22: ; preds = %1, %18, %16, %11, %7
%23 = phi double [ %8, %7 ], [ %13, %11 ], [ %17, %16 ], [ %21, %18 ], [ %0, %1 ]
ret double %23
}