#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 exp(double);
scalar_t__ isinf(double);
double grad_log_det_inverse_transform(double z, double lb, double ub) {
  if (lb == 0.0 && isinf(ub)) {
    return 1.0;
  } else if (isinf(ub) && isinf(lb)) {
    return 0;
  }
  double exp_x = exp(z);
  return (1.0 - exp_x) / (1.0 + exp_x);
}


x86 assembly (clang, -O0):
<grad_log_det_inverse_transform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1175 <grad_log_det_inverse_transform+0x55>
jp     1175 <grad_log_det_inverse_transform+0x55>
movsd  -0x20(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
je     1175 <grad_log_det_inverse_transform+0x55>
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e1 <grad_log_det_inverse_transform+0xc1>
movsd  -0x20(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
je     11aa <grad_log_det_inverse_transform+0x8a>
movsd  -0x18(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
je     11aa <grad_log_det_inverse_transform+0x8a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e1 <grad_log_det_inverse_transform+0xc1>
jmp    11af <grad_log_det_inverse_transform+0x8f>
movsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe3a(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xe2d(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grad_log_det_inverse_transform>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm1,0x8(%rsp)
ucomisd %xmm0,%xmm1
jne    1161 <grad_log_det_inverse_transform+0x41>
jp     1161 <grad_log_det_inverse_transform+0x41>
movapd %xmm2,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <isinf@plt>
movsd  (%rsp),%xmm2
test   %rax,%rax
je     1161 <grad_log_det_inverse_transform+0x41>
movsd  0xea4(%rip),%xmm0
add    $0x18,%rsp
ret
movaps %xmm2,%xmm0
call   1040 <isinf@plt>
test   %rax,%rax
je     1186 <grad_log_det_inverse_transform+0x66>
movsd  0x8(%rsp),%xmm0
call   1040 <isinf@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
je     1186 <grad_log_det_inverse_transform+0x66>
add    $0x18,%rsp
ret
movsd  0x10(%rsp),%xmm0
call   1030 <exp@plt>
movapd %xmm0,%xmm1
movsd  0xe63(%rip),%xmm2
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @grad_log_det_inverse_transform(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %6
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %16
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 %16
15: ; preds = %11
store double 1.000000e+00, double* %4
br label %34
16: ; preds = %11, %3
%17 = load double, double* %7
%18 = call i64 @isinf(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load double, double* %6
%22 = call i64 @isinf(double %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store double 0.000000e+00, double* %4
br label %34
25: ; preds = %20, %16
br label %26
26: ; preds = %25
%27 = load double, double* %5
%28 = call double @exp(double %27)
store double %28, double* %8
%29 = load double, double* %8
%30 = fsub double 1.000000e+00, %29
%31 = load double, double* %8
%32 = fadd double 1.000000e+00, %31
%33 = fdiv double %30, %32
store double %33, double* %4
br label %34
34: ; preds = %26, %24, %15
%35 = load double, double* %4
ret double %35
}

LLVM IR (-O2):
define double @grad_log_det_inverse_transform(double %0, double %1, double %2) {
%4 = fcmp oeq double %1, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i64 @isinf(double %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5, %3
%9 = tail call i64 @isinf(double %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i64 @isinf(double %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %8, %11
%15 = tail call double @exp(double %0)
%16 = fsub double 1.000000e+00, %15
%17 = fadd double %15, 1.000000e+00
%18 = fdiv double %16, %17
br label %19
19: ; preds = %11, %5, %14
%20 = phi double [ %18, %14 ], [ 1.000000e+00, %5 ], [ 0.000000e+00, %11 ]
ret double %20
}