#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 const);
double ortho_para_ratio(double T) {
  double weights[6], sum_ortho = 0.0, sum_para = 0.0;
  int i;
  const double energy[6] = {0e0, 170.5, 509.9, 1015.1, 1681.7, 2504e0};
  for (i = 0; i <= 5; i++)
    weights[i] = 2e0 * (double)i + 1e0;
  for (i = 0; i <= 4; i += 2)
    sum_para += weights[i] * exp(-energy[i] / T);
  for (i = 1; i <= 5; i += 2)
    sum_ortho += weights[i] * exp(-energy[i] / T);
  return sum_para / (3e0 * sum_ortho + sum_para);
}


x86 assembly (clang, -O0):
<ortho_para_ratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jg     11d5 <ortho_para_ratio+0xb5>
cvtsi2sdl -0x54(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe77(%rip),%xmm1
addsd  %xmm1,%xmm0
movslq -0x54(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    119e <ortho_para_ratio+0x7e>
movl   $0x0,-0x54(%rbp)
cmpl   $0x4,-0x54(%rbp)
jg     1251 <ortho_para_ratio+0x131>
movslq -0x54(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movslq -0x54(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
jmp    11dc <ortho_para_ratio+0xbc>
movl   $0x1,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jg     12cd <ortho_para_ratio+0x1ad>
movslq -0x54(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movslq -0x54(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
jmp    1258 <ortho_para_ratio+0x138>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  0xd44(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ortho_para_ratio>:
sub    $0x28,%rsp
movapd %xmm0,%xmm1
movsd  %xmm0,(%rsp)
movsd  0xedb(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xecc(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xebc(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xeac(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0xea2(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe94(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0xe8a(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe7e(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0xe74(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm2
mulsd  0xe68(%rip),%xmm2
movsd  0x20(%rsp),%xmm1
addsd  0xe6a(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0x10(%rsp),%xmm1
mulsd  0xe50(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  0xe14(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ortho_para_ratio(double %0) {
%2 = alloca double
%3 = alloca [6 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca [6 x double]
store double %0, double* %2
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
%8 = bitcast [6 x double]* %7 to i8*
%9 = bitcast i8* %8 to [6 x double]*
%10 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 1
store double 1.705000e+02, double* %10
%11 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 2
store double 5.099000e+02, double* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 3
store double 1.015100e+03, double* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 4
store double 1.681700e+03, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 5
store double 2.504000e+03, double* %14
store i32 0, i32* %6
br label %15
15: ; preds = %25, %1
%16 = load i32, i32* %6
%17 = icmp sle i32 %16, 5
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
%21 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %20, double 1.000000e+00)
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 %23
store double %21, double* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %15
28: ; preds = %15
store i32 0, i32* %6
br label %29
29: ; preds = %47, %28
%30 = load i32, i32* %6
%31 = icmp sle i32 %30, 4
br i1 %31, label %32, label %50
32: ; preds = %29
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 %34
%36 = load double, double* %35
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [6 x double], [6 x double]* %7, i64 0, i64 %38
%40 = load double, double* %39
%41 = fneg double %40
%42 = load double, double* %2
%43 = fdiv double %41, %42
%44 = call double @exp(double %43)
%45 = load double, double* %5
%46 = call double @llvm.fmuladd.f64(double %36, double %44, double %45)
store double %46, double* %5
br label %47
47: ; preds = %32
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 2
store i32 %49, i32* %6
br label %29
50: ; preds = %29
store i32 1, i32* %6
br label %51
51: ; preds = %69, %50
%52 = load i32, i32* %6
%53 = icmp sle i32 %52, 5
br i1 %53, label %54, label %72
54: ; preds = %51
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 %56
%58 = load double, double* %57
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [6 x double], [6 x double]* %7, i64 0, i64 %60
%62 = load double, double* %61
%63 = fneg double %62
%64 = load double, double* %2
%65 = fdiv double %63, %64
%66 = call double @exp(double %65)
%67 = load double, double* %4
%68 = call double @llvm.fmuladd.f64(double %58, double %66, double %67)
store double %68, double* %4
br label %69
69: ; preds = %54
%70 = load i32, i32* %6
%71 = add nsw i32 %70, 2
store i32 %71, i32* %6
br label %51
72: ; preds = %51
%73 = load double, double* %5
%74 = load double, double* %4
%75 = load double, double* %5
%76 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %74, double %75)
%77 = fdiv double %73, %76
ret double %77
}

LLVM IR (-O2):
define double @ortho_para_ratio(double %0) {
%2 = fdiv double -0.000000e+00, %0
%3 = tail call double @exp(double %2)
%4 = fdiv double -5.099000e+02, %0
%5 = tail call double @exp(double %4)
%6 = fdiv double -1.681700e+03, %0
%7 = tail call double @exp(double %6)
%8 = fdiv double -1.705000e+02, %0
%9 = tail call double @exp(double %8)
%10 = tail call double @llvm.fmuladd.f64(double %9, double 3.000000e+00, double 0.000000e+00)
%11 = fdiv double -1.015100e+03, %0
%12 = tail call double @exp(double %11)
%13 = tail call double @llvm.fmuladd.f64(double %12, double 7.000000e+00, double %10)
%14 = fdiv double -2.504000e+03, %0
%15 = tail call double @exp(double %14)
%16 = tail call double @llvm.fmuladd.f64(double %15, double 1.100000e+01, double %13)
%17 = fadd double %3, 0.000000e+00
%18 = tail call double @llvm.fmuladd.f64(double %5, double 5.000000e+00, double %17)
%19 = tail call double @llvm.fmuladd.f64(double %7, double 9.000000e+00, double %18)
%20 = tail call double @llvm.fmuladd.f64(double %16, double 3.000000e+00, double %19)
%21 = fdiv double %19, %20
ret double %21
}