#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 M_PI;
double acos(double);
void circleangleloop(double *r, double p, double z, int n, double *answer) {
  int i;
  double pminusz = p - z;
  double pplusz = p + z;
  double zsquared = z * z;
  double psquared = p * p;
  double ri;
  for (i = 0; i < n; i++) {
    ri = *(r + i);
    if (ri <= pminusz)
      *(answer + i) = M_PI;
    else if ((ri < pplusz) && (ri > -pminusz))
      *(answer + i) = acos((ri * ri + zsquared - psquared) / (2 * z * ri));
    else
      *(answer + i) = 0;
  }
  return;
}


x86 assembly (clang, -O0):
<circleangleloop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    126f <circleangleloop+0x15f>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11bf <circleangleloop+0xaf>
mov    0x2e3f(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    125c <circleangleloop+0x14c>
movsd  -0x58(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1247 <circleangleloop+0x137>
movsd  -0x58(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
jbe    1247 <circleangleloop+0x137>
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xdde(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1257 <circleangleloop+0x147>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    125c <circleangleloop+0x14c>
jmp    1261 <circleangleloop+0x151>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <circleangleloop+0x60>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circleangleloop>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
test   %esi,%esi
jle    11f7 <circleangleloop+0xe7>
mov    %rdx,%r14
mov    %rdi,%r15
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm0,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
movsd  %xmm4,(%rsp)
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd 0xea6(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
addsd  %xmm1,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %esi,%r12d
xor    %ebx,%ebx
mov    0x2e6e(%rip),%r13
movapd %xmm2,0x20(%rsp)
movsd  %xmm3,0x8(%rsp)
jmp    11a5 <circleangleloop+0x95>
nopl   0x0(%rax,%rax,1)
movsd  0x0(%r13),%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11f7 <circleangleloop+0xe7>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm0,%xmm2
jae    1190 <circleangleloop+0x80>
ucomisd %xmm0,%xmm3
xorpd  %xmm1,%xmm1
jbe    1196 <circleangleloop+0x86>
ucomisd 0x30(%rsp),%xmm0
jbe    1196 <circleangleloop+0x86>
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm0
addsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
movsd  0x8(%rsp),%xmm3
movapd 0x20(%rsp),%xmm2
movapd %xmm0,%xmm1
jmp    1196 <circleangleloop+0x86>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @circleangleloop(double* %0, double %1, double %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double* %0, double** %6
store double %1, double* %7
store double %2, double* %8
store i32 %3, i32* %9
store double* %4, double** %10
%17 = load double, double* %7
%18 = load double, double* %8
%19 = fsub double %17, %18
store double %19, double* %12
%20 = load double, double* %7
%21 = load double, double* %8
%22 = fadd double %20, %21
store double %22, double* %13
%23 = load double, double* %8
%24 = load double, double* %8
%25 = fmul double %23, %24
store double %25, double* %14
%26 = load double, double* %7
%27 = load double, double* %7
%28 = fmul double %26, %27
store double %28, double* %15
store i32 0, i32* %11
br label %29
29: ; preds = %81, %5
%30 = load i32, i32* %11
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %84
33: ; preds = %29
%34 = load double*, double** %6
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
store double %38, double* %16
%39 = load double, double* %16
%40 = load double, double* %12
%41 = fcmp ole double %39, %40
br i1 %41, label %42, label %48
42: ; preds = %33
%43 = load double, double* @M_PI
%44 = load double*, double** %10
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %80
48: ; preds = %33
%49 = load double, double* %16
%50 = load double, double* %13
%51 = fcmp olt double %49, %50
br i1 %51, label %52, label %74
52: ; preds = %48
%53 = load double, double* %16
%54 = load double, double* %12
%55 = fneg double %54
%56 = fcmp ogt double %53, %55
br i1 %56, label %57, label %74
57: ; preds = %52
%58 = load double, double* %16
%59 = load double, double* %16
%60 = load double, double* %14
%61 = call double @llvm.fmuladd.f64(double %58, double %59, double %60)
%62 = load double, double* %15
%63 = fsub double %61, %62
%64 = load double, double* %8
%65 = fmul double 2.000000e+00, %64
%66 = load double, double* %16
%67 = fmul double %65, %66
%68 = fdiv double %63, %67
%69 = call double @acos(double %68)
%70 = load double*, double** %10
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
store double %69, double* %73
br label %79
74: ; preds = %52, %48
%75 = load double*, double** %10
%76 = load i32, i32* %11
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
store double 0.000000e+00, double* %78
br label %79
79: ; preds = %74, %57
br label %80
80: ; preds = %79, %42
br label %81
81: ; preds = %80
%82 = load i32, i32* %11
%83 = add nsw i32 %82, 1
store i32 %83, i32* %11
br label %29
84: ; preds = %29
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @circleangleloop(double* nocapture %0, double %1, double %2, i32 %3, double* nocapture writeonly %4) {
%6 = fsub double %1, %2
%7 = fadd double %1, %2
%8 = fmul double %2, %2
%9 = fmul double %1, %1
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %37
11: ; preds = %5
%12 = fneg double %6
%13 = fmul double %2, 2.000000e+00
%14 = zext i32 %3 to i64
br label %15
15: ; preds = %11, %32
%16 = phi i64 [ 0, %11 ], [ %35, %32 ]
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = fcmp ugt double %18, %6
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = load double, double* @M_PI
br label %32
22: ; preds = %15
%23 = fcmp olt double %18, %7
%24 = fcmp ogt double %18, %12
%25 = and i1 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %8)
%28 = fsub double %27, %9
%29 = fmul double %13, %18
%30 = fdiv double %28, %29
%31 = tail call double @acos(double %30)
br label %32
32: ; preds = %22, %20, %26
%33 = phi double [ %21, %20 ], [ %31, %26 ], [ 0.000000e+00, %22 ]
%34 = getelementptr inbounds double, double* %4, i64 %16
store double %33, double* %34
%35 = add nuw nsw i64 %16, 1
%36 = icmp eq i64 %35, %14
br i1 %36, label %37, label %15
37: ; preds = %32, %5
ret void
}