#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 cbrt(double);
double fabs(double);
int /*<<< orphan*/ finitef(double);
double transverse_distance(double);
double comoving_volume_to_redshift(double Vc) {
  double r = cbrt(Vc * (3.0 / (4.0 * 3.14159265358979323846264338327950288)));
  if (r <= 0)
    return 0;
  double z = 1;
  double dz = 0.1;
  double rt;
  while (dz > 1e-7) {
    rt = transverse_distance(z);
    dz = ((r - rt) * dz) /
         (transverse_distance(z + dz) - transverse_distance(z));
    if (!finitef(dz))
      return z;
    if (z + dz < 0)
      z /= 3.0;
    else
      z += dz;
    dz = fabs(dz);
    if (dz > 0.1)
      dz = 0.1;
  }
  return z;
}


x86 assembly (clang, -O0):
<comoving_volume_to_redshift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xebb(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cbrt@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     116f <comoving_volume_to_redshift+0x3f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a6 <comoving_volume_to_redshift+0x176>
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe84(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    129c <comoving_volume_to_redshift+0x16c>
movsd  -0x20(%rbp),%xmm0
call   1030 <transverse_distance@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1030 <transverse_distance@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <transverse_distance@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <finitef@plt>
cmp    $0x0,%eax
jne    121d <comoving_volume_to_redshift+0xed>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a6 <comoving_volume_to_redshift+0x176>
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    124f <comoving_volume_to_redshift+0x11f>
movsd  -0x20(%rbp),%xmm0
movsd  0xddf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    125e <comoving_volume_to_redshift+0x12e>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xdc6(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xd88(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1297 <comoving_volume_to_redshift+0x167>
movsd  0xd76(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1189 <comoving_volume_to_redshift+0x59>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comoving_volume_to_redshift>:
sub    $0x28,%rsp
mulsd  0xec4(%rip),%xmm0
call   1040 <cbrt@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm1,0x20(%rsp)
ucomisd %xmm1,%xmm0
jae    1233 <comoving_volume_to_redshift+0x103>
movsd  0xea7(%rip),%xmm1
movsd  0xea7(%rip),%xmm2
jmp    1196 <comoving_volume_to_redshift+0x66>
nopl   0x0(%rax,%rax,1)
andpd  0xeb8(%rip),%xmm3
movsd  0xe90(%rip),%xmm2
minsd  %xmm3,%xmm2
ucomisd 0xe94(%rip),%xmm2
movapd %xmm0,%xmm1
jbe    1233 <comoving_volume_to_redshift+0x103>
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1030 <transverse_distance@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
addsd  (%rsp),%xmm0
call   1030 <transverse_distance@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <transverse_distance@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
call   1050 <finitef@plt>
test   %eax,%eax
je     1238 <comoving_volume_to_redshift+0x108>
movsd  (%rsp),%xmm2
movapd %xmm2,%xmm0
movapd 0x10(%rsp),%xmm3
addsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1170 <comoving_volume_to_redshift+0x40>
divsd  0xdee(%rip),%xmm2
movapd %xmm2,%xmm0
jmp    1170 <comoving_volume_to_redshift+0x40>
add    $0x28,%rsp
ret
movsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @comoving_volume_to_redshift(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
%8 = load double, double* %3
%9 = fmul double %8, 0x3FCE8EC8A4AEACC4
%10 = call double @cbrt(double %9)
store double %10, double* %4
%11 = load double, double* %4
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %1
store double 0.000000e+00, double* %2
br label %60
14: ; preds = %1
store double 1.000000e+00, double* %5
store double 1.000000e-01, double* %6
br label %15
15: ; preds = %57, %14
%16 = load double, double* %6
%17 = fcmp ogt double %16, 0x3E7AD7F29ABCAF48
br i1 %17, label %18, label %58
18: ; preds = %15
%19 = load double, double* %5
%20 = call double @transverse_distance(double %19)
store double %20, double* %7
%21 = load double, double* %4
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = load double, double* %5
%27 = load double, double* %6
%28 = fadd double %26, %27
%29 = call double @transverse_distance(double %28)
%30 = load double, double* %5
%31 = call double @transverse_distance(double %30)
%32 = fsub double %29, %31
%33 = fdiv double %25, %32
store double %33, double* %6
%34 = load double, double* %6
%35 = call i32 @finitef(double %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %18
%38 = load double, double* %5
store double %38, double* %2
br label %60
39: ; preds = %18
%40 = load double, double* %5
%41 = load double, double* %6
%42 = fadd double %40, %41
%43 = fcmp olt double %42, 0.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load double, double* %5
%46 = fdiv double %45, 3.000000e+00
store double %46, double* %5
br label %51
47: ; preds = %39
%48 = load double, double* %6
%49 = load double, double* %5
%50 = fadd double %49, %48
store double %50, double* %5
br label %51
51: ; preds = %47, %44
%52 = load double, double* %6
%53 = call double @llvm.fabs.f64(double %52)
store double %53, double* %6
%54 = load double, double* %6
%55 = fcmp ogt double %54, 1.000000e-01
br i1 %55, label %56, label %57
56: ; preds = %51
store double 1.000000e-01, double* %6
br label %57
57: ; preds = %56, %51
br label %15
58: ; preds = %15
%59 = load double, double* %5
store double %59, double* %2
br label %60
60: ; preds = %58, %37, %13
%61 = load double, double* %2
ret double %61
}

LLVM IR (-O2):
define double @comoving_volume_to_redshift(double %0) {
%2 = fmul double %0, 0x3FCE8EC8A4AEACC4
%3 = tail call double @cbrt(double %2)
%4 = fcmp ugt double %3, 0.000000e+00
br i1 %4, label %5, label %27
5: ; preds = %1, %18
%6 = phi double [ %25, %18 ], [ 1.000000e-01, %1 ]
%7 = phi double [ %22, %18 ], [ 1.000000e+00, %1 ]
%8 = tail call double @transverse_distance(double %7)
%9 = fsub double %3, %8
%10 = fmul double %6, %9
%11 = fadd double %7, %6
%12 = tail call double @transverse_distance(double %11)
%13 = tail call double @transverse_distance(double %7)
%14 = fsub double %12, %13
%15 = fdiv double %10, %14
%16 = tail call i32 @finitef(double %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %5
%19 = fadd double %7, %15
%20 = fcmp olt double %19, 0.000000e+00
%21 = fdiv double %7, 3.000000e+00
%22 = select i1 %20, double %21, double %19
%23 = tail call double @llvm.fabs.f64(double %15)
%24 = fcmp ogt double %23, 1.000000e-01
%25 = select i1 %24, double 1.000000e-01, double %23
%26 = fcmp ogt double %25, 0x3E7AD7F29ABCAF48
br i1 %26, label %5, label %27
27: ; preds = %5, %18, %1
%28 = phi double [ 0.000000e+00, %1 ], [ %22, %18 ], [ %7, %5 ]
ret double %28
}