#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 cos(double);
double phi_gradient(double, double, double, double, double, double);
double sin(double);
void line_integral(double *weights, double in_phi1, double in_phi2,
                   double theta1, double theta2, double grid1_lon,
                   double grid2_lon) {
  double dphi, sinth1, sinth2, costh1, costh2;
  double f1, f2;
  sinth1 = sin(theta1);
  sinth2 = sin(theta2);
  costh1 = cos(theta1);
  costh2 = cos(theta2);
  dphi = in_phi1 - in_phi2;
  if (dphi > 3.14159265358979323846)
    dphi -= (2.0 * 3.14159265358979323846);
  else if (dphi < -3.14159265358979323846)
    dphi += (2.0 * 3.14159265358979323846);
  dphi = 0.5 * dphi;
  weights[0] = dphi * (sinth1 + sinth2);
  weights[1] = dphi * (costh1 + costh2 + (theta1 * sinth1 + theta2 * sinth2));
  weights[3] = weights[0];
  weights[4] = weights[1];
  f1 = 0.5 * (costh1 * sinth1 + theta1);
  f2 = 0.5 * (costh2 * sinth2 + theta2);
  weights[2] = phi_gradient(in_phi1, in_phi2, dphi, f1, f2, grid1_lon);
  weights[5] = phi_gradient(in_phi1, in_phi2, dphi, f1, f2, grid2_lon);
}


x86 assembly (clang, -O0):
<line_integral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d7 <line_integral+0xa7>
movsd  -0x40(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1201 <line_integral+0xd1>
movsd  0xe29(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11fc <line_integral+0xcc>
movsd  0xe1e(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1201 <line_integral+0xd1>
movsd  0xe0f(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  -0x50(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
addsd  -0x60(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm3
mulsd  -0x50(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x58(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd6c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd44(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
movsd  -0x70(%rbp),%xmm4
movsd  -0x30(%rbp),%xmm5
call   1050 <phi_gradient@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
movsd  -0x70(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
call   1050 <phi_gradient@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_integral>:
push   %rbx
sub    $0x70,%rsp
movsd  %xmm5,0x38(%rsp)
movsd  %xmm4,0x30(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%rbx
movaps %xmm2,%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x60(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm9
movsd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm8
subsd  %xmm1,%xmm2
ucomisd 0xe49(%rip),%xmm2
jbe    11c3 <line_integral+0x93>
addsd  0xe57(%rip),%xmm2
jmp    11d9 <line_integral+0xa9>
movsd  0xe3d(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    11d9 <line_integral+0xa9>
addsd  0xe37(%rip),%xmm2
movsd  0xe3e(%rip),%xmm10
mulsd  %xmm10,%xmm2
movsd  0x10(%rsp),%xmm4
movapd %xmm4,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm0,%xmm11
movapd %xmm2,%xmm6
movapd 0x50(%rsp),%xmm5
movapd %xmm5,%xmm2
movsd  0x8(%rsp),%xmm12
mulsd  %xmm12,%xmm2
movsd  0x28(%rsp),%xmm7
movapd %xmm7,%xmm3
movapd 0x60(%rsp),%xmm0
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm0,%xmm2
unpcklpd %xmm3,%xmm2
movapd %xmm5,%xmm3
unpcklpd %xmm1,%xmm3
addpd  %xmm2,%xmm3
movapd %xmm6,%xmm1
movapd %xmm6,%xmm2
movapd %xmm6,0x40(%rsp)
unpcklpd %xmm6,%xmm1
mulpd  %xmm3,%xmm1
movupd %xmm1,(%rbx)
movupd %xmm1,0x18(%rbx)
mulsd  %xmm0,%xmm4
addsd  %xmm7,%xmm4
mulsd  %xmm10,%xmm4
movapd %xmm4,%xmm3
movsd  %xmm4,0x10(%rsp)
movapd %xmm11,%xmm4
mulsd  %xmm5,%xmm4
addsd  %xmm12,%xmm4
mulsd  %xmm10,%xmm4
movsd  %xmm4,0x8(%rsp)
movapd %xmm9,%xmm0
movapd %xmm8,%xmm1
movsd  0x30(%rsp),%xmm5
call   1050 <phi_gradient@plt>
movsd  %xmm0,0x10(%rbx)
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movaps 0x40(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movsd  0x38(%rsp),%xmm5
call   1050 <phi_gradient@plt>
movsd  %xmm0,0x28(%rbx)
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @line_integral(double* %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double* %0, double** %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%22 = load double, double* %11
%23 = call double @sin(double %22)
store double %23, double* %16
%24 = load double, double* %12
%25 = call double @sin(double %24)
store double %25, double* %17
%26 = load double, double* %11
%27 = call double @cos(double %26)
store double %27, double* %18
%28 = load double, double* %12
%29 = call double @cos(double %28)
store double %29, double* %19
%30 = load double, double* %9
%31 = load double, double* %10
%32 = fsub double %30, %31
store double %32, double* %15
%33 = load double, double* %15
%34 = fcmp ogt double %33, 0x400921FB54442D18
br i1 %34, label %35, label %38
35: ; preds = %7
%36 = load double, double* %15
%37 = fsub double %36, 0x401921FB54442D18
store double %37, double* %15
br label %45
38: ; preds = %7
%39 = load double, double* %15
%40 = fcmp olt double %39, 0xC00921FB54442D18
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load double, double* %15
%43 = fadd double %42, 0x401921FB54442D18
store double %43, double* %15
br label %44
44: ; preds = %41, %38
br label %45
45: ; preds = %44, %35
%46 = load double, double* %15
%47 = fmul double 5.000000e-01, %46
store double %47, double* %15
%48 = load double, double* %15
%49 = load double, double* %16
%50 = load double, double* %17
%51 = fadd double %49, %50
%52 = fmul double %48, %51
%53 = load double*, double** %8
%54 = getelementptr inbounds double, double* %53, i64 0
store double %52, double* %54
%55 = load double, double* %15
%56 = load double, double* %18
%57 = load double, double* %19
%58 = fadd double %56, %57
%59 = load double, double* %11
%60 = load double, double* %16
%61 = load double, double* %12
%62 = load double, double* %17
%63 = fmul double %61, %62
%64 = call double @llvm.fmuladd.f64(double %59, double %60, double %63)
%65 = fadd double %58, %64
%66 = fmul double %55, %65
%67 = load double*, double** %8
%68 = getelementptr inbounds double, double* %67, i64 1
store double %66, double* %68
%69 = load double*, double** %8
%70 = getelementptr inbounds double, double* %69, i64 0
%71 = load double, double* %70
%72 = load double*, double** %8
%73 = getelementptr inbounds double, double* %72, i64 3
store double %71, double* %73
%74 = load double*, double** %8
%75 = getelementptr inbounds double, double* %74, i64 1
%76 = load double, double* %75
%77 = load double*, double** %8
%78 = getelementptr inbounds double, double* %77, i64 4
store double %76, double* %78
%79 = load double, double* %18
%80 = load double, double* %16
%81 = load double, double* %11
%82 = call double @llvm.fmuladd.f64(double %79, double %80, double %81)
%83 = fmul double 5.000000e-01, %82
store double %83, double* %20
%84 = load double, double* %19
%85 = load double, double* %17
%86 = load double, double* %12
%87 = call double @llvm.fmuladd.f64(double %84, double %85, double %86)
%88 = fmul double 5.000000e-01, %87
store double %88, double* %21
%89 = load double, double* %9
%90 = load double, double* %10
%91 = load double, double* %15
%92 = load double, double* %20
%93 = load double, double* %21
%94 = load double, double* %13
%95 = call double @phi_gradient(double %89, double %90, double %91, double %92, double %93, double %94)
%96 = load double*, double** %8
%97 = getelementptr inbounds double, double* %96, i64 2
store double %95, double* %97
%98 = load double, double* %9
%99 = load double, double* %10
%100 = load double, double* %15
%101 = load double, double* %20
%102 = load double, double* %21
%103 = load double, double* %14
%104 = call double @phi_gradient(double %98, double %99, double %100, double %101, double %102, double %103)
%105 = load double*, double** %8
%106 = getelementptr inbounds double, double* %105, i64 5
store double %104, double* %106
ret void
}

LLVM IR (-O2):
define void @line_integral(double* nocapture %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call double @sin(double %3)
%9 = tail call double @sin(double %4)
%10 = tail call double @cos(double %3)
%11 = tail call double @cos(double %4)
%12 = fsub double %1, %2
%13 = fcmp ogt double %12, 0x400921FB54442D18
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = fadd double %12, 0xC01921FB54442D18
br label %20
16: ; preds = %7
%17 = fcmp olt double %12, 0xC00921FB54442D18
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = fadd double %12, 0x401921FB54442D18
br label %20
20: ; preds = %16, %18, %14
%21 = phi double [ %15, %14 ], [ %19, %18 ], [ %12, %16 ]
%22 = fmul double %21, 5.000000e-01
%23 = fadd double %10, %11
%24 = fmul double %9, %4
%25 = tail call double @llvm.fmuladd.f64(double %3, double %8, double %24)
%26 = insertelement <2 x double> poison, double %8, i64 0
%27 = insertelement <2 x double> %26, double %25, i64 1
%28 = insertelement <2 x double> poison, double %9, i64 0
%29 = insertelement <2 x double> %28, double %23, i64 1
%30 = fadd <2 x double> %27, %29
%31 = insertelement <2 x double> poison, double %22, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = fmul <2 x double> %30, %32
%34 = bitcast double* %0 to <2 x double>*
store <2 x double> %33, <2 x double>* %34
%35 = getelementptr inbounds double, double* %0, i64 3
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> %33, <2 x double>* %36
%37 = tail call double @llvm.fmuladd.f64(double %10, double %8, double %3)
%38 = fmul double %37, 5.000000e-01
%39 = tail call double @llvm.fmuladd.f64(double %11, double %9, double %4)
%40 = fmul double %39, 5.000000e-01
%41 = tail call double @phi_gradient(double %1, double %2, double %22, double %38, double %40, double %5)
%42 = getelementptr inbounds double, double* %0, i64 2
store double %41, double* %42
%43 = tail call double @phi_gradient(double %1, double %2, double %22, double %38, double %40, double %6)
%44 = getelementptr inbounds double, double* %0, i64 5
store double %43, double* %44
ret void
}