#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 pow(double, double);
double calc_comoving_distance(double red, double dz, double Om, double OL) {
  int i = 0;
  double z, result = 0.0;
  result =
      pow(Om * pow(red + 1, 3) + (red + 1) * (red + 1) * (1 - Om - OL) + OL,
          -0.5) /
          2.0 +
      0.5;
  for (z = dz; z < red - dz * 0.1; z += dz, i++)
    result +=
        pow(Om * pow(z + 1, 3) + (z + 1) * (z + 1) * (1 - Om - OL) + OL, -0.5);
  return result * dz * 2997.92458;
}


x86 assembly (clang, -O0):
<calc_comoving_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xecb(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  0xea9(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  0xe9c(%rip),%xmm3
addsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movsd  0xe8b(%rip),%xmm3
subsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe4b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe37(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe1e(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12bd <calc_comoving_distance+0x1ad>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdea(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xde5(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  0xdc8(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xdbb(%rip),%xmm3
addsd  -0x30(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movsd  0xdaa(%rip),%xmm3
subsd  -0x18(%rbp),%xmm3
subsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xd7f(%rip),%xmm1
call   1030 <pow@plt>
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11dc <calc_comoving_distance+0xcc>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xd61(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_comoving_distance>:
sub    $0x48,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x10(%rsp)
addsd  0xecc(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xec6(%rip),%xmm1
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm4
mulsd  %xmm4,%xmm4
movsd  0xea7(%rip),%xmm1
movsd  0x18(%rsp),%xmm3
subsd  %xmm3,%xmm1
movsd  0x20(%rsp),%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x38(%rsp)
mulsd  %xmm1,%xmm4
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe85(%rip),%xmm1
call   1030 <pow@plt>
movsd  0x28(%rsp),%xmm1
movapd %xmm0,%xmm2
movsd  0xe76(%rip),%xmm0
mulsd  %xmm0,%xmm2
addsd  %xmm0,%xmm2
movsd  0xe6e(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0x10(%rsp),%xmm3
ucomisd %xmm1,%xmm3
jbe    124e <calc_comoving_distance+0x13e>
movapd %xmm1,%xmm4
movsd  %xmm3,0x30(%rsp)
movsd  %xmm4,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
movapd %xmm4,%xmm0
addsd  0xe18(%rip),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  0xe12(%rip),%xmm1
call   1030 <pow@plt>
movsd  0x40(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  0x38(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
addsd  0x20(%rsp),%xmm0
movsd  0xded(%rip),%xmm1
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm4
movsd  0x30(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
addsd  %xmm0,%xmm2
addsd  %xmm1,%xmm4
ucomisd %xmm4,%xmm3
ja     11d0 <calc_comoving_distance+0xc0>
mulsd  %xmm1,%xmm2
mulsd  0xdce(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @calc_comoving_distance(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store i32 0, i32* %9
store double 0.000000e+00, double* %11
%12 = load double, double* %7
%13 = load double, double* %5
%14 = fadd double %13, 1.000000e+00
%15 = call double @pow(double %14, double 3.000000e+00)
%16 = load double, double* %5
%17 = fadd double %16, 1.000000e+00
%18 = load double, double* %5
%19 = fadd double %18, 1.000000e+00
%20 = fmul double %17, %19
%21 = load double, double* %7
%22 = fsub double 1.000000e+00, %21
%23 = load double, double* %8
%24 = fsub double %22, %23
%25 = fmul double %20, %24
%26 = call double @llvm.fmuladd.f64(double %12, double %15, double %25)
%27 = load double, double* %8
%28 = fadd double %26, %27
%29 = call double @pow(double %28, double -5.000000e-01)
%30 = fdiv double %29, 2.000000e+00
%31 = fadd double %30, 5.000000e-01
store double %31, double* %11
%32 = load double, double* %6
store double %32, double* %10
br label %33
33: ; preds = %61, %4
%34 = load double, double* %10
%35 = load double, double* %5
%36 = load double, double* %6
%37 = fneg double %36
%38 = call double @llvm.fmuladd.f64(double %37, double 1.000000e-01, double %35)
%39 = fcmp olt double %34, %38
br i1 %39, label %40, label %67
40: ; preds = %33
%41 = load double, double* %7
%42 = load double, double* %10
%43 = fadd double %42, 1.000000e+00
%44 = call double @pow(double %43, double 3.000000e+00)
%45 = load double, double* %10
%46 = fadd double %45, 1.000000e+00
%47 = load double, double* %10
%48 = fadd double %47, 1.000000e+00
%49 = fmul double %46, %48
%50 = load double, double* %7
%51 = fsub double 1.000000e+00, %50
%52 = load double, double* %8
%53 = fsub double %51, %52
%54 = fmul double %49, %53
%55 = call double @llvm.fmuladd.f64(double %41, double %44, double %54)
%56 = load double, double* %8
%57 = fadd double %55, %56
%58 = call double @pow(double %57, double -5.000000e-01)
%59 = load double, double* %11
%60 = fadd double %59, %58
store double %60, double* %11
br label %61
61: ; preds = %40
%62 = load double, double* %6
%63 = load double, double* %10
%64 = fadd double %63, %62
store double %64, double* %10
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %33
67: ; preds = %33
%68 = load double, double* %11
%69 = load double, double* %6
%70 = fmul double %68, %69
%71 = fmul double %70, 0x40A76BD9628CBD12
ret double %71
}

LLVM IR (-O2):
define double @calc_comoving_distance(double %0, double %1, double %2, double %3) {
%5 = fadd double %0, 1.000000e+00
%6 = tail call double @pow(double %5, double 3.000000e+00)
%7 = fmul double %5, %5
%8 = fsub double 1.000000e+00, %2
%9 = fsub double %8, %3
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %2, double %6, double %10)
%12 = fadd double %11, %3
%13 = tail call double @pow(double %12, double -5.000000e-01)
%14 = fmul double %13, 5.000000e-01
%15 = fadd double %14, 5.000000e-01
%16 = fneg double %1
%17 = tail call double @llvm.fmuladd.f64(double %16, double 1.000000e-01, double %0)
%18 = fcmp ogt double %17, %1
br i1 %18, label %19, label %32
19: ; preds = %4, %19
%20 = phi double [ %29, %19 ], [ %15, %4 ]
%21 = phi double [ %30, %19 ], [ %1, %4 ]
%22 = fadd double %21, 1.000000e+00
%23 = tail call double @pow(double %22, double 3.000000e+00)
%24 = fmul double %22, %22
%25 = fmul double %9, %24
%26 = tail call double @llvm.fmuladd.f64(double %2, double %23, double %25)
%27 = fadd double %26, %3
%28 = tail call double @pow(double %27, double -5.000000e-01)
%29 = fadd double %20, %28
%30 = fadd double %21, %1
%31 = fcmp olt double %30, %17
br i1 %31, label %19, label %32
32: ; preds = %19, %4
%33 = phi double [ %15, %4 ], [ %29, %19 ]
%34 = fmul double %33, %1
%35 = fmul double %34, 0x40A76BD9628CBD12
ret double %35
}