#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 C_sumof3uniforms_cdf(double *, double const *, double const *,
                            double const *, int *);
void C_rss3Dloop(const double *x, const double *y, const double *z,
                 const double *ax, const double *ay, const double *az,
                 const int *n, const int *n_theta, const int *n_phi,
                 const int *i_phi, double *ans) {
  double p;
  int k;
  for (int i_theta = 0; i_theta < *n_theta; i_theta++) {
    for (int i = 0; i < *n; i++) {
      k = i_theta + *n_theta * *i_phi;
      p = x[i] * ax[k] + y[i] * ay[k] + z[i] * az[k];
      ans[i + *n * i_theta] = C_sumof3uniforms_cdf(&p, ax, ay, az, &k);
    }
  }
}


x86 assembly (clang, -O0):
<C_rss3Dloop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    123d <C_rss3Dloop+0x12d>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    122a <C_rss3Dloop+0x11a>
mov    -0x40(%rbp),%eax
mov    0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    0x28(%rbp),%rdx
imul   (%rdx),%ecx
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%rdi
lea    -0x3c(%rbp),%r8
call   1030 <C_sumof3uniforms_cdf@plt>
mov    0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    0x10(%rbp),%rdx
mov    (%rdx),%edx
imul   -0x40(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1161 <C_rss3Dloop+0x51>
jmp    122f <C_rss3Dloop+0x11f>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    114b <C_rss3Dloop+0x3b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_rss3Dloop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x78(%rsp),%r11
mov    (%r11),%eax
test   %eax,%eax
jle    1251 <C_rss3Dloop+0x141>
mov    %r8,%r12
mov    %rcx,%r10
mov    0x88(%rsp),%rbx
mov    0x70(%rsp),%r14
mov    (%r14),%ecx
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r8
mov    %rdi,0x28(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdx,0x18(%rsp)
jmp    117b <C_rss3Dloop+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %eax,%ebp
jge    1251 <C_rss3Dloop+0x141>
test   %ecx,%ecx
jle    1170 <C_rss3Dloop+0x60>
xor    %r13d,%r13d
mov    %rbp,0x30(%rsp)
nopw   0x0(%rax,%rax,1)
imul   (%rbx),%eax
add    %ebp,%eax
mov    %eax,0xc(%rsp)
movsd  (%rdi,%r13,8),%xmm0
cltq
movsd  (%rsi,%r13,8),%xmm1
mulsd  (%r12,%rax,8),%xmm1
mulsd  (%r10,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  (%rdx,%r13,8),%xmm1
mulsd  (%r9,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r10,%rsi
mov    %r12,%rdx
mov    %r9,%rcx
mov    %r12,%rbx
mov    %r9,%r15
mov    %r10,%r12
mov    %r14,%rbp
mov    %r11,%r14
call   1030 <C_sumof3uniforms_cdf@plt>
mov    %r14,%r11
mov    %rbp,%r14
mov    0x28(%rsp),%rdi
mov    %r12,%r10
lea    0xc(%rsp),%r8
mov    %rbx,%r12
mov    0x90(%rsp),%rbx
mov    %r15,%r9
lea    0x10(%rsp),%r15
mov    0x30(%rsp),%rbp
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%rdx
movslq (%r14),%rcx
mov    %ebp,%eax
imul   %ecx,%eax
cltq
add    %r13,%rax
movsd  %xmm0,(%rbx,%rax,8)
mov    0x88(%rsp),%rbx
add    $0x1,%r13
mov    (%r11),%eax
cmp    %rcx,%r13
jl     1190 <C_rss3Dloop+0x80>
jmp    1170 <C_rss3Dloop+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @C_rss3Dloop(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* %3, double* %4, double* %5, i32* nocapture %6, i32* nocapture %7, i32* nocapture readnone %8, i32* nocapture %9, double* nocapture writeonly %10) {
%12 = alloca double
%13 = alloca i32
%14 = bitcast double* %12 to i8*
%15 = bitcast i32* %13 to i8*
%16 = load i32, i32* %7
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i32, i32* %6
br label %20
20: ; preds = %18, %26
%21 = phi i32 [ %27, %26 ], [ %16, %18 ]
%22 = phi i32 [ %28, %26 ], [ %19, %18 ]
%23 = phi i32 [ %29, %26 ], [ 0, %18 ]
%24 = icmp sgt i32 %22, 0
br i1 %24, label %31, label %26
25: ; preds = %26, %11
ret void
26: ; preds = %31, %20
%27 = phi i32 [ %21, %20 ], [ %63, %31 ]
%28 = phi i32 [ %22, %20 ], [ %54, %31 ]
%29 = add nuw nsw i32 %23, 1
%30 = icmp slt i32 %29, %27
br i1 %30, label %20, label %25
31: ; preds = %20, %31
%32 = phi i32 [ %63, %31 ], [ %21, %20 ]
%33 = phi i64 [ %60, %31 ], [ 0, %20 ]
%34 = load i32, i32* %9
%35 = mul nsw i32 %34, %32
%36 = add nsw i32 %35, %23
store i32 %36, i32* %13
%37 = getelementptr inbounds double, double* %0, i64 %33
%38 = load double, double* %37
%39 = sext i32 %36 to i64
%40 = getelementptr inbounds double, double* %3, i64 %39
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %1, i64 %33
%43 = load double, double* %42
%44 = getelementptr inbounds double, double* %4, i64 %39
%45 = load double, double* %44
%46 = fmul double %43, %45
%47 = call double @llvm.fmuladd.f64(double %38, double %41, double %46)
%48 = getelementptr inbounds double, double* %2, i64 %33
%49 = load double, double* %48
%50 = getelementptr inbounds double, double* %5, i64 %39
%51 = load double, double* %50
%52 = call double @llvm.fmuladd.f64(double %49, double %51, double %47)
store double %52, double* %12
%53 = call double @C_sumof3uniforms_cdf(double* %12, double* %3, double* %4, double* %5, i32* %13)
%54 = load i32, i32* %6
%55 = mul nsw i32 %54, %23
%56 = trunc i64 %33 to i32
%57 = add nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %10, i64 %58
store double %53, double* %59
%60 = add nuw nsw i64 %33, 1
%61 = sext i32 %54 to i64
%62 = icmp slt i64 %60, %61
%63 = load i32, i32* %7
br i1 %62, label %31, label %26
}