#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 DBL_MAX;
double atan2(double, double);
double *calloc(int, int);
double circularMvDistance(int, double *, double *);
double cos(double);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
double sin(double);
void circularGeometricMedian(int n, int p, double *angles, double eps,
                             int maxiter, int *maxiter_flag, double *median) {
  double *last = calloc(sizeof(double), p);
  int i, j;
  int iter;
  double auxDist;
  double aggr;
  double improv = DBL_MAX;
  double *aux_cos = calloc(sizeof(double), 2 * p);
  double *aux_sin = aux_cos + p;
  iter = 0;
  while (improv > eps && maxiter > iter) {
    iter++;
    aggr = 0;
    memcpy(last, median, sizeof(double) * p);
    memset(aux_cos, 0, sizeof(double) * p);
    memset(aux_sin, 0, sizeof(double) * p);
    for (i = 0; i < n; i++) {
      auxDist = circularMvDistance(p, last, angles + (i * p));
      if (auxDist != 0) {
        aggr += 1 / auxDist;
        for (j = 0; j < p; j++) {
          aux_cos[j] += cos(angles[(i * p) + j]) / auxDist;
          aux_sin[j] += sin(angles[(i * p) + j]) / auxDist;
        }
      }
    }
    for (j = 0; j < p; j++) {
      aux_cos[j] /= aggr;
      aux_sin[j] /= aggr;
      median[j] = atan2(aux_sin[j], aux_cos[j]);
    }
    improv = circularMvDistance(p, last, median);
  }
  free(last);
  free(aux_cos);
  if (maxiter_flag != NULL)
    *maxiter_flag = maxiter > iter;
}


x86 assembly (clang, -O0):
<circularGeometricMedian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x8,%edi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x2e23(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
mov    $0x8,%edi
call   1060 <calloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x8(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x44(%rbp)
movsd  -0x60(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x71(%rbp)
jbe    1215 <circularGeometricMedian+0x95>
mov    -0x1c(%rbp),%eax
cmp    -0x44(%rbp),%eax
setg   %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    1225 <circularGeometricMedian+0xa5>
jmp    141d <circularGeometricMedian+0x29d>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1080 <memcpy@plt>
mov    -0x68(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x70(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1380 <circularGeometricMedian+0x200>
mov    -0x8(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x3c(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   10a0 <circularMvDistance@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12cc <circularGeometricMedian+0x14c>
jp     12cc <circularGeometricMedian+0x14c>
jmp    136d <circularGeometricMedian+0x1ed>
movsd  0xd2c(%rip),%xmm0
divsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1368 <circularGeometricMedian+0x1e8>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1090 <cos@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x40(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <sin@plt>
divsd  -0x50(%rbp),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x40(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12ea <circularGeometricMedian+0x16a>
jmp    136d <circularGeometricMedian+0x1ed>
jmp    1372 <circularGeometricMedian+0x1f2>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    127e <circularGeometricMedian+0xfe>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1403 <circularGeometricMedian+0x283>
movsd  -0x58(%rbp),%xmm1
mov    -0x68(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm1
mov    -0x70(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x70(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1040 <atan2@plt>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1387 <circularGeometricMedian+0x207>
mov    -0x8(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10a0 <circularMvDistance@plt>
movsd  %xmm0,-0x60(%rbp)
jmp    11f4 <circularGeometricMedian+0x74>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
je     144e <circularGeometricMedian+0x2ce>
mov    -0x1c(%rbp),%eax
cmp    -0x44(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circularGeometricMedian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,%r13
mov    %r8,0x50(%rsp)
mov    %ecx,%ebx
movsd  %xmm0,0x38(%rsp)
mov    %rdx,0x48(%rsp)
mov    %esi,%ebp
mov    %edi,0x14(%rsp)
mov    $0x8,%edi
call   1060 <calloc@plt>
mov    %rax,0x20(%rsp)
mov    0x2e21(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %rbp,0x18(%rsp)
lea    0x0(%rbp,%rbp,1),%esi
mov    $0x8,%edi
call   1060 <calloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
setg   %r12b
movsd  0x28(%rsp),%xmm0
ucomisd 0x38(%rsp),%xmm0
jbe    1400 <circularGeometricMedian+0x280>
test   %ebx,%ebx
jle    1400 <circularGeometricMedian+0x280>
mov    0x18(%rsp),%rax
movslq %eax,%rcx
lea    (%r14,%rcx,8),%r15
lea    0x0(,%rax,8),%edx
mov    %edx,0x30(%rsp)
mov    0x14(%rsp),%edx
mov    %rdx,0x68(%rsp)
mov    %eax,%ebp
mov    %rcx,0x70(%rsp)
lea    0x0(,%rcx,8),%rax
mov    %rax,0x60(%rsp)
xor    %eax,%eax
mov    %rax,0x40(%rsp)
mov    %r13,0x58(%rsp)
mov    %ebx,0x34(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    0x30(%rsp),%ebx
mov    %ebx,%edx
call   1080 <memcpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
xorpd  %xmm2,%xmm2
cmpl   $0x0,0x14(%rsp)
mov    0x18(%rsp),%rbx
jle    1370 <circularGeometricMedian+0x1f0>
xorpd  %xmm2,%xmm2
mov    0x48(%rsp),%r13
xor    %r12d,%r12d
jmp    12ba <circularGeometricMedian+0x13a>
nopl   (%rax)
movsd  0x8(%rsp),%xmm2
add    $0x1,%r12
add    0x60(%rsp),%r13
cmp    0x68(%rsp),%r12
je     1370 <circularGeometricMedian+0x1f0>
movsd  %xmm2,0x8(%rsp)
mov    %r12,%rax
imul   0x70(%rsp),%rax
mov    0x48(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    %ebx,%edi
mov    0x20(%rsp),%rsi
call   10a0 <circularMvDistance@plt>
ucomisd 0xd22(%rip),%xmm0
jne    12ea <circularGeometricMedian+0x16a>
jnp    12a0 <circularGeometricMedian+0x120>
movapd %xmm0,%xmm2
movsd  0xd0a(%rip),%xmm0
movapd %xmm2,%xmm1
divsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
test   %ebx,%ebx
jle    12a6 <circularGeometricMedian+0x126>
movsd  %xmm2,0x8(%rsp)
xor    %ebx,%ebx
movsd  %xmm1,0x28(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1090 <cos@plt>
divsd  0x28(%rsp),%xmm0
addsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1070 <sin@plt>
divsd  0x28(%rsp),%xmm0
addsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1320 <circularGeometricMedian+0x1a0>
mov    0x18(%rsp),%rbx
jmp    12a0 <circularGeometricMedian+0x120>
nop
mov    0x40(%rsp),%r12
add    $0x1,%r12d
test   %ebx,%ebx
mov    0x58(%rsp),%r13
jle    13cb <circularGeometricMedian+0x24b>
xor    %ebx,%ebx
movsd  %xmm2,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  (%r14,%rbx,8),%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
movsd  (%r15,%rbx,8),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
call   1040 <atan2@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm0,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1390 <circularGeometricMedian+0x210>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    %r13,%rdx
call   10a0 <circularMvDistance@plt>
mov    0x34(%rsp),%ebx
cmp    %ebx,%r12d
mov    %r12,%rax
setl   %r12b
ucomisd 0x38(%rsp),%xmm0
jbe    1400 <circularGeometricMedian+0x280>
mov    %rax,0x40(%rsp)
cmp    %ebx,%eax
jl     1250 <circularGeometricMedian+0xd0>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x50(%rsp),%rcx
test   %rcx,%rcx
je     1422 <circularGeometricMedian+0x2a2>
movzbl %r12b,%eax
mov    %eax,(%rcx)
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
define void @circularGeometricMedian(i32 %0, i32 %1, double* %2, double %3, i32 %4, i32* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double
%12 = alloca i32
%13 = alloca i32*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double*
%23 = alloca double*
store i32 %0, i32* %8
store i32 %1, i32* %9
store double* %2, double** %10
store double %3, double* %11
store i32 %4, i32* %12
store i32* %5, i32** %13
store double* %6, double** %14
%24 = load i32, i32* %9
%25 = call double* @calloc(i32 8, i32 %24)
store double* %25, double** %15
%26 = load double, double* @DBL_MAX
store double %26, double* %21
%27 = load i32, i32* %9
%28 = mul nsw i32 2, %27
%29 = call double* @calloc(i32 8, i32 %28)
store double* %29, double** %22
%30 = load double*, double** %22
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double* %33, double** %23
store i32 0, i32* %18
br label %34
34: ; preds = %174, %7
%35 = load double, double* %21
%36 = load double, double* %11
%37 = fcmp ogt double %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %12
%40 = load i32, i32* %18
%41 = icmp sgt i32 %39, %40
br label %42
42: ; preds = %38, %34
%43 = phi i1 [ false, %34 ], [ %41, %38 ]
br i1 %43, label %44, label %179
44: ; preds = %42
%45 = load i32, i32* %18
%46 = add nsw i32 %45, 1
store i32 %46, i32* %18
store double 0.000000e+00, double* %20
%47 = load double*, double** %15
%48 = load double*, double** %14
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = mul i64 8, %50
%52 = trunc i64 %51 to i32
%53 = call i32 @memcpy(double* %47, double* %48, i32 %52)
%54 = load double*, double** %22
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = mul i64 8, %56
%58 = trunc i64 %57 to i32
%59 = call i32 @memset(double* %54, i32 0, i32 %58)
%60 = load double*, double** %23
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = mul i64 8, %62
%64 = trunc i64 %63 to i32
%65 = call i32 @memset(double* %60, i32 0, i32 %64)
store i32 0, i32* %16
br label %66
66: ; preds = %133, %44
%67 = load i32, i32* %16
%68 = load i32, i32* %8
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %136
70: ; preds = %66
%71 = load i32, i32* %9
%72 = load double*, double** %15
%73 = load double*, double** %10
%74 = load i32, i32* %16
%75 = load i32, i32* %9
%76 = mul nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %73, i64 %77
%79 = call double @circularMvDistance(i32 %71, double* %72, double* %78)
store double %79, double* %19
%80 = load double, double* %19
%81 = fcmp une double %80, 0.000000e+00
br i1 %81, label %82, label %132
82: ; preds = %70
%83 = load double, double* %19
%84 = fdiv double 1.000000e+00, %83
%85 = load double, double* %20
%86 = fadd double %85, %84
store double %86, double* %20
store i32 0, i32* %17
br label %87
87: ; preds = %128, %82
%88 = load i32, i32* %17
%89 = load i32, i32* %9
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %131
91: ; preds = %87
%92 = load double*, double** %10
%93 = load i32, i32* %16
%94 = load i32, i32* %9
%95 = mul nsw i32 %93, %94
%96 = load i32, i32* %17
%97 = add nsw i32 %95, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %92, i64 %98
%100 = load double, double* %99
%101 = call double @cos(double %100)
%102 = load double, double* %19
%103 = fdiv double %101, %102
%104 = load double*, double** %22
%105 = load i32, i32* %17
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
%108 = load double, double* %107
%109 = fadd double %108, %103
store double %109, double* %107
%110 = load double*, double** %10
%111 = load i32, i32* %16
%112 = load i32, i32* %9
%113 = mul nsw i32 %111, %112
%114 = load i32, i32* %17
%115 = add nsw i32 %113, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %110, i64 %116
%118 = load double, double* %117
%119 = call double @sin(double %118)
%120 = load double, double* %19
%121 = fdiv double %119, %120
%122 = load double*, double** %23
%123 = load i32, i32* %17
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %122, i64 %124
%126 = load double, double* %125
%127 = fadd double %126, %121
store double %127, double* %125
br label %128
128: ; preds = %91
%129 = load i32, i32* %17
%130 = add nsw i32 %129, 1
store i32 %130, i32* %17
br label %87
131: ; preds = %87
br label %132
132: ; preds = %131, %70
br label %133
133: ; preds = %132
%134 = load i32, i32* %16
%135 = add nsw i32 %134, 1
store i32 %135, i32* %16
br label %66
136: ; preds = %66
store i32 0, i32* %17
br label %137
137: ; preds = %171, %136
%138 = load i32, i32* %17
%139 = load i32, i32* %9
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %174
141: ; preds = %137
%142 = load double, double* %20
%143 = load double*, double** %22
%144 = load i32, i32* %17
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %143, i64 %145
%147 = load double, double* %146
%148 = fdiv double %147, %142
store double %148, double* %146
%149 = load double, double* %20
%150 = load double*, double** %23
%151 = load i32, i32* %17
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %150, i64 %152
%154 = load double, double* %153
%155 = fdiv double %154, %149
store double %155, double* %153
%156 = load double*, double** %23
%157 = load i32, i32* %17
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %156, i64 %158
%160 = load double, double* %159
%161 = load double*, double** %22
%162 = load i32, i32* %17
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds double, double* %161, i64 %163
%165 = load double, double* %164
%166 = call double @atan2(double %160, double %165)
%167 = load double*, double** %14
%168 = load i32, i32* %17
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %167, i64 %169
store double %166, double* %170
br label %171
171: ; preds = %141
%172 = load i32, i32* %17
%173 = add nsw i32 %172, 1
store i32 %173, i32* %17
br label %137
174: ; preds = %137
%175 = load i32, i32* %9
%176 = load double*, double** %15
%177 = load double*, double** %14
%178 = call double @circularMvDistance(i32 %175, double* %176, double* %177)
store double %178, double* %21
br label %34
179: ; preds = %42
%180 = load double*, double** %15
%181 = call i32 @free(double* %180)
%182 = load double*, double** %22
%183 = call i32 @free(double* %182)
%184 = load i32*, i32** %13
%185 = icmp ne i32* %184, null
br i1 %185, label %186, label %192
186: ; preds = %179
%187 = load i32, i32* %12
%188 = load i32, i32* %18
%189 = icmp sgt i32 %187, %188
%190 = zext i1 %189 to i32
%191 = load i32*, i32** %13
store i32 %190, i32* %191
br label %192
192: ; preds = %186, %179
ret void
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
define void @circularGeometricMedian(i32 %0, i32 %1, double* %2, double %3, i32 %4, i32* writeonly %5, double* %6) {
%8 = tail call double* @calloc(i32 8, i32 %1)
%9 = load double, double* @DBL_MAX
%10 = shl nsw i32 %1, 1
%11 = tail call double* @calloc(i32 8, i32 %10)
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds double, double* %11, i64 %12
%14 = fcmp ogt double %9, %3
%15 = icmp sgt i32 %4, 0
%16 = and i1 %14, %15
br i1 %16, label %17, label %81
17: ; preds = %7
%18 = shl i32 %1, 3
%19 = icmp sgt i32 %0, 0
%20 = icmp sgt i32 %1, 0
%21 = zext i32 %0 to i64
%22 = zext i32 %1 to i64
%23 = zext i32 %1 to i64
br label %24
24: ; preds = %17, %76
%25 = phi i32 [ 0, %17 ], [ %26, %76 ]
%26 = add nuw nsw i32 %25, 1
%27 = tail call i32 @memcpy(double* %8, double* %6, i32 %18)
%28 = tail call i32 @memset(double* %11, i32 0, i32 %18)
%29 = tail call i32 @memset(double* %13, i32 0, i32 %18)
br i1 %19, label %32, label %30
30: ; preds = %60, %24
%31 = phi double [ 0.000000e+00, %24 ], [ %61, %60 ]
br i1 %20, label %64, label %76
32: ; preds = %24, %60
%33 = phi i64 [ %62, %60 ], [ 0, %24 ]
%34 = phi double [ %61, %60 ], [ 0.000000e+00, %24 ]
%35 = mul nsw i64 %33, %12
%36 = getelementptr inbounds double, double* %2, i64 %35
%37 = tail call double @circularMvDistance(i32 %1, double* %8, double* %36)
%38 = fcmp une double %37, 0.000000e+00
br i1 %38, label %39, label %60
39: ; preds = %32
%40 = fdiv double 1.000000e+00, %37
%41 = fadd double %34, %40
br i1 %20, label %42, label %60
42: ; preds = %39, %42
%43 = phi i64 [ %58, %42 ], [ 0, %39 ]
%44 = add nsw i64 %43, %35
%45 = getelementptr inbounds double, double* %2, i64 %44
%46 = load double, double* %45
%47 = tail call double @cos(double %46)
%48 = fdiv double %47, %37
%49 = getelementptr inbounds double, double* %11, i64 %43
%50 = load double, double* %49
%51 = fadd double %50, %48
store double %51, double* %49
%52 = load double, double* %45
%53 = tail call double @sin(double %52)
%54 = fdiv double %53, %37
%55 = getelementptr inbounds double, double* %13, i64 %43
%56 = load double, double* %55
%57 = fadd double %56, %54
store double %57, double* %55
%58 = add nuw nsw i64 %43, 1
%59 = icmp eq i64 %58, %22
br i1 %59, label %60, label %42
60: ; preds = %42, %39, %32
%61 = phi double [ %34, %32 ], [ %41, %39 ], [ %41, %42 ]
%62 = add nuw nsw i64 %33, 1
%63 = icmp eq i64 %62, %21
br i1 %63, label %30, label %32
64: ; preds = %30, %64
%65 = phi i64 [ %74, %64 ], [ 0, %30 ]
%66 = getelementptr inbounds double, double* %11, i64 %65
%67 = load double, double* %66
%68 = fdiv double %67, %31
store double %68, double* %66
%69 = getelementptr inbounds double, double* %13, i64 %65
%70 = load double, double* %69
%71 = fdiv double %70, %31
store double %71, double* %69
%72 = tail call double @atan2(double %71, double %68)
%73 = getelementptr inbounds double, double* %6, i64 %65
store double %72, double* %73
%74 = add nuw nsw i64 %65, 1
%75 = icmp eq i64 %74, %23
br i1 %75, label %76, label %64
76: ; preds = %64, %30
%77 = tail call double @circularMvDistance(i32 %1, double* %8, double* %6)
%78 = fcmp ogt double %77, %3
%79 = icmp slt i32 %26, %4
%80 = select i1 %78, i1 %79, i1 false
br i1 %80, label %24, label %81
81: ; preds = %76, %7
%82 = phi i1 [ %15, %7 ], [ %79, %76 ]
%83 = tail call i32 @free(double* %8)
%84 = tail call i32 @free(double* %11)
%85 = icmp eq i32* %5, null
br i1 %85, label %88, label %86
86: ; preds = %81
%87 = zext i1 %82 to i32
store i32 %87, i32* %5
br label %88
88: ; preds = %86, %81
ret void
}