#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 */
scalar_t__ ceil(double);
double fabs(double);
scalar_t__ floor(double);
double calcProfile(float *profileArray, double position) {
  double value, value1, value2, diff, percentDiff, dIndex;
  int index1, index2;
  if (position < 0.0) {
    position = fabs(position);
    dIndex = (double)((position / 6.2831853) * ((double)628));
    percentDiff = dIndex - ((double)floor(dIndex));
    index1 = 628 - ((int)floor(dIndex)) % 628;
    index2 = 628 - ((int)ceil(dIndex)) % 628;
  } else {
    dIndex = (double)((position / 6.2831853) * ((double)628));
    percentDiff = dIndex - ((double)floor(dIndex));
    index1 = ((int)floor(dIndex)) % 628;
    index2 = ((int)ceil(dIndex)) % 628;
  }
  if (index1 < 0)
    index1 = 0;
  else if (index1 >= 628)
    index1 = 628 - 1;
  if (index2 < 0)
    index2 = 0;
  else if (index2 >= 628)
    index2 = 628 - 1;
  value1 = ((double)profileArray[index1]) / ((double)100);
  value2 = ((double)profileArray[index2]) / ((double)100);
  diff = value2 - value1;
  value = value1 + percentDiff * diff;
  return (value);
}


x86 assembly (clang, -O0):
<calcProfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11da <calcProfile+0xba>
movsd  -0x10(%rbp),%xmm0
movaps 0xed5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
mov    $0x274,%ecx
cltd
idiv   %ecx
mov    $0x274,%eax
sub    %edx,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <ceil@plt>
mov    $0x274,%ecx
cltd
idiv   %ecx
mov    $0x274,%eax
sub    %edx,%eax
mov    %eax,-0x48(%rbp)
jmp    124d <calcProfile+0x12d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe0d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
movsd  -0x58(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <floor@plt>
mov    $0x274,%ecx
cltd
idiv   %ecx
mov    %edx,-0x44(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <ceil@plt>
mov    $0x274,%ecx
cltd
idiv   %ecx
mov    %edx,-0x48(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1263 <calcProfile+0x143>
movl   $0x0,-0x44(%rbp)
jmp    127c <calcProfile+0x15c>
cmpl   $0x274,-0x44(%rbp)
jl     1277 <calcProfile+0x157>
movl   $0x273,-0x44(%rbp)
jmp    127c <calcProfile+0x15c>
cmpl   $0x0,-0x48(%rbp)
jge    1292 <calcProfile+0x172>
movl   $0x0,-0x48(%rbp)
jmp    12ab <calcProfile+0x18b>
cmpl   $0x274,-0x48(%rbp)
jl     12a6 <calcProfile+0x186>
movl   $0x273,-0x48(%rbp)
jmp    12ab <calcProfile+0x18b>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd4c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd2a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcProfile>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    11ca <calcProfile+0xaa>
andpd  0xed0(%rip),%xmm0
divsd  0xeb8(%rip),%xmm0
mulsd  0xeb8(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
cvtsi2sd %rax,%xmm2
movapd (%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
call   1040 <floor@plt>
cltq
imul   $0x342da7f3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rcx
add    %edx,%ecx
imul   $0x274,%ecx,%ebx
sub    %eax,%ebx
add    $0x274,%ebx
movaps (%rsp),%xmm0
call   1030 <ceil@plt>
movslq %eax,%rcx
imul   $0x342da7f3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rax
add    %edx,%eax
imul   $0x274,%eax,%eax
sub    %ecx,%eax
add    $0x274,%eax
jmp    1247 <calcProfile+0x127>
divsd  0xe2e(%rip),%xmm0
mulsd  0xe2e(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
cvtsi2sd %rax,%xmm2
movapd (%rsp),%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
call   1040 <floor@plt>
movslq %eax,%rbx
imul   $0x342da7f3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x27,%rax
add    %ecx,%eax
imul   $0x274,%eax,%eax
sub    %eax,%ebx
movaps (%rsp),%xmm0
call   1030 <ceil@plt>
cltq
imul   $0x342da7f3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rcx
add    %edx,%ecx
imul   $0x274,%ecx,%ecx
sub    %ecx,%eax
cmp    $0x273,%ebx
mov    $0x273,%ecx
cmovge %ecx,%ebx
xor    %edx,%edx
test   %ebx,%ebx
cmovs  %edx,%ebx
cmp    $0x273,%eax
cmovl  %eax,%ecx
test   %ecx,%ecx
cmovs  %edx,%ecx
movss  (%r14,%rbx,4),%xmm0
movss  (%r14,%rcx,4),%xmm1
unpcklps %xmm0,%xmm1
cvtps2pd %xmm1,%xmm0
divpd  0xd9d(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @calcProfile(float* %0, double %1) {
%3 = alloca float*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %3
store double %1, double* %4
%13 = load double, double* %4
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %36
15: ; preds = %2
%16 = load double, double* %4
%17 = call double @llvm.fabs.f64(double %16)
store double %17, double* %4
%18 = load double, double* %4
%19 = fdiv double %18, 0x401921FB53C8D4F1
%20 = fmul double %19, 6.280000e+02
store double %20, double* %10
%21 = load double, double* %10
%22 = load double, double* %10
%23 = call i64 @floor(double %22)
%24 = sitofp i64 %23 to double
%25 = fsub double %21, %24
store double %25, double* %9
%26 = load double, double* %10
%27 = call i64 @floor(double %26)
%28 = trunc i64 %27 to i32
%29 = srem i32 %28, 628
%30 = sub nsw i32 628, %29
store i32 %30, i32* %11
%31 = load double, double* %10
%32 = call i64 @ceil(double %31)
%33 = trunc i64 %32 to i32
%34 = srem i32 %33, 628
%35 = sub nsw i32 628, %34
store i32 %35, i32* %12
br label %53
36: ; preds = %2
%37 = load double, double* %4
%38 = fdiv double %37, 0x401921FB53C8D4F1
%39 = fmul double %38, 6.280000e+02
store double %39, double* %10
%40 = load double, double* %10
%41 = load double, double* %10
%42 = call i64 @floor(double %41)
%43 = sitofp i64 %42 to double
%44 = fsub double %40, %43
store double %44, double* %9
%45 = load double, double* %10
%46 = call i64 @floor(double %45)
%47 = trunc i64 %46 to i32
%48 = srem i32 %47, 628
store i32 %48, i32* %11
%49 = load double, double* %10
%50 = call i64 @ceil(double %49)
%51 = trunc i64 %50 to i32
%52 = srem i32 %51, 628
store i32 %52, i32* %12
br label %53
53: ; preds = %36, %15
%54 = load i32, i32* %11
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %53
store i32 0, i32* %11
br label %62
57: ; preds = %53
%58 = load i32, i32* %11
%59 = icmp sge i32 %58, 628
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 627, i32* %11
br label %61
61: ; preds = %60, %57
br label %62
62: ; preds = %61, %56
%63 = load i32, i32* %12
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %62
store i32 0, i32* %12
br label %71
66: ; preds = %62
%67 = load i32, i32* %12
%68 = icmp sge i32 %67, 628
br i1 %68, label %69, label %70
69: ; preds = %66
store i32 627, i32* %12
br label %70
70: ; preds = %69, %66
br label %71
71: ; preds = %70, %65
%72 = load float*, float** %3
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds float, float* %72, i64 %74
%76 = load float, float* %75
%77 = fpext float %76 to double
%78 = fdiv double %77, 1.000000e+02
store double %78, double* %6
%79 = load float*, float** %3
%80 = load i32, i32* %12
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
%83 = load float, float* %82
%84 = fpext float %83 to double
%85 = fdiv double %84, 1.000000e+02
store double %85, double* %7
%86 = load double, double* %7
%87 = load double, double* %6
%88 = fsub double %86, %87
store double %88, double* %8
%89 = load double, double* %6
%90 = load double, double* %9
%91 = load double, double* %8
%92 = call double @llvm.fmuladd.f64(double %90, double %91, double %89)
store double %92, double* %5
%93 = load double, double* %5
ret double %93
}

LLVM IR (-O2):
define double @calcProfile(float* nocapture %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = tail call double @llvm.fabs.f64(double %1)
%6 = fdiv double %5, 0x401921FB53C8D4F1
%7 = fmul double %6, 6.280000e+02
%8 = tail call i64 @floor(double %7)
%9 = sitofp i64 %8 to double
%10 = fsub double %7, %9
%11 = tail call i64 @floor(double %7)
%12 = trunc i64 %11 to i32
%13 = srem i32 %12, 628
%14 = sub nsw i32 628, %13
%15 = tail call i64 @ceil(double %7)
%16 = trunc i64 %15 to i32
%17 = srem i32 %16, 628
%18 = sub nsw i32 628, %17
br label %31
19: ; preds = %2
%20 = fdiv double %1, 0x401921FB53C8D4F1
%21 = fmul double %20, 6.280000e+02
%22 = tail call i64 @floor(double %21)
%23 = sitofp i64 %22 to double
%24 = fsub double %21, %23
%25 = tail call i64 @floor(double %21)
%26 = trunc i64 %25 to i32
%27 = srem i32 %26, 628
%28 = tail call i64 @ceil(double %21)
%29 = trunc i64 %28 to i32
%30 = srem i32 %29, 628
br label %31
31: ; preds = %19, %4
%32 = phi double [ %10, %4 ], [ %24, %19 ]
%33 = phi i32 [ %14, %4 ], [ %27, %19 ]
%34 = phi i32 [ %18, %4 ], [ %30, %19 ]
%35 = icmp slt i32 %33, 627
%36 = select i1 %35, i32 %33, i32 627
%37 = icmp sgt i32 %36, 0
%38 = select i1 %37, i32 %36, i32 0
%39 = zext i32 %38 to i64
%40 = icmp slt i32 %34, 627
%41 = select i1 %40, i32 %34, i32 627
%42 = icmp sgt i32 %41, 0
%43 = select i1 %42, i32 %41, i32 0
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds float, float* %0, i64 %39
%46 = load float, float* %45
%47 = getelementptr inbounds float, float* %0, i64 %44
%48 = load float, float* %47
%49 = insertelement <2 x float> poison, float %48, i64 0
%50 = insertelement <2 x float> %49, float %46, i64 1
%51 = fpext <2 x float> %50 to <2 x double>
%52 = fdiv <2 x double> %51, <double 1.000000e+02, double 1.000000e+02>
%53 = extractelement <2 x double> %52, i64 0
%54 = extractelement <2 x double> %52, i64 1
%55 = fsub double %53, %54
%56 = tail call double @llvm.fmuladd.f64(double %32, double %55, double %54)
ret double %56
}