#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 */
scalar_t__ isinf(double);
double log(double);
double logit(double);
double transform(double x, double lb, double ub) {
  if (!isinf(lb) && isinf(ub)) {
    return log(x - lb);
  } else if (!isinf(ub) && isinf(lb)) {
    return log(ub - x);
  } else if (!isinf(ub) && !isinf(lb)) {
    return logit((x - lb) / (ub - lb));
  }
  return x;
}


x86 assembly (clang, -O0):
<transform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    1188 <transform+0x58>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     1188 <transform+0x58>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    122c <transform+0xfc>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    11c9 <transform+0x99>
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     11c9 <transform+0x99>
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    122c <transform+0xfc>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    1218 <transform+0xe8>
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    1218 <transform+0xe8>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <logit@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    122c <transform+0xfc>
jmp    121d <transform+0xed>
jmp    1222 <transform+0xf2>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform>:
sub    $0x18,%rsp
movsd  %xmm2,(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movaps %xmm1,%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     118b <transform+0x5b>
movsd  (%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     11af <transform+0x7f>
movsd  (%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
jne    1180 <transform+0x50>
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     11d3 <transform+0xa3>
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  (%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1152 <transform+0x22>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
jmp    1040 <log@plt>
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1161 <transform+0x31>
movsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
jmp    1040 <log@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
jmp    1030 <logit@plt>

LLVM IR (-O0):
define double @transform(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %6
%9 = call i64 @isinf(double %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %3
%12 = load double, double* %7
%13 = call i64 @isinf(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load double, double* %5
%17 = load double, double* %6
%18 = fsub double %16, %17
%19 = call double @log(double %18)
store double %19, double* %4
br label %54
20: ; preds = %11, %3
%21 = load double, double* %7
%22 = call i64 @isinf(double %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %20
%25 = load double, double* %6
%26 = call i64 @isinf(double %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load double, double* %7
%30 = load double, double* %5
%31 = fsub double %29, %30
%32 = call double @log(double %31)
store double %32, double* %4
br label %54
33: ; preds = %24, %20
%34 = load double, double* %7
%35 = call i64 @isinf(double %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %50, label %37
37: ; preds = %33
%38 = load double, double* %6
%39 = call i64 @isinf(double %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %50, label %41
41: ; preds = %37
%42 = load double, double* %5
%43 = load double, double* %6
%44 = fsub double %42, %43
%45 = load double, double* %7
%46 = load double, double* %6
%47 = fsub double %45, %46
%48 = fdiv double %44, %47
%49 = call double @logit(double %48)
store double %49, double* %4
br label %54
50: ; preds = %37, %33
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
%53 = load double, double* %5
store double %53, double* %4
br label %54
54: ; preds = %52, %41, %28, %15
%55 = load double, double* %4
ret double %55
}

LLVM IR (-O2):
define double @transform(double %0, double %1, double %2) {
%4 = tail call i64 @isinf(double %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i64 @isinf(double %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = fsub double %0, %1
%11 = tail call double @log(double %10)
br label %32
12: ; preds = %6, %3
%13 = tail call i64 @isinf(double %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = tail call i64 @isinf(double %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = fsub double %2, %0
%20 = tail call double @log(double %19)
br label %32
21: ; preds = %15, %12
%22 = tail call i64 @isinf(double %2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = tail call i64 @isinf(double %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = fsub double %0, %1
%29 = fsub double %2, %1
%30 = fdiv double %28, %29
%31 = tail call double @logit(double %30)
br label %32
32: ; preds = %21, %24, %27, %18, %9
%33 = phi double [ %31, %27 ], [ %20, %18 ], [ %11, %9 ], [ %0, %24 ], [ %0, %21 ]
ret double %33
}