#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 sin(double);
int getSphereNorms(int n, double *xn, double *yn, double *zn) {
  int i, j, npts;
  double theta1, theta2, theta3, dn;
  npts = 0;
  dn = n;
  for (j = 0; j < n / 2; j++) {
    theta1 = j * 6.2831853071795862 / dn - 1.57079632679489661923;
    theta2 = (j + 1) * 6.2831853071795862 / dn - 1.57079632679489661923;
    for (i = 0; i <= n; i++) {
      theta3 = i * 6.2831853071795862 / dn;
      xn[npts] = cos(theta2) * cos(theta3);
      yn[npts] = sin(theta2);
      zn[npts] = cos(theta2) * sin(theta3);
      npts++;
      xn[npts] = cos(theta1) * cos(theta3);
      yn[npts] = sin(theta1);
      zn[npts] = cos(theta1) * sin(theta3);
      npts++;
    }
  }
  return npts;
}


x86 assembly (clang, -O0):
<getSphereNorms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    131a <getSphereNorms+0x1fa>
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5f(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1307 <getSphereNorms+0x1e7>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe25(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ca <getSphereNorms+0xaa>
jmp    130c <getSphereNorms+0x1ec>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1152 <getSphereNorms+0x32>
mov    -0x2c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSphereNorms>:
xor    %eax,%eax
cmp    $0x2,%edi
jl     1322 <getSphereNorms+0x202>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edi,%ebp
cvtsi2sd %edi,%xmm0
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
mov    %eax,0x24(%rsp)
add    $0x8,%rsi
add    $0x8,%rdx
add    $0x8,%rcx
add    $0x1,%ebp
xor    %edi,%edi
xorpd  %xmm1,%xmm1
movsd  0xe97(%rip),%xmm2
xor    %eax,%eax
mov    %rcx,0x40(%rsp)
mov    %rdx,0x38(%rsp)
mov    %rsi,0x30(%rsp)
movsd  %xmm0,0x60(%rsp)
movapd %xmm1,%xmm4
mulsd  %xmm2,%xmm4
divsd  %xmm0,%xmm4
movsd  0xe74(%rip),%xmm3
addsd  %xmm3,%xmm4
movsd  %xmm4,0x18(%rsp)
addsd  0xe6a(%rip),%xmm1
movsd  %xmm1,0x50(%rsp)
add    $0x1,%edi
mov    %rdi,0x58(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %rax,0x28(%rsp)
cltq
lea    (%rsi,%rax,8),%r13
lea    (%rdx,%rax,8),%r15
mov    %rax,0x48(%rsp)
lea    (%rcx,%rax,8),%r14
xor    %r12d,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,-0x8(%r13,%r12,8)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x8(%r15,%r12,8)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,-0x8(%r14,%r12,8)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%r12,8)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%r15,%r12,8)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0xd40(%rip),%xmm2
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r14,%r12,8)
movsd  0x60(%rsp),%xmm0
add    $0x1,%ebx
add    $0x2,%r12
cmp    %ebx,%ebp
jne    11f0 <getSphereNorms+0xd0>
mov    0x48(%rsp),%rax
add    %r12,%rax
mov    0x58(%rsp),%rdi
cmp    0x24(%rsp),%edi
mov    0x40(%rsp),%rcx
mov    0x38(%rsp),%rdx
mov    0x30(%rsp),%rsi
movsd  0x50(%rsp),%xmm1
jne    1180 <getSphereNorms+0x60>
mov    0x28(%rsp),%rax
add    %r12d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getSphereNorms(i32 %0, double* nocapture writeonly %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = sitofp i32 %0 to double
%6 = sdiv i32 %0, 2
%7 = icmp sgt i32 %0, 1
br i1 %7, label %10, label %56
8: ; preds = %24
%9 = icmp eq i32 %17, %6
br i1 %9, label %54, label %10
10: ; preds = %4, %8
%11 = phi i32 [ %17, %8 ], [ 0, %4 ]
%12 = phi i64 [ %51, %8 ], [ 0, %4 ]
%13 = sitofp i32 %11 to double
%14 = fmul double %13, 0x401921FB54442D18
%15 = fdiv double %14, %5
%16 = fadd double %15, 0xBFF921FB54442D18
%17 = add nuw nsw i32 %11, 1
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 0x401921FB54442D18
%20 = fdiv double %19, %5
%21 = fadd double %20, 0xBFF921FB54442D18
%22 = shl i64 %12, 32
%23 = ashr exact i64 %22, 32
br label %24
24: ; preds = %10, %24
%25 = phi i64 [ %23, %10 ], [ %51, %24 ]
%26 = phi i32 [ 0, %10 ], [ %52, %24 ]
%27 = sitofp i32 %26 to double
%28 = fmul double %27, 0x401921FB54442D18
%29 = fdiv double %28, %5
%30 = tail call double @cos(double %21)
%31 = tail call double @cos(double %29)
%32 = fmul double %30, %31
%33 = getelementptr inbounds double, double* %1, i64 %25
store double %32, double* %33
%34 = tail call double @sin(double %21)
%35 = getelementptr inbounds double, double* %2, i64 %25
store double %34, double* %35
%36 = tail call double @cos(double %21)
%37 = tail call double @sin(double %29)
%38 = fmul double %36, %37
%39 = getelementptr inbounds double, double* %3, i64 %25
store double %38, double* %39
%40 = add nsw i64 %25, 1
%41 = tail call double @cos(double %16)
%42 = tail call double @cos(double %29)
%43 = fmul double %41, %42
%44 = getelementptr inbounds double, double* %1, i64 %40
store double %43, double* %44
%45 = tail call double @sin(double %16)
%46 = getelementptr inbounds double, double* %2, i64 %40
store double %45, double* %46
%47 = tail call double @cos(double %16)
%48 = tail call double @sin(double %29)
%49 = fmul double %47, %48
%50 = getelementptr inbounds double, double* %3, i64 %40
store double %49, double* %50
%51 = add nsw i64 %25, 2
%52 = add nuw i32 %26, 1
%53 = icmp eq i32 %26, %0
br i1 %53, label %8, label %24
54: ; preds = %8
%55 = trunc i64 %51 to i32
br label %56
56: ; preds = %54, %4
%57 = phi i32 [ 0, %4 ], [ %55, %54 ]
ret i32 %57
}