#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 atan2(double, double);
size_t ind(int, int);
double round(double);
void c_circCurvature_simple(double *points, int numberOfPoints,
                            double edgeLength, double *angles) {
  int p1I, p2I;
  double a1, a2;
  edgeLength = round(edgeLength);
  p1I = (int)(numberOfPoints - edgeLength);
  p2I = (int)(edgeLength);
  int kk;
  for (kk = 0; kk < numberOfPoints; kk++, p1I++, p2I++) {
    if (p1I == numberOfPoints)
      p1I = 0;
    if (p2I == numberOfPoints)
      p2I = 0;
    a2 = atan2(points[ind(kk, 0)] - points[ind(p2I, 0)],
               points[ind(kk, 1)] - points[ind(p2I, 1)]);
    a1 = atan2(points[ind(p1I, 0)] - points[ind(kk, 0)],
               points[ind(p1I, 1)] - points[ind(kk, 1)]);
    angles[kk] = a2 - a1;
    if (angles[kk] > M_PI)
      angles[kk] = angles[kk] - 2 * M_PI;
    else {
      if (angles[kk] < -M_PI)
        angles[kk] = angles[kk] + 2 * M_PI;
    }
    angles[kk] = angles[kk] * 180 / M_PI;
  }
}


x86 assembly (clang, -O0):
<c_circCurvature_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <round@plt>
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    143b <c_circCurvature_simple+0x30b>
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1199 <c_circCurvature_simple+0x69>
movl   $0x0,-0x24(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ac <c_circCurvature_simple+0x7c>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x3c(%rbp),%edi
xor    %esi,%esi
call   1040 <ind@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  -0xa8(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1040 <ind@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x28(%rbp),%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
subsd  (%rax,%rcx,8),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x24(%rbp),%edi
xor    %esi,%esi
call   1040 <ind@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x3c(%rbp),%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  -0x70(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   1040 <ind@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
subsd  (%rax,%rcx,8),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2ca1(%rip),%rax
ucomisd (%rax),%xmm0
jbe    1383 <c_circCurvature_simple+0x253>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2c83(%rip),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13ee <c_circCurvature_simple+0x2be>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    0x2c51(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    13e9 <c_circCurvature_simple+0x2b9>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    0x2c18(%rip),%rax
movsd  (%rax),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13ee <c_circCurvature_simple+0x2be>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xc02(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    0x2bde(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117a <c_circCurvature_simple+0x4a>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_circCurvature_simple>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%r12
call   1050 <round@plt>
mov    %ebx,0x14(%rsp)
test   %ebx,%ebx
jle    12fa <c_circCurvature_simple+0x1ca>
mov    0x14(%rsp),%eax
mov    %eax,%ecx
cvttsd2si %xmm0,%r13d
cvtsi2sd %eax,%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
mov    0x2e73(%rip),%r14
xor    %ebx,%ebx
mov    %rcx,0x18(%rsp)
jmp    11ba <c_circCurvature_simple+0x8a>
xchg   %ax,%ax
addsd  %xmm0,%xmm0
subsd  %xmm0,%xmm2
mov    0x18(%rsp),%rcx
movsd  %xmm2,(%r15,%rbx,8)
mulsd  0xe75(%rip),%xmm2
divsd  (%r14),%xmm2
movsd  %xmm2,(%r15,%rbx,8)
add    $0x1,%rbx
add    $0x1,%ebp
add    $0x1,%r13d
cmp    %rbx,%rcx
je     12fa <c_circCurvature_simple+0x1ca>
cmp    %ecx,%ebp
mov    $0x0,%eax
cmove  %eax,%ebp
cmp    0x14(%rsp),%r13d
cmove  %eax,%r13d
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r13d,%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  0x8(%rsp),%xmm0
subsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %r13d,%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  0x20(%rsp),%xmm1
subsd  (%r12,%rax,8),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
movaps %xmm0,0x20(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <ind@plt>
movsd  0x8(%rsp),%xmm0
subsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <ind@plt>
movsd  0x30(%rsp),%xmm1
subsd  (%r12,%rax,8),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
movapd 0x20(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,(%r15,%rbx,8)
movsd  (%r14),%xmm0
ucomisd %xmm0,%xmm2
ja     1180 <c_circCurvature_simple+0x50>
movapd %xmm0,%xmm1
xorpd  0xd2b(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    12f0 <c_circCurvature_simple+0x1c0>
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm2
jmp    1188 <c_circCurvature_simple+0x58>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rcx
jmp    1193 <c_circCurvature_simple+0x63>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @c_circCurvature_simple(double* %0, i32 %1, double %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double* %3, double** %8
%14 = load double, double* %7
%15 = call double @llvm.round.f64(double %14)
store double %15, double* %7
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
%18 = load double, double* %7
%19 = fsub double %17, %18
%20 = fptosi double %19 to i32
store i32 %20, i32* %9
%21 = load double, double* %7
%22 = fptosi double %21 to i32
store i32 %22, i32* %10
store i32 0, i32* %13
br label %23
23: ; preds = %145, %4
%24 = load i32, i32* %13
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %152
27: ; preds = %23
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 0, i32* %9
br label %32
32: ; preds = %31, %27
%33 = load i32, i32* %10
%34 = load i32, i32* %6
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 0, i32* %10
br label %37
37: ; preds = %36, %32
%38 = load double*, double** %5
%39 = load i32, i32* %13
%40 = call i64 @ind(i32 %39, i32 0)
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %5
%44 = load i32, i32* %10
%45 = call i64 @ind(i32 %44, i32 0)
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fsub double %42, %47
%49 = load double*, double** %5
%50 = load i32, i32* %13
%51 = call i64 @ind(i32 %50, i32 1)
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %5
%55 = load i32, i32* %10
%56 = call i64 @ind(i32 %55, i32 1)
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = fsub double %53, %58
%60 = call double @atan2(double %48, double %59)
store double %60, double* %12
%61 = load double*, double** %5
%62 = load i32, i32* %9
%63 = call i64 @ind(i32 %62, i32 0)
%64 = getelementptr inbounds double, double* %61, i64 %63
%65 = load double, double* %64
%66 = load double*, double** %5
%67 = load i32, i32* %13
%68 = call i64 @ind(i32 %67, i32 0)
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fsub double %65, %70
%72 = load double*, double** %5
%73 = load i32, i32* %9
%74 = call i64 @ind(i32 %73, i32 1)
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = load double*, double** %5
%78 = load i32, i32* %13
%79 = call i64 @ind(i32 %78, i32 1)
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fsub double %76, %81
%83 = call double @atan2(double %71, double %82)
store double %83, double* %11
%84 = load double, double* %12
%85 = load double, double* %11
%86 = fsub double %84, %85
%87 = load double*, double** %8
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
store double %86, double* %90
%91 = load double*, double** %8
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = load double, double* @M_PI
%97 = fcmp ogt double %95, %96
br i1 %97, label %98, label %110
98: ; preds = %37
%99 = load double*, double** %8
%100 = load i32, i32* %13
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
%103 = load double, double* %102
%104 = load double, double* @M_PI
%105 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %104, double %103)
%106 = load double*, double** %8
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
store double %105, double* %109
br label %132
110: ; preds = %37
%111 = load double*, double** %8
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = load double, double* @M_PI
%117 = fneg double %116
%118 = fcmp olt double %115, %117
br i1 %118, label %119, label %131
119: ; preds = %110
%120 = load double*, double** %8
%121 = load i32, i32* %13
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
%124 = load double, double* %123
%125 = load double, double* @M_PI
%126 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %125, double %124)
%127 = load double*, double** %8
%128 = load i32, i32* %13
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
store double %126, double* %130
br label %131
131: ; preds = %119, %110
br label %132
132: ; preds = %131, %98
%133 = load double*, double** %8
%134 = load i32, i32* %13
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %133, i64 %135
%137 = load double, double* %136
%138 = fmul double %137, 1.800000e+02
%139 = load double, double* @M_PI
%140 = fdiv double %138, %139
%141 = load double*, double** %8
%142 = load i32, i32* %13
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %141, i64 %143
store double %140, double* %144
br label %145
145: ; preds = %132
%146 = load i32, i32* %13
%147 = add nsw i32 %146, 1
store i32 %147, i32* %13
%148 = load i32, i32* %9
%149 = add nsw i32 %148, 1
store i32 %149, i32* %9
%150 = load i32, i32* %10
%151 = add nsw i32 %150, 1
store i32 %151, i32* %10
br label %23
152: ; preds = %23
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @c_circCurvature_simple(double* nocapture %0, i32 %1, double %2, double* nocapture %3) {
%5 = tail call double @llvm.round.f64(double %2)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %74
7: ; preds = %4
%8 = fptosi double %5 to i32
%9 = sitofp i32 %1 to double
%10 = fsub double %9, %5
%11 = fptosi double %10 to i32
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %7, %65
%14 = phi i64 [ 0, %7 ], [ %70, %65 ]
%15 = phi i32 [ %11, %7 ], [ %71, %65 ]
%16 = phi i32 [ %8, %7 ], [ %72, %65 ]
%17 = icmp eq i32 %15, %1
%18 = select i1 %17, i32 0, i32 %15
%19 = icmp eq i32 %16, %1
%20 = select i1 %19, i32 0, i32 %16
%21 = trunc i64 %14 to i32
%22 = tail call i64 @ind(i32 %21, i32 0)
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = tail call i64 @ind(i32 %20, i32 0)
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = tail call i64 @ind(i32 %21, i32 1)
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = tail call i64 @ind(i32 %20, i32 1)
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = fsub double %31, %34
%36 = tail call double @atan2(double %28, double %35)
%37 = tail call i64 @ind(i32 %18, i32 0)
%38 = getelementptr inbounds double, double* %0, i64 %37
%39 = load double, double* %38
%40 = tail call i64 @ind(i32 %21, i32 0)
%41 = getelementptr inbounds double, double* %0, i64 %40
%42 = load double, double* %41
%43 = fsub double %39, %42
%44 = tail call i64 @ind(i32 %18, i32 1)
%45 = getelementptr inbounds double, double* %0, i64 %44
%46 = load double, double* %45
%47 = tail call i64 @ind(i32 %21, i32 1)
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = load double, double* %48
%50 = fsub double %46, %49
%51 = tail call double @atan2(double %43, double %50)
%52 = fsub double %36, %51
%53 = getelementptr inbounds double, double* %3, i64 %14
store double %52, double* %53
%54 = load double, double* @M_PI
%55 = fcmp ogt double %52, %54
br i1 %55, label %56, label %58
56: ; preds = %13
%57 = tail call double @llvm.fmuladd.f64(double %54, double -2.000000e+00, double %52)
br label %63
58: ; preds = %13
%59 = fneg double %54
%60 = fcmp olt double %52, %59
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = tail call double @llvm.fmuladd.f64(double %54, double 2.000000e+00, double %52)
br label %63
63: ; preds = %56, %61
%64 = phi double [ %62, %61 ], [ %57, %56 ]
store double %64, double* %53
br label %65
65: ; preds = %63, %58
%66 = phi double [ %52, %58 ], [ %64, %63 ]
%67 = fmul double %66, 1.800000e+02
%68 = load double, double* @M_PI
%69 = fdiv double %67, %68
store double %69, double* %53
%70 = add nuw nsw i64 %14, 1
%71 = add nsw i32 %18, 1
%72 = add nsw i32 %20, 1
%73 = icmp eq i64 %70, %12
br i1 %73, label %74, label %13
74: ; preds = %65, %4
ret void
}