#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 */
int sort_omegas(double *);
double get_integration_weight(
    const double omega, double tetrahedra_omegas[24][4],
    double (*gn)(const int, const double, const double[4]),
    double (*IJ)(const int, const int, const double, const double[4])) {
  int 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,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x18,-0x24(%rbp)
jge    13df <get_integration_weight+0x2cf>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1186 <get_integration_weight+0x76>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x28(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <get_integration_weight+0x3c>
lea    -0x60(%rbp),%rdi
call   1030 <sort_omegas@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ef <get_integration_weight+0xdf>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
xor    %edi,%edi
call   *%rax
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
xor    %edi,%edi
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13cc <get_integration_weight+0x2bc>
movsd  -0x60(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1266 <get_integration_weight+0x156>
movsd  -0x8(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1266 <get_integration_weight+0x156>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%esi
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  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13c7 <get_integration_weight+0x2b7>
movsd  -0x58(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12dd <get_integration_weight+0x1cd>
movsd  -0x8(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12dd <get_integration_weight+0x1cd>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%esi
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  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13c2 <get_integration_weight+0x2b2>
movsd  -0x50(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1354 <get_integration_weight+0x244>
movsd  -0x8(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1354 <get_integration_weight+0x244>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%esi
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  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13bd <get_integration_weight+0x2ad>
movsd  -0x48(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13b8 <get_integration_weight+0x2a8>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%esi
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  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13bd <get_integration_weight+0x2ad>
jmp    13c2 <get_integration_weight+0x2b2>
jmp    13c7 <get_integration_weight+0x2b7>
jmp    13cc <get_integration_weight+0x2bc>
jmp    13d1 <get_integration_weight+0x2c1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113b <get_integration_weight+0x2b>
movsd  -0x38(%rbp),%xmm0
movsd  0xc14(%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    %ebx,%ebx
lea    0x20(%rsp),%r12
xchg   %ax,%ax
movups 0x0(%r13,%rbx,1),%xmm0
movups 0x10(%r13,%rbx,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
mov    $0x0,%ebp
ja     11d0 <get_integration_weight+0xc0>
ucomisd %xmm1,%xmm0
movsd  0x28(%rsp),%xmm1
jbe    118c <get_integration_weight+0x7c>
mov    $0x1,%ebp
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
ucomisd %xmm1,%xmm0
movsd  0x30(%rsp),%xmm1
jbe    11a3 <get_integration_weight+0x93>
mov    $0x2,%ebp
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
ucomisd %xmm1,%xmm0
movsd  0x38(%rsp),%xmm1
jbe    11ba <get_integration_weight+0xaa>
mov    $0x3,%ebp
ucomisd %xmm0,%xmm1
ja     11d0 <get_integration_weight+0xc0>
mov    $0x4,%ebp
ucomisd %xmm1,%xmm0
jbe    1204 <get_integration_weight+0xf4>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %eax,%esi
mov    %r12,%rdx
call   *%r14
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
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,%rbx
cmp    $0x300,%rbx
jne    1140 <get_integration_weight+0x30>
movsd  0x8(%rsp),%xmm0
divsd  0xddd(%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 (i32, double, double*)* %2, double (i32, i32, double, double*)* %3) {
%5 = alloca double
%6 = alloca [4 x double]*
%7 = alloca double (i32, double, double*)*
%8 = alloca double (i32, i32, double, double*)*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca [4 x double]
store double %0, double* %5
store [4 x double]* %1, [4 x double]** %6
store double (i32, double, double*)* %2, double (i32, double, double*)** %7
store double (i32, i32, double, double*)* %3, double (i32, i32, double, double*)** %8
store double 0.000000e+00, double* %12
store i32 0, i32* %9
br label %14
14: ; preds = %143, %4
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 24
br i1 %16, label %17, label %146
17: ; preds = %14
store i32 0, i32* %10
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %10
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %36
21: ; preds = %18
%22 = load [4 x double]*, [4 x double]** %6
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x double], [4 x double]* %22, i64 %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x double], [4 x double]* %25, i64 0, i64 %27
%29 = load double, double* %28
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 %31
store double %29, double* %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %18
36: ; preds = %18
%37 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%38 = call i32 @sort_omegas(double* %37)
store i32 %38, i32* %11
%39 = load double, double* %5
%40 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%41 = load double, double* %40
%42 = fcmp olt double %39, %41
br i1 %42, label %43, label %55
43: ; preds = %36
%44 = load double (i32, i32, double, double*)*, double (i32, i32, double, double*)** %8
%45 = load i32, i32* %11
%46 = load double, double* %5
%47 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%48 = call double %44(i32 0, i32 %45, double %46, double* %47)
%49 = load double (i32, double, double*)*, double (i32, double, double*)** %7
%50 = load double, double* %5
%51 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%52 = call double %49(i32 0, double %50, double* %51)
%53 = load double, double* %12
%54 = call double @llvm.fmuladd.f64(double %48, double %52, double %53)
store double %54, double* %12
br label %142
55: ; preds = %36
%56 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%57 = load double, double* %56
%58 = load double, double* %5
%59 = fcmp olt double %57, %58
br i1 %59, label %60, label %77
60: ; preds = %55
%61 = load double, double* %5
%62 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 1
%63 = load double, double* %62
%64 = fcmp olt double %61, %63
br i1 %64, label %65, label %77
65: ; preds = %60
%66 = load double (i32, i32, double, double*)*, double (i32, i32, double, double*)** %8
%67 = load i32, i32* %11
%68 = load double, double* %5
%69 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%70 = call double %66(i32 1, i32 %67, double %68, double* %69)
%71 = load double (i32, double, double*)*, double (i32, double, double*)** %7
%72 = load double, double* %5
%73 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%74 = call double %71(i32 1, double %72, double* %73)
%75 = load double, double* %12
%76 = call double @llvm.fmuladd.f64(double %70, double %74, double %75)
store double %76, double* %12
br label %141
77: ; preds = %60, %55
%78 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 1
%79 = load double, double* %78
%80 = load double, double* %5
%81 = fcmp olt double %79, %80
br i1 %81, label %82, label %99
82: ; preds = %77
%83 = load double, double* %5
%84 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 2
%85 = load double, double* %84
%86 = fcmp olt double %83, %85
br i1 %86, label %87, label %99
87: ; preds = %82
%88 = load double (i32, i32, double, double*)*, double (i32, i32, double, double*)** %8
%89 = load i32, i32* %11
%90 = load double, double* %5
%91 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%92 = call double %88(i32 2, i32 %89, double %90, double* %91)
%93 = load double (i32, double, double*)*, double (i32, double, double*)** %7
%94 = load double, double* %5
%95 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%96 = call double %93(i32 2, double %94, double* %95)
%97 = load double, double* %12
%98 = call double @llvm.fmuladd.f64(double %92, double %96, double %97)
store double %98, double* %12
br label %140
99: ; preds = %82, %77
%100 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 2
%101 = load double, double* %100
%102 = load double, double* %5
%103 = fcmp olt double %101, %102
br i1 %103, label %104, label %121
104: ; preds = %99
%105 = load double, double* %5
%106 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 3
%107 = load double, double* %106
%108 = fcmp olt double %105, %107
br i1 %108, label %109, label %121
109: ; preds = %104
%110 = load double (i32, i32, double, double*)*, double (i32, i32, double, double*)** %8
%111 = load i32, i32* %11
%112 = load double, double* %5
%113 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%114 = call double %110(i32 3, i32 %111, double %112, double* %113)
%115 = load double (i32, double, double*)*, double (i32, double, double*)** %7
%116 = load double, double* %5
%117 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%118 = call double %115(i32 3, double %116, double* %117)
%119 = load double, double* %12
%120 = call double @llvm.fmuladd.f64(double %114, double %118, double %119)
store double %120, double* %12
br label %139
121: ; preds = %104, %99
%122 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 3
%123 = load double, double* %122
%124 = load double, double* %5
%125 = fcmp olt double %123, %124
br i1 %125, label %126, label %138
126: ; preds = %121
%127 = load double (i32, i32, double, double*)*, double (i32, i32, double, double*)** %8
%128 = load i32, i32* %11
%129 = load double, double* %5
%130 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%131 = call double %127(i32 4, i32 %128, double %129, double* %130)
%132 = load double (i32, double, double*)*, double (i32, double, double*)** %7
%133 = load double, double* %5
%134 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%135 = call double %132(i32 4, double %133, double* %134)
%136 = load double, double* %12
%137 = call double @llvm.fmuladd.f64(double %131, double %135, double %136)
store double %137, double* %12
br label %138
138: ; preds = %126, %121
br label %139
139: ; preds = %138, %109
br label %140
140: ; preds = %139, %87
br label %141
141: ; preds = %140, %65
br label %142
142: ; preds = %141, %43
br label %143
143: ; preds = %142
%144 = load i32, i32* %9
%145 = add nsw i32 %144, 1
store i32 %145, i32* %9
br label %14
146: ; preds = %14
%147 = load double, double* %12
%148 = fdiv double %147, 6.000000e+00
ret double %148
}

LLVM IR (-O2):
define double @get_integration_weight(double %0, [4 x double]* nocapture %1, double (i32, double, double*)* nocapture %2, double (i32, i32, 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 i64 [ 0, %4 ], [ %43, %41 ]
%13 = phi double [ 0.000000e+00, %4 ], [ %42, %41 ]
%14 = getelementptr [4 x double], [4 x double]* %1, i64 %12, i64 0
%15 = bitcast double* %14 to i8*
%16 = call i32 @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 i32 [ 0, %11 ], [ 1, %19 ], [ 2, %24 ], [ 3, %29 ], [ 4, %34 ]
%38 = call double %3(i32 %37, i32 %16, double %0, double* %7)
%39 = call double %2(i32 %37, double %0, double* %7)
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double %13)
br label %41
41: ; preds = %36, %34
%42 = phi double [ %13, %34 ], [ %40, %36 ]
%43 = add nuw nsw i64 %12, 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
}