#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 */
long sort_omegas(double *);
double get_integration_weight(
    const double omega, double tetrahedra_omegas[24][4],
    double (*gn)(const long, const double, const double[4]),
    double (*IJ)(const long, const long, const double, const double[4])) {
  long i, j, ci;
  double sum;
  double v[4];
  sum = 0;
  for (i = 0; i < 24; i++) {
    for (j = 0; j < 4; j++) {
      v[j] = tetrahedra_omegas[i][j];
    }
    ci = sort_omegas(v);
    if (omega < v[0]) {
      sum += IJ(0, ci, omega, v) * gn(0, omega, v);
    } else {
      if (v[0] < omega && omega < v[1]) {
        sum += IJ(1, ci, omega, v) * gn(1, omega, v);
      } else {
        if (v[1] < omega && omega < v[2]) {
          sum += IJ(2, ci, omega, v) * gn(2, omega, v);
        } else {
          if (v[2] < omega && omega < v[3]) {
            sum += IJ(3, ci, omega, v) * gn(3, omega, v);
          } else {
            if (v[3] < omega) {
              sum += IJ(4, ci, omega, v) * gn(4, omega, v);
            }
          }
        }
      }
    }
  }
  return sum / 6;
}


x86 assembly (clang, -O0):
<get_integration_weight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x18,-0x28(%rbp)
jge    13f3 <get_integration_weight+0x2e3>
movq   $0x0,-0x30(%rbp)
cmpq   $0x4,-0x30(%rbp)
jge    118d <get_integration_weight+0x7d>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    114f <get_integration_weight+0x3f>
lea    -0x60(%rbp),%rdi
call   1030 <sort_omegas@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fc <get_integration_weight+0xec>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
xor    %ecx,%ecx
mov    %ecx,%edi
call   *%rax
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    13dd <get_integration_weight+0x2cd>
movsd  -0x60(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1274 <get_integration_weight+0x164>
movsd  -0x8(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1274 <get_integration_weight+0x164>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
mov    $0x1,%edi
call   *%rax
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
mov    $0x1,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    13d8 <get_integration_weight+0x2c8>
movsd  -0x58(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ec <get_integration_weight+0x1dc>
movsd  -0x8(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ec <get_integration_weight+0x1dc>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
mov    $0x2,%edi
call   *%rax
movsd  %xmm0,-0x78(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
mov    $0x2,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    13d3 <get_integration_weight+0x2c3>
movsd  -0x50(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1364 <get_integration_weight+0x254>
movsd  -0x8(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1364 <get_integration_weight+0x254>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
mov    $0x3,%edi
call   *%rax
movsd  %xmm0,-0x80(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
mov    $0x3,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    13ce <get_integration_weight+0x2be>
movsd  -0x48(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13c9 <get_integration_weight+0x2b9>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rsi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
mov    $0x4,%edi
call   *%rax
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
mov    $0x4,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    13ce <get_integration_weight+0x2be>
jmp    13d3 <get_integration_weight+0x2c3>
jmp    13d8 <get_integration_weight+0x2c8>
jmp    13dd <get_integration_weight+0x2cd>
jmp    13e2 <get_integration_weight+0x2d2>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    113c <get_integration_weight+0x2c>
movsd  -0x40(%rbp),%xmm0
movsd  0xc00(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_integration_weight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebp,%ebp
lea    0x20(%rsp),%r12
xchg   %ax,%ax
movups 0x0(%r13,%rbp,1),%xmm0
movups 0x10(%r13,%rbp,1),%xmm1
movaps %xmm1,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %r12,%rdi
call   1030 <sort_omegas@plt>
movsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    1180 <get_integration_weight+0x70>
xor    %ebx,%ebx
jmp    11d0 <get_integration_weight+0xc0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd %xmm1,%xmm0
movsd  0x28(%rsp),%xmm1
jbe    1197 <get_integration_weight+0x87>
mov    $0x1,%ebx
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
ucomisd %xmm1,%xmm0
movsd  0x30(%rsp),%xmm1
jbe    11ae <get_integration_weight+0x9e>
mov    $0x2,%ebx
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
ucomisd %xmm1,%xmm0
movsd  0x38(%rsp),%xmm1
jbe    11c5 <get_integration_weight+0xb5>
mov    $0x3,%ebx
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
mov    $0x4,%ebx
ucomisd %xmm1,%xmm0
jbe    1207 <get_integration_weight+0xf7>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
call   *%r14
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%rdi
movsd  0x10(%rsp),%xmm0
mov    %r12,%rsi
call   *%r15
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x20,%rbp
cmp    $0x300,%rbp
jne    1140 <get_integration_weight+0x30>
movsd  0x8(%rsp),%xmm0
divsd  0xdda(%rip),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @get_integration_weight(double %0, [4 x double]* %1, double (i64, double, double*)* %2, double (i64, i64, double, double*)* %3) {
%5 = alloca double
%6 = alloca [4 x double]*
%7 = alloca double (i64, double, double*)*
%8 = alloca double (i64, i64, double, double*)*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca double
%13 = alloca [4 x double]
store double %0, double* %5
store [4 x double]* %1, [4 x double]** %6
store double (i64, double, double*)* %2, double (i64, double, double*)** %7
store double (i64, i64, double, double*)* %3, double (i64, i64, double, double*)** %8
store double 0.000000e+00, double* %12
store i64 0, i64* %9
br label %14
14: ; preds = %140, %4
%15 = load i64, i64* %9
%16 = icmp slt i64 %15, 24
br i1 %16, label %17, label %143
17: ; preds = %14
store i64 0, i64* %10
br label %18
18: ; preds = %30, %17
%19 = load i64, i64* %10
%20 = icmp slt i64 %19, 4
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load [4 x double]*, [4 x double]** %6
%23 = load i64, i64* %9
%24 = getelementptr inbounds [4 x double], [4 x double]* %22, i64 %23
%25 = load i64, i64* %10
%26 = getelementptr inbounds [4 x double], [4 x double]* %24, i64 0, i64 %25
%27 = load double, double* %26
%28 = load i64, i64* %10
%29 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 %28
store double %27, double* %29
br label %30
30: ; preds = %21
%31 = load i64, i64* %10
%32 = add nsw i64 %31, 1
store i64 %32, i64* %10
br label %18
33: ; preds = %18
%34 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%35 = call i64 @sort_omegas(double* %34)
store i64 %35, i64* %11
%36 = load double, double* %5
%37 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%38 = load double, double* %37
%39 = fcmp olt double %36, %38
br i1 %39, label %40, label %52
40: ; preds = %33
%41 = load double (i64, i64, double, double*)*, double (i64, i64, double, double*)** %8
%42 = load i64, i64* %11
%43 = load double, double* %5
%44 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%45 = call double %41(i64 0, i64 %42, double %43, double* %44)
%46 = load double (i64, double, double*)*, double (i64, double, double*)** %7
%47 = load double, double* %5
%48 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%49 = call double %46(i64 0, double %47, double* %48)
%50 = load double, double* %12
%51 = call double @llvm.fmuladd.f64(double %45, double %49, double %50)
store double %51, double* %12
br label %139
52: ; preds = %33
%53 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%54 = load double, double* %53
%55 = load double, double* %5
%56 = fcmp olt double %54, %55
br i1 %56, label %57, label %74
57: ; preds = %52
%58 = load double, double* %5
%59 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 1
%60 = load double, double* %59
%61 = fcmp olt double %58, %60
br i1 %61, label %62, label %74
62: ; preds = %57
%63 = load double (i64, i64, double, double*)*, double (i64, i64, double, double*)** %8
%64 = load i64, i64* %11
%65 = load double, double* %5
%66 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%67 = call double %63(i64 1, i64 %64, double %65, double* %66)
%68 = load double (i64, double, double*)*, double (i64, double, double*)** %7
%69 = load double, double* %5
%70 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%71 = call double %68(i64 1, double %69, double* %70)
%72 = load double, double* %12
%73 = call double @llvm.fmuladd.f64(double %67, double %71, double %72)
store double %73, double* %12
br label %138
74: ; preds = %57, %52
%75 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 1
%76 = load double, double* %75
%77 = load double, double* %5
%78 = fcmp olt double %76, %77
br i1 %78, label %79, label %96
79: ; preds = %74
%80 = load double, double* %5
%81 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 2
%82 = load double, double* %81
%83 = fcmp olt double %80, %82
br i1 %83, label %84, label %96
84: ; preds = %79
%85 = load double (i64, i64, double, double*)*, double (i64, i64, double, double*)** %8
%86 = load i64, i64* %11
%87 = load double, double* %5
%88 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%89 = call double %85(i64 2, i64 %86, double %87, double* %88)
%90 = load double (i64, double, double*)*, double (i64, double, double*)** %7
%91 = load double, double* %5
%92 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%93 = call double %90(i64 2, double %91, double* %92)
%94 = load double, double* %12
%95 = call double @llvm.fmuladd.f64(double %89, double %93, double %94)
store double %95, double* %12
br label %137
96: ; preds = %79, %74
%97 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 2
%98 = load double, double* %97
%99 = load double, double* %5
%100 = fcmp olt double %98, %99
br i1 %100, label %101, label %118
101: ; preds = %96
%102 = load double, double* %5
%103 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 3
%104 = load double, double* %103
%105 = fcmp olt double %102, %104
br i1 %105, label %106, label %118
106: ; preds = %101
%107 = load double (i64, i64, double, double*)*, double (i64, i64, double, double*)** %8
%108 = load i64, i64* %11
%109 = load double, double* %5
%110 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%111 = call double %107(i64 3, i64 %108, double %109, double* %110)
%112 = load double (i64, double, double*)*, double (i64, double, double*)** %7
%113 = load double, double* %5
%114 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%115 = call double %112(i64 3, double %113, double* %114)
%116 = load double, double* %12
%117 = call double @llvm.fmuladd.f64(double %111, double %115, double %116)
store double %117, double* %12
br label %136
118: ; preds = %101, %96
%119 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 3
%120 = load double, double* %119
%121 = load double, double* %5
%122 = fcmp olt double %120, %121
br i1 %122, label %123, label %135
123: ; preds = %118
%124 = load double (i64, i64, double, double*)*, double (i64, i64, double, double*)** %8
%125 = load i64, i64* %11
%126 = load double, double* %5
%127 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%128 = call double %124(i64 4, i64 %125, double %126, double* %127)
%129 = load double (i64, double, double*)*, double (i64, double, double*)** %7
%130 = load double, double* %5
%131 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%132 = call double %129(i64 4, double %130, double* %131)
%133 = load double, double* %12
%134 = call double @llvm.fmuladd.f64(double %128, double %132, double %133)
store double %134, double* %12
br label %135
135: ; preds = %123, %118
br label %136
136: ; preds = %135, %106
br label %137
137: ; preds = %136, %84
br label %138
138: ; preds = %137, %62
br label %139
139: ; preds = %138, %40
br label %140
140: ; preds = %139
%141 = load i64, i64* %9
%142 = add nsw i64 %141, 1
store i64 %142, i64* %9
br label %14
143: ; preds = %14
%144 = load double, double* %12
%145 = fdiv double %144, 6.000000e+00
ret double %145
}

LLVM IR (-O2):
define double @get_integration_weight(double %0, [4 x double]* nocapture %1, double (i64, double, double*)* nocapture %2, double (i64, i64, double, double*)* nocapture %3) {
%5 = alloca [4 x double]
%6 = bitcast [4 x double]* %5 to i8*
%7 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 0
%8 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 1
%9 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 2
%10 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 3
br label %11
11: ; preds = %4, %41
%12 = phi double [ 0.000000e+00, %4 ], [ %42, %41 ]
%13 = phi i64 [ 0, %4 ], [ %43, %41 ]
%14 = getelementptr [4 x double], [4 x double]* %1, i64 %13, i64 0
%15 = bitcast double* %14 to i8*
%16 = call i64 @sort_omegas(double* %7)
%17 = load double, double* %7
%18 = fcmp ogt double %17, %0
br i1 %18, label %36, label %19
19: ; preds = %11
%20 = fcmp olt double %17, %0
%21 = load double, double* %8
%22 = fcmp ogt double %21, %0
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %36, label %24
24: ; preds = %19
%25 = fcmp olt double %21, %0
%26 = load double, double* %9
%27 = fcmp ogt double %26, %0
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %36, label %29
29: ; preds = %24
%30 = fcmp olt double %26, %0
%31 = load double, double* %10
%32 = fcmp ogt double %31, %0
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = fcmp olt double %31, %0
br i1 %35, label %36, label %41
36: ; preds = %34, %29, %24, %19, %11
%37 = phi i64 [ 0, %11 ], [ 1, %19 ], [ 2, %24 ], [ 3, %29 ], [ 4, %34 ]
%38 = call double %3(i64 %37, i64 %16, double %0, double* %7)
%39 = call double %2(i64 %37, double %0, double* %7)
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double %12)
br label %41
41: ; preds = %36, %34
%42 = phi double [ %12, %34 ], [ %40, %36 ]
%43 = add nuw nsw i64 %13, 1
%44 = icmp eq i64 %43, 24
br i1 %44, label %45, label %11
45: ; preds = %41
%46 = fdiv double %42, 6.000000e+00
ret double %46
}