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


x86 assembly (clang, -O0):
<transform2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    11be <transform2+0x8e>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     11be <transform2+0x8e>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <transform2+0x190>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    1226 <transform2+0xf6>
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     1226 <transform2+0xf6>
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe08(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1040 <log@plt>
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <transform2+0x190>
movsd  -0x20(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    12ac <transform2+0x17c>
movsd  -0x18(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    12ac <transform2+0x17c>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
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    12c0 <transform2+0x190>
jmp    12b1 <transform2+0x181>
jmp    12b6 <transform2+0x186>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform2>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x10(%rsp)
movaps %xmm1,%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1195 <transform2+0x65>
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     11cd <transform2+0x9d>
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
jne    118a <transform2+0x5a>
movsd  0x10(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1217 <transform2+0xe7>
movsd  (%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1156 <transform2+0x26>
movsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <log@plt>
movsd  (%rbx),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  (%rsp),%xmm0
jmp    120d <transform2+0xdd>
movsd  0x10(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1166 <transform2+0x36>
movsd  0x8(%rsp),%xmm1
subsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe0a(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1040 <log@plt>
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
jmp    1040 <log@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm2
movsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
subsd  %xmm0,%xmm3
movsd  %xmm3,(%rsp)
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
call   1040 <log@plt>
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
movsd  (%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
jmp    1030 <logit@plt>

LLVM IR (-O0):
define double @transform2(double %0, double %1, double %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double*
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
%10 = load double, double* %7
%11 = call i64 @isinf(double %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %4
%14 = load double, double* %8
%15 = call i64 @isinf(double %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load double, double* %6
%19 = load double, double* %7
%20 = fsub double %18, %19
%21 = call double @log(double %20)
%22 = fneg double %21
%23 = load double*, double** %9
%24 = load double, double* %23
%25 = fadd double %24, %22
store double %25, double* %23
%26 = load double, double* %6
%27 = load double, double* %7
%28 = fsub double %26, %27
%29 = call double @log(double %28)
store double %29, double* %5
br label %87
30: ; preds = %13, %4
%31 = load double, double* %8
%32 = call i64 @isinf(double %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %51, label %34
34: ; preds = %30
%35 = load double, double* %7
%36 = call i64 @isinf(double %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %34
%39 = load double, double* %8
%40 = load double, double* %6
%41 = fsub double %39, %40
%42 = fdiv double -1.000000e+00, %41
%43 = call double @log(double %42)
%44 = load double*, double** %9
%45 = load double, double* %44
%46 = fadd double %45, %43
store double %46, double* %44
%47 = load double, double* %8
%48 = load double, double* %6
%49 = fsub double %47, %48
%50 = call double @log(double %49)
store double %50, double* %5
br label %87
51: ; preds = %34, %30
%52 = load double, double* %8
%53 = call i64 @isinf(double %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %83, label %55
55: ; preds = %51
%56 = load double, double* %7
%57 = call i64 @isinf(double %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %83, label %59
59: ; preds = %55
%60 = load double, double* %8
%61 = load double, double* %7
%62 = fsub double %60, %61
%63 = load double, double* %8
%64 = load double, double* %6
%65 = fsub double %63, %64
%66 = load double, double* %6
%67 = load double, double* %7
%68 = fsub double %66, %67
%69 = fmul double %65, %68
%70 = fdiv double %62, %69
%71 = call double @log(double %70)
%72 = load double*, double** %9
%73 = load double, double* %72
%74 = fadd double %73, %71
store double %74, double* %72
%75 = load double, double* %6
%76 = load double, double* %7
%77 = fsub double %75, %76
%78 = load double, double* %8
%79 = load double, double* %7
%80 = fsub double %78, %79
%81 = fdiv double %77, %80
%82 = call double @logit(double %81)
store double %82, double* %5
br label %87
83: ; preds = %55, %51
br label %84
84: ; preds = %83
br label %85
85: ; preds = %84
%86 = load double, double* %6
store double %86, double* %5
br label %87
87: ; preds = %85, %59, %38, %17
%88 = load double, double* %5
ret double %88
}

LLVM IR (-O2):
define double @transform2(double %0, double %1, double %2, double* nocapture %3) {
%5 = tail call i64 @isinf(double %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = tail call i64 @isinf(double %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = fsub double %0, %1
%12 = tail call double @log(double %11)
%13 = load double, double* %3
%14 = fsub double %13, %12
store double %14, double* %3
%15 = tail call double @log(double %11)
br label %46
16: ; preds = %7, %4
%17 = tail call i64 @isinf(double %2)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = tail call i64 @isinf(double %1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = fsub double %2, %0
%24 = fdiv double -1.000000e+00, %23
%25 = tail call double @log(double %24)
%26 = load double, double* %3
%27 = fadd double %25, %26
store double %27, double* %3
%28 = tail call double @log(double %23)
br label %46
29: ; preds = %19, %16
%30 = tail call i64 @isinf(double %2)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = tail call i64 @isinf(double %1)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = fsub double %2, %1
%37 = fsub double %2, %0
%38 = fsub double %0, %1
%39 = fmul double %38, %37
%40 = fdiv double %36, %39
%41 = tail call double @log(double %40)
%42 = load double, double* %3
%43 = fadd double %41, %42
store double %43, double* %3
%44 = fdiv double %38, %36
%45 = tail call double @logit(double %44)
br label %46
46: ; preds = %29, %32, %35, %22, %10
%47 = phi double [ %45, %35 ], [ %28, %22 ], [ %15, %10 ], [ %0, %32 ], [ %0, %29 ]
ret double %47
}