#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(int);
int /*<<< orphan*/ printf(char *, ...);
double sin(int);
int /*<<< orphan*/ sort_by_distance(int, double *, double *, double *,
                                    double *);
int /*<<< orphan*/ spherical_quadrature_points(double *, double *, double *,
                                               double *, int);
int main(void) {
  int i;
  double x2[12], y2[12], z2[12], w2[12];
  double x3[50], y3[50], z3[50], w3[50];
  printf(
      "/* For 1d, 2d, and 3d, quadrature points and weights on a unit sphere.\n"
      "   There are num_sphere_quad[dim-1] points i, with the i-th point at\n"
      "   (x,y,z) = (sphere_quad[dim-1][i][ 0, 1, 2 ]), and with a quadrature\n"
      "   weight sphere_quad[dim-1][i][3]. */\n\n");
  printf("#define NQUAD %d\n",
         ((50) > (((2) > (12) ? (2) : (12))) ? (50)
                                             : (((2) > (12) ? (2) : (12)))));
  printf("static const int num_sphere_quad[3] = { %d, %d, %d };\n\n", 2, 12,
         50);
  printf("static const double sphere_quad[3][NQUAD][4] = {\n");
  printf("    { {1,0,0,0.5}, {-1,0,0,0.5} },\n");
  for (i = 0; i < 12; ++i) {
    if (i == 0) {
      x2[i] = 1;
      y2[i] = 0;
    } else if (2 * i == 12) {
      x2[i] = -1;
      y2[i] = 0;
    } else if (4 * i == 12) {
      y2[i] = 1;
      x2[i] = 0;
    } else if (4 * i == 3 * 12) {
      y2[i] = -1;
      x2[i] = 0;
    } else {
      x2[i] = cos(2 * i * 3.141592653589793238462643383279502884197 / 12);
      y2[i] = sin(2 * i * 3.141592653589793238462643383279502884197 / 12);
    }
    z2[i] = 0.0;
    w2[i] = 1.0 / 12;
  }
  sort_by_distance(12, x2, y2, z2, w2);
  printf("    {\n");
  for (i = 0; i < 12; ++i) {
    printf("        { %0.20g, %0.20g, %0.20g, %0.20g },\n", x2[i], y2[i], z2[i],
           w2[i]);
  }
  printf("    },\n");
  printf("    {\n");
  spherical_quadrature_points(x3, y3, z3, w3, 50);
  sort_by_distance(50, x3, y3, z3, w3);
  for (i = 0; i < 50; ++i) {
    printf("        { %0.20g, %0.20g, %0.20g, %0.20g },\n", x3[i], y3[i], z3[i],
           w3[i]);
  }
  printf("    }\n");
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfad(%rip),%rdi
mov    $0x32,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfac(%rip),%rdi
mov    $0x2,%esi
mov    $0xc,%edx
mov    $0x32,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    134f <main+0x1ff>
cmpl   $0x0,-0x8(%rbp)
jne    11fe <main+0xae>
movslq -0x8(%rbp),%rax
movsd  0xe35(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
jmp    131c <main+0x1cc>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
cmp    $0xc,%eax
jne    1234 <main+0xe4>
movslq -0x8(%rbp),%rax
movsd  0xdf7(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
jmp    1317 <main+0x1c7>
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
cmp    $0xc,%eax
jne    126a <main+0x11a>
movslq -0x8(%rbp),%rax
movsd  0xdc9(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
jmp    1312 <main+0x1c2>
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
cmp    $0x24,%eax
jne    12a0 <main+0x150>
movslq -0x8(%rbp),%rax
movsd  0xd8b(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
jmp    130d <main+0x1bd>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd56(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd42(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <cos@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x70(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd21(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd0d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
jmp    1312 <main+0x1c2>
jmp    1317 <main+0x1c7>
jmp    131c <main+0x1cc>
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x130(%rbp,%rax,8)
ff ff
movslq -0x8(%rbp),%rax
movsd  0xce8(%rip),%xmm0
movsd  %xmm0,-0x190(%rbp,%rax,8)
ff ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <main+0x73>
lea    -0x70(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x190(%rbp),%r8
mov    $0xc,%edi
call   1060 <sort_by_distance@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    13de <main+0x28e>
movslq -0x8(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm0
movslq -0x8(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm1
ff ff
movslq -0x8(%rbp),%rax
movsd  -0x130(%rbp,%rax,8),%xmm2
ff ff
movslq -0x8(%rbp),%rax
movsd  -0x190(%rbp,%rax,8),%xmm3
ff ff
lea    0xe02(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1387 <main+0x237>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x320(%rbp),%rdi
lea    -0x4b0(%rbp),%rsi
lea    -0x640(%rbp),%rdx
lea    -0x7d0(%rbp),%rcx
mov    $0x32,%r8d
call   1050 <spherical_quadrature_points@plt>
lea    -0x320(%rbp),%rsi
lea    -0x4b0(%rbp),%rdx
lea    -0x640(%rbp),%rcx
lea    -0x7d0(%rbp),%r8
mov    $0x32,%edi
call   1060 <sort_by_distance@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    14a8 <main+0x358>
movslq -0x8(%rbp),%rax
movsd  -0x320(%rbp,%rax,8),%xmm0
ff ff
movslq -0x8(%rbp),%rax
movsd  -0x4b0(%rbp,%rax,8),%xmm1
ff ff
movslq -0x8(%rbp),%rax
movsd  -0x640(%rbp,%rax,8),%xmm2
ff ff
movslq -0x8(%rbp),%rax
movsd  -0x7d0(%rbp,%rax,8),%xmm3
ff ff
lea    0xd38(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    144e <main+0x2fe>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7c8,%rsp
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
mov    $0x32,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x2,%esi
mov    $0xc,%edx
mov    $0x32,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xff4(%rip),%rdi
call   1030 <puts@plt>
lea    0x1019(%rip),%rdi
call   1030 <puts@plt>
movabs $0x3fb5555555555555,%r15
55 b5 3f
lea    0xe38(%rip),%rdi
movabs $0x3ff0000000000000,%r13
movabs $0xbff0000000000000,%r14
xor    %r12d,%r12d
jmp    1261 <main+0x101>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  0xdf0(%rip),%xmm0
divsd  0xdf0(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1080 <cos@plt>
movsd  %xmm0,0x60(%rsp,%r12,4)
mov    %ebp,%edi
call   1050 <sin@plt>
lea    0xdd8(%rip),%rdi
movsd  %xmm0,(%rsp,%r12,4)
xchg   %ax,%ax
movq   $0x0,0x120(%rsp,%r12,4)
mov    %r15,0xc0(%rsp,%r12,4)
add    $0x2,%r12
add    $0x1,%ebx
cmp    $0x18,%r12
je     12af <main+0x14f>
cmp    $0x9,%ebx
ja     1200 <main+0xa0>
mov    %ebx,%eax
movslq (%rdi,%rax,4),%rax
add    %rdi,%rax
jmp    *%rax
mov    %r13,0x60(%rsp)
movq   $0x0,(%rsp)
jmp    1240 <main+0xe0>
mov    %r13,(%rsp,%r12,4)
movq   $0x0,0x60(%rsp,%r12,4)
jmp    1240 <main+0xe0>
nop
mov    %r14,0x60(%rsp,%r12,4)
movq   $0x0,(%rsp,%r12,4)
jmp    1240 <main+0xe0>
nop
mov    %r14,(%rsp,%r12,4)
movq   $0x0,0x60(%rsp,%r12,4)
jmp    1240 <main+0xe0>
lea    0x60(%rsp),%rsi
mov    %rsp,%rdx
lea    0x120(%rsp),%rcx
lea    0xc0(%rsp),%r8
mov    $0xc,%edi
call   1070 <sort_by_distance@plt>
lea    0xf2d(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
movsd  0x60(%rsp),%xmm0
movsd  (%rsp),%xmm1
movsd  0x120(%rsp),%xmm2
movsd  0xc0(%rsp),%xmm3
lea    0xd7e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x68(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x128(%rsp),%xmm2
movsd  0xc8(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x70(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x130(%rsp),%xmm2
movsd  0xd0(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x78(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x138(%rsp),%xmm2
movsd  0xd8(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x80(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x140(%rsp),%xmm2
movsd  0xe0(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x88(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x148(%rsp),%xmm2
movsd  0xe8(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x90(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x150(%rsp),%xmm2
movsd  0xf0(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x98(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x158(%rsp),%xmm2
movsd  0xf8(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xa0(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x160(%rsp),%xmm2
movsd  0x100(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xa8(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
movsd  0x168(%rsp),%xmm2
movsd  0x108(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xb0(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
movsd  0x170(%rsp),%xmm2
movsd  0x110(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xb8(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  0x178(%rsp),%xmm2
movsd  0x118(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
lea    0xd19(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0x630(%rsp),%r14
lea    0x4a0(%rsp),%r15
lea    0x310(%rsp),%r12
lea    0x180(%rsp),%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    $0x32,%r8d
call   1060 <spherical_quadrature_points@plt>
mov    $0x32,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1070 <sort_by_distance@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x630(%rsp,%rbp,8),%xmm0
movsd  0x4a0(%rsp,%rbp,8),%xmm1
movsd  0x310(%rsp,%rbp,8),%xmm2
movsd  0x180(%rsp,%rbp,8),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x32,%rbp
jne    1550 <main+0x3f0>
lea    0xc7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xc76(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x7c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [252 x i8] c"/* For 1d, 2d, and 3d, quadrature points and weights on a unit sphere.\0A There are num_sphere_quad[dim-1] points i, with the i-th point at\0A (x,y,z) = (sphere_quad[dim-1][i][ 0, 1, 2 ]), and with a quadrature\0A weight sphere_quad[dim-1][i][3]. */\0A\0A\00"
@.str.1 = [18 x i8] c"#define NQUAD %d\0A\00"
@.str.2 = [56 x i8] c"static const int num_sphere_quad[3] = { %d, %d, %d };\0A\0A\00"
@.str.3 = [50 x i8] c"static const double sphere_quad[3][NQUAD][4] = {\0A\00"
@.str.4 = [36 x i8] c" { {1,0,0,0.5}, {-1,0,0,0.5} },\0A\00"
@.str.5 = [7 x i8] c" {\0A\00"
@.str.6 = [45 x i8] c" { %0.20g, %0.20g, %0.20g, %0.20g },\0A\00"
@.str.7 = [8 x i8] c" },\0A\00"
@.str.8 = [7 x i8] c" }\0A\00"
@.str.9 = [4 x i8] c"};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [12 x double]
%4 = alloca [12 x double]
%5 = alloca [12 x double]
%6 = alloca [12 x double]
%7 = alloca [50 x double]
%8 = alloca [50 x double]
%9 = alloca [50 x double]
%10 = alloca [50 x double]
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([252 x i8], [252 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 50)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 12, i32 50)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %16
16: ; preds = %93, %0
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 12
br i1 %18, label %19, label %96
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %24
store double 1.000000e+00, double* %25
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %27
store double 0.000000e+00, double* %28
br label %86
29: ; preds = %19
%30 = load i32, i32* %2
%31 = mul nsw i32 2, %30
%32 = icmp eq i32 %31, 12
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %35
store double -1.000000e+00, double* %36
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %38
store double 0.000000e+00, double* %39
br label %85
40: ; preds = %29
%41 = load i32, i32* %2
%42 = mul nsw i32 4, %41
%43 = icmp eq i32 %42, 12
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i32, i32* %2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %46
store double 1.000000e+00, double* %47
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %49
store double 0.000000e+00, double* %50
br label %84
51: ; preds = %40
%52 = load i32, i32* %2
%53 = mul nsw i32 4, %52
%54 = icmp eq i32 %53, 36
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %57
store double -1.000000e+00, double* %58
%59 = load i32, i32* %2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %60
store double 0.000000e+00, double* %61
br label %83
62: ; preds = %51
%63 = load i32, i32* %2
%64 = mul nsw i32 2, %63
%65 = sitofp i32 %64 to double
%66 = fmul double %65, 0x400921FB54442D18
%67 = fdiv double %66, 1.200000e+01
%68 = fptosi double %67 to i32
%69 = call double @cos(i32 %68)
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %71
store double %69, double* %72
%73 = load i32, i32* %2
%74 = mul nsw i32 2, %73
%75 = sitofp i32 %74 to double
%76 = fmul double %75, 0x400921FB54442D18
%77 = fdiv double %76, 1.200000e+01
%78 = fptosi double %77 to i32
%79 = call double @sin(i32 %78)
%80 = load i32, i32* %2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %81
store double %79, double* %82
br label %83
83: ; preds = %62, %55
br label %84
84: ; preds = %83, %44
br label %85
85: ; preds = %84, %33
br label %86
86: ; preds = %85, %22
%87 = load i32, i32* %2
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 %88
store double 0.000000e+00, double* %89
%90 = load i32, i32* %2
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [12 x double], [12 x double]* %6, i64 0, i64 %91
store double 0x3FB5555555555555, double* %92
br label %93
93: ; preds = %86
%94 = load i32, i32* %2
%95 = add nsw i32 %94, 1
store i32 %95, i32* %2
br label %16
96: ; preds = %16
%97 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 0
%98 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 0
%99 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 0
%100 = getelementptr inbounds [12 x double], [12 x double]* %6, i64 0, i64 0
%101 = call i32 @sort_by_distance(i32 12, double* %97, double* %98, double* %99, double* %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %103
103: ; preds = %124, %96
%104 = load i32, i32* %2
%105 = icmp slt i32 %104, 12
br i1 %105, label %106, label %127
106: ; preds = %103
%107 = load i32, i32* %2
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %108
%110 = load double, double* %109
%111 = load i32, i32* %2
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %112
%114 = load double, double* %113
%115 = load i32, i32* %2
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 %116
%118 = load double, double* %117
%119 = load i32, i32* %2
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [12 x double], [12 x double]* %6, i64 0, i64 %120
%122 = load double, double* %121
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %110, double %114, double %118, double %122)
br label %124
124: ; preds = %106
%125 = load i32, i32* %2
%126 = add nsw i32 %125, 1
store i32 %126, i32* %2
br label %103
127: ; preds = %103
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%130 = getelementptr inbounds [50 x double], [50 x double]* %7, i64 0, i64 0
%131 = getelementptr inbounds [50 x double], [50 x double]* %8, i64 0, i64 0
%132 = getelementptr inbounds [50 x double], [50 x double]* %9, i64 0, i64 0
%133 = getelementptr inbounds [50 x double], [50 x double]* %10, i64 0, i64 0
%134 = call i32 @spherical_quadrature_points(double* %130, double* %131, double* %132, double* %133, i32 50)
%135 = getelementptr inbounds [50 x double], [50 x double]* %7, i64 0, i64 0
%136 = getelementptr inbounds [50 x double], [50 x double]* %8, i64 0, i64 0
%137 = getelementptr inbounds [50 x double], [50 x double]* %9, i64 0, i64 0
%138 = getelementptr inbounds [50 x double], [50 x double]* %10, i64 0, i64 0
%139 = call i32 @sort_by_distance(i32 50, double* %135, double* %136, double* %137, double* %138)
store i32 0, i32* %2
br label %140
140: ; preds = %161, %127
%141 = load i32, i32* %2
%142 = icmp slt i32 %141, 50
br i1 %142, label %143, label %164
143: ; preds = %140
%144 = load i32, i32* %2
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [50 x double], [50 x double]* %7, i64 0, i64 %145
%147 = load double, double* %146
%148 = load i32, i32* %2
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [50 x double], [50 x double]* %8, i64 0, i64 %149
%151 = load double, double* %150
%152 = load i32, i32* %2
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [50 x double], [50 x double]* %9, i64 0, i64 %153
%155 = load double, double* %154
%156 = load i32, i32* %2
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [50 x double], [50 x double]* %10, i64 0, i64 %157
%159 = load double, double* %158
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %147, double %151, double %155, double %159)
br label %161
161: ; preds = %143
%162 = load i32, i32* %2
%163 = add nsw i32 %162, 1
store i32 %163, i32* %2
br label %140
164: ; preds = %140
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"#define NQUAD %d\0A\00"
@.str.2 = [56 x i8] c"static const int num_sphere_quad[3] = { %d, %d, %d };\0A\0A\00"
@.str.6 = [45 x i8] c" { %0.20g, %0.20g, %0.20g, %0.20g },\0A\00"
@str = [251 x i8] c"/* For 1d, 2d, and 3d, quadrature points and weights on a unit sphere.\0A There are num_sphere_quad[dim-1] points i, with the i-th point at\0A (x,y,z) = (sphere_quad[dim-1][i][ 0, 1, 2 ]), and with a quadrature\0A weight sphere_quad[dim-1][i][3]. */\0A\00"
@str.10 = [49 x i8] c"static const double sphere_quad[3][NQUAD][4] = {\00"
@str.11 = [35 x i8] c" { {1,0,0,0.5}, {-1,0,0,0.5} },\00"
@str.13 = [7 x i8] c" },\00"
@str.14 = [6 x i8] c" {\00"
@str.15 = [6 x i8] c" }\00"
@str.16 = [3 x i8] c"};\00"
define i32 @main() {
%1 = alloca [12 x double]
%2 = alloca [12 x double]
%3 = alloca [12 x double]
%4 = alloca [12 x double]
%5 = alloca [50 x double]
%6 = alloca [50 x double]
%7 = alloca [50 x double]
%8 = alloca [50 x double]
%9 = bitcast [12 x double]* %1 to i8*
%10 = bitcast [12 x double]* %2 to i8*
%11 = bitcast [12 x double]* %3 to i8*
%12 = bitcast [12 x double]* %4 to i8*
%13 = bitcast [50 x double]* %5 to i8*
%14 = bitcast [50 x double]* %6 to i8*
%15 = bitcast [50 x double]* %7 to i8*
%16 = bitcast [50 x double]* %8 to i8*
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([251 x i8], [251 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 50)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 12, i32 50)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.10, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.11, i64 0, i64 0))
%22 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 0
%23 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 0
br label %24
24: ; preds = %0, %48
%25 = phi i64 [ 0, %0 ], [ %51, %48 ]
%26 = trunc i64 %25 to i32
switch i32 %26, label %37 [
i32 0, label %27
i32 6, label %28
i32 3, label %31
i32 9, label %34
]
27: ; preds = %24
store double 1.000000e+00, double* %22
store double 0.000000e+00, double* %23
br label %48
28: ; preds = %24
%29 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 %25
store double -1.000000e+00, double* %29
%30 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 %25
store double 0.000000e+00, double* %30
br label %48
31: ; preds = %24
%32 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 %25
store double 1.000000e+00, double* %32
%33 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 %25
store double 0.000000e+00, double* %33
br label %48
34: ; preds = %24
%35 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 %25
store double -1.000000e+00, double* %35
%36 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 %25
store double 0.000000e+00, double* %36
br label %48
37: ; preds = %24
%38 = trunc i64 %25 to i32
%39 = shl i32 %38, 1
%40 = sitofp i32 %39 to double
%41 = fmul double %40, 0x400921FB54442D18
%42 = fdiv double %41, 1.200000e+01
%43 = fptosi double %42 to i32
%44 = tail call double @cos(i32 %43)
%45 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 %25
store double %44, double* %45
%46 = tail call double @sin(i32 %43)
%47 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 %25
store double %46, double* %47
br label %48
48: ; preds = %28, %34, %37, %31, %27
%49 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %25
store double 0.000000e+00, double* %49
%50 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 %25
store double 0x3FB5555555555555, double* %50
%51 = add nuw nsw i64 %25, 1
%52 = icmp eq i64 %51, 12
br i1 %52, label %53, label %24
53: ; preds = %48
%54 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 0
%55 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 0
%56 = call i32 @sort_by_distance(i32 12, double* %22, double* %23, double* %54, double* %55)
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.14, i64 0, i64 0))
%58 = load double, double* %22
%59 = load double, double* %23
%60 = load double, double* %54
%61 = load double, double* %55
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %58, double %59, double %60, double %61)
%63 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 1
%64 = load double, double* %63
%65 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 1
%66 = load double, double* %65
%67 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 1
%68 = load double, double* %67
%69 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 1
%70 = load double, double* %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %64, double %66, double %68, double %70)
%72 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 2
%73 = load double, double* %72
%74 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 2
%75 = load double, double* %74
%76 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 2
%77 = load double, double* %76
%78 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 2
%79 = load double, double* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %73, double %75, double %77, double %79)
%81 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 3
%82 = load double, double* %81
%83 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 3
%84 = load double, double* %83
%85 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 3
%86 = load double, double* %85
%87 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 3
%88 = load double, double* %87
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %82, double %84, double %86, double %88)
%90 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 4
%91 = load double, double* %90
%92 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 4
%93 = load double, double* %92
%94 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 4
%95 = load double, double* %94
%96 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 4
%97 = load double, double* %96
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %91, double %93, double %95, double %97)
%99 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 5
%100 = load double, double* %99
%101 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 5
%102 = load double, double* %101
%103 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 5
%104 = load double, double* %103
%105 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 5
%106 = load double, double* %105
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %100, double %102, double %104, double %106)
%108 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 6
%109 = load double, double* %108
%110 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 6
%111 = load double, double* %110
%112 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 6
%113 = load double, double* %112
%114 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 6
%115 = load double, double* %114
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %109, double %111, double %113, double %115)
%117 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 7
%118 = load double, double* %117
%119 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 7
%120 = load double, double* %119
%121 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 7
%122 = load double, double* %121
%123 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 7
%124 = load double, double* %123
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %118, double %120, double %122, double %124)
%126 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 8
%127 = load double, double* %126
%128 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 8
%129 = load double, double* %128
%130 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 8
%131 = load double, double* %130
%132 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 8
%133 = load double, double* %132
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %127, double %129, double %131, double %133)
%135 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 9
%136 = load double, double* %135
%137 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 9
%138 = load double, double* %137
%139 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 9
%140 = load double, double* %139
%141 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 9
%142 = load double, double* %141
%143 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %136, double %138, double %140, double %142)
%144 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 10
%145 = load double, double* %144
%146 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 10
%147 = load double, double* %146
%148 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 10
%149 = load double, double* %148
%150 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 10
%151 = load double, double* %150
%152 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %145, double %147, double %149, double %151)
%153 = getelementptr inbounds [12 x double], [12 x double]* %1, i64 0, i64 11
%154 = load double, double* %153
%155 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 11
%156 = load double, double* %155
%157 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 11
%158 = load double, double* %157
%159 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 11
%160 = load double, double* %159
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %154, double %156, double %158, double %160)
%162 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.13, i64 0, i64 0))
%163 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.14, i64 0, i64 0))
%164 = getelementptr inbounds [50 x double], [50 x double]* %5, i64 0, i64 0
%165 = getelementptr inbounds [50 x double], [50 x double]* %6, i64 0, i64 0
%166 = getelementptr inbounds [50 x double], [50 x double]* %7, i64 0, i64 0
%167 = getelementptr inbounds [50 x double], [50 x double]* %8, i64 0, i64 0
%168 = call i32 @spherical_quadrature_points(double* %164, double* %165, double* %166, double* %167, i32 50)
%169 = call i32 @sort_by_distance(i32 50, double* %164, double* %165, double* %166, double* %167)
br label %170
170: ; preds = %53, %170
%171 = phi i64 [ 0, %53 ], [ %181, %170 ]
%172 = getelementptr inbounds [50 x double], [50 x double]* %5, i64 0, i64 %171
%173 = load double, double* %172
%174 = getelementptr inbounds [50 x double], [50 x double]* %6, i64 0, i64 %171
%175 = load double, double* %174
%176 = getelementptr inbounds [50 x double], [50 x double]* %7, i64 0, i64 %171
%177 = load double, double* %176
%178 = getelementptr inbounds [50 x double], [50 x double]* %8, i64 0, i64 %171
%179 = load double, double* %178
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %173, double %175, double %177, double %179)
%181 = add nuw nsw i64 %171, 1
%182 = icmp eq i64 %181, 50
br i1 %182, label %183, label %170
183: ; preds = %170
%184 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0))
%185 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0))
ret i32 0
}