#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);
scalar_t__ round(double);
void initInterpolationList(unsigned int *indexList, double *levels,
                           double avgBW, unsigned int fcLen,
                           unsigned int xLim) {
  unsigned int a = 3;
  double step = avgBW;
  levels[0] = (1.0 - 1.0) / (double)xLim;
  levels[1] = (2.0 - 1.0) / (double)xLim;
  for (unsigned int i = 0; i < fcLen; i++) {
    unsigned int stepp = (unsigned int)round(step);
    indexList[(i << 1) + 0] = a - 1;
    indexList[(i << 1) + 1] = a + stepp - 1;
    levels[i + 2] =
        ((double)a + ((double)stepp - 1.0) * 0.5 - 1.0) / (double)xLim;
    a = a + (unsigned int)ceil(((double)stepp) * 0.5);
    step = step * avgBW;
  }
  indexList[(fcLen << 1) + 0] = a - 1;
  indexList[(fcLen << 1) + 1] = xLim;
  levels[2 + fcLen] = ((a + xLim) * 0.5 - 1.0) / (double)xLim;
  levels[2 + fcLen + 1] = (xLim - 1.0) / (double)xLim;
}


x86 assembly (clang, -O0):
<initInterpolationList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm1
xorps  %xmm0,%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  0xe8d(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1262 <initInterpolationList+0x142>
movsd  -0x30(%rbp),%xmm0
call   1040 <round@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edx
add    $0xffffffff,%edx
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x1(%rax,%rcx,1),%edx
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%esi
mov    %esi,%ecx
lea    0x1(%rcx,%rcx,1),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm2
mov    -0x38(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe18(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe14(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xdd7(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %rax,%rcx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1187 <initInterpolationList+0x67>
mov    -0x24(%rbp),%edx
add    $0xffffffff,%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%esi
mov    %esi,%ecx
lea    0x1(%rcx,%rcx,1),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    %edx,%ecx
cvtsi2sd %rcx,%xmm0
movsd  0xd6a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd66(%rip),%xmm2
addsd  %xmm2,%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm1
movaps %xmm1,%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initInterpolationList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,0x4(%rsp)
mov    %ecx,%eax
cvtsi2sd %rax,%xmm1
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbp
movapd %xmm1,%xmm2
movapd %xmm1,%xmm0
xorpd  %xmm1,%xmm1
movhpd 0xea7(%rip),%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movupd %xmm1,(%rsi)
test   %edx,%edx
mov    %rdx,0x18(%rsp)
movapd %xmm2,0x20(%rsp)
je     1249 <initInterpolationList+0x129>
mov    %edx,%r13d
neg    %r13
mov    $0x3,%r14d
mov    $0x2,%ebx
mov    $0x1,%r15d
movsd  0x8(%rsp),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <round@plt>
lea    -0x1(%r14),%ecx
lea    -0x1(%r15),%edx
mov    %ecx,0x0(%rbp,%rdx,4)
lea    (%r14,%rax,1),%ecx
add    $0xffffffff,%ecx
mov    %r14d,%edx
xorps  %xmm1,%xmm1
cvtsi2sd %rdx,%xmm1
mov    %r15d,%edx
mov    %ecx,0x0(%rbp,%rdx,4)
mov    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd %xmm0,%xmm2
movsd  0xe1c(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  0xe18(%rip),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
divsd  0x20(%rsp),%xmm2
mov    %ebx,%eax
movsd  %xmm2,(%r12,%rax,8)
mulsd  %xmm4,%xmm0
call   1030 <ceil@plt>
movsd  0x10(%rsp),%xmm0
add    %r14d,%eax
mulsd  0x8(%rsp),%xmm0
add    $0x2,%r15d
lea    (%rbx,%r13,1),%rcx
add    $0x1,%rcx
add    $0x1,%rbx
mov    %eax,%r14d
cmp    $0x2,%rcx
jne    11a0 <initInterpolationList+0x80>
jmp    124e <initInterpolationList+0x12e>
mov    $0x3,%eax
lea    -0x1(%rax),%ecx
mov    0x18(%rsp),%rsi
lea    (%rsi,%rsi,1),%edx
mov    %ecx,0x0(%rbp,%rdx,4)
lea    (%rsi,%rsi,1),%ecx
add    $0x1,%ecx
mov    0x4(%rsp),%edx
add    %edx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    %edx,0x0(%rbp,%rcx,4)
mulsd  0xd93(%rip),%xmm0
movsd  0xd83(%rip),%xmm1
addsd  %xmm1,%xmm0
movapd 0x20(%rsp),%xmm2
divsd  %xmm2,%xmm0
lea    0x2(%rsi),%eax
movsd  %xmm0,(%r12,%rax,8)
addsd  %xmm2,%xmm1
divsd  %xmm2,%xmm1
add    $0x3,%esi
movsd  %xmm1,(%r12,%rsi,8)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @initInterpolationList(i32* %0, double* %1, double %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %6
store double* %1, double** %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 3, i32* %11
%15 = load double, double* %8
store double %15, double* %12
%16 = load i32, i32* %10
%17 = uitofp i32 %16 to double
%18 = fdiv double 0.000000e+00, %17
%19 = load double*, double** %7
%20 = getelementptr inbounds double, double* %19, i64 0
store double %18, double* %20
%21 = load i32, i32* %10
%22 = uitofp i32 %21 to double
%23 = fdiv double 1.000000e+00, %22
%24 = load double*, double** %7
%25 = getelementptr inbounds double, double* %24, i64 1
store double %23, double* %25
store i32 0, i32* %13
br label %26
26: ; preds = %77, %5
%27 = load i32, i32* %13
%28 = load i32, i32* %9
%29 = icmp ult i32 %27, %28
br i1 %29, label %30, label %80
30: ; preds = %26
%31 = load double, double* %12
%32 = call i64 @round(double %31)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %14
%34 = load i32, i32* %11
%35 = sub i32 %34, 1
%36 = load i32*, i32** %6
%37 = load i32, i32* %13
%38 = shl i32 %37, 1
%39 = add i32 %38, 0
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %36, i64 %40
store i32 %35, i32* %41
%42 = load i32, i32* %11
%43 = load i32, i32* %14
%44 = add i32 %42, %43
%45 = sub i32 %44, 1
%46 = load i32*, i32** %6
%47 = load i32, i32* %13
%48 = shl i32 %47, 1
%49 = add i32 %48, 1
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %46, i64 %50
store i32 %45, i32* %51
%52 = load i32, i32* %11
%53 = uitofp i32 %52 to double
%54 = load i32, i32* %14
%55 = uitofp i32 %54 to double
%56 = fsub double %55, 1.000000e+00
%57 = call double @llvm.fmuladd.f64(double %56, double 5.000000e-01, double %53)
%58 = fsub double %57, 1.000000e+00
%59 = load i32, i32* %10
%60 = uitofp i32 %59 to double
%61 = fdiv double %58, %60
%62 = load double*, double** %7
%63 = load i32, i32* %13
%64 = add i32 %63, 2
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds double, double* %62, i64 %65
store double %61, double* %66
%67 = load i32, i32* %11
%68 = load i32, i32* %14
%69 = uitofp i32 %68 to double
%70 = fmul double %69, 5.000000e-01
%71 = call i64 @ceil(double %70)
%72 = trunc i64 %71 to i32
%73 = add i32 %67, %72
store i32 %73, i32* %11
%74 = load double, double* %12
%75 = load double, double* %8
%76 = fmul double %74, %75
store double %76, double* %12
br label %77
77: ; preds = %30
%78 = load i32, i32* %13
%79 = add i32 %78, 1
store i32 %79, i32* %13
br label %26
80: ; preds = %26
%81 = load i32, i32* %11
%82 = sub i32 %81, 1
%83 = load i32*, i32** %6
%84 = load i32, i32* %9
%85 = shl i32 %84, 1
%86 = add i32 %85, 0
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %83, i64 %87
store i32 %82, i32* %88
%89 = load i32, i32* %10
%90 = load i32*, i32** %6
%91 = load i32, i32* %9
%92 = shl i32 %91, 1
%93 = add i32 %92, 1
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %90, i64 %94
store i32 %89, i32* %95
%96 = load i32, i32* %11
%97 = load i32, i32* %10
%98 = add i32 %96, %97
%99 = uitofp i32 %98 to double
%100 = call double @llvm.fmuladd.f64(double %99, double 5.000000e-01, double -1.000000e+00)
%101 = load i32, i32* %10
%102 = uitofp i32 %101 to double
%103 = fdiv double %100, %102
%104 = load double*, double** %7
%105 = load i32, i32* %9
%106 = add i32 2, %105
%107 = zext i32 %106 to i64
%108 = getelementptr inbounds double, double* %104, i64 %107
store double %103, double* %108
%109 = load i32, i32* %10
%110 = uitofp i32 %109 to double
%111 = fsub double %110, 1.000000e+00
%112 = load i32, i32* %10
%113 = uitofp i32 %112 to double
%114 = fdiv double %111, %113
%115 = load double*, double** %7
%116 = load i32, i32* %9
%117 = add i32 2, %116
%118 = add i32 %117, 1
%119 = zext i32 %118 to i64
%120 = getelementptr inbounds double, double* %115, i64 %119
store double %114, double* %120
ret void
}

LLVM IR (-O2):
define void @initInterpolationList(i32* nocapture writeonly %0, double* nocapture writeonly %1, double %2, i32 %3, i32 %4) {
%6 = uitofp i32 %4 to double
%7 = insertelement <2 x double> poison, double %6, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = fdiv <2 x double> <double 0.000000e+00, double 1.000000e+00>, %8
%10 = bitcast double* %1 to <2 x double>*
store <2 x double> %9, <2 x double>* %10
%11 = icmp eq i32 %3, 0
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = zext i32 %3 to i64
br label %35
14: ; preds = %35, %5
%15 = phi i32 [ 3, %5 ], [ %62, %35 ]
%16 = add i32 %15, -1
%17 = shl i32 %3, 1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %16, i32* %19
%20 = or i32 %17, 1
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %0, i64 %21
store i32 %4, i32* %22
%23 = add i32 %15, %4
%24 = uitofp i32 %23 to double
%25 = tail call double @llvm.fmuladd.f64(double %24, double 5.000000e-01, double -1.000000e+00)
%26 = fdiv double %25, %6
%27 = add i32 %3, 2
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds double, double* %1, i64 %28
store double %26, double* %29
%30 = fadd double %6, -1.000000e+00
%31 = fdiv double %30, %6
%32 = add i32 %3, 3
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds double, double* %1, i64 %33
store double %31, double* %34
ret void
35: ; preds = %12, %35
%36 = phi i64 [ 0, %12 ], [ %64, %35 ]
%37 = phi i32 [ 3, %12 ], [ %62, %35 ]
%38 = phi double [ %2, %12 ], [ %63, %35 ]
%39 = tail call i64 @round(double %38)
%40 = trunc i64 %39 to i32
%41 = add i32 %37, -1
%42 = trunc i64 %36 to i32
%43 = shl i32 %42, 1
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %0, i64 %44
store i32 %41, i32* %45
%46 = add i32 %41, %40
%47 = or i32 %43, 1
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %0, i64 %48
store i32 %46, i32* %49
%50 = uitofp i32 %37 to double
%51 = uitofp i32 %40 to double
%52 = fadd double %51, -1.000000e+00
%53 = tail call double @llvm.fmuladd.f64(double %52, double 5.000000e-01, double %50)
%54 = fadd double %53, -1.000000e+00
%55 = fdiv double %54, %6
%56 = add nuw i64 %36, 2
%57 = and i64 %56, 4294967295
%58 = getelementptr inbounds double, double* %1, i64 %57
store double %55, double* %58
%59 = fmul double %51, 5.000000e-01
%60 = tail call i64 @ceil(double %59)
%61 = trunc i64 %60 to i32
%62 = add i32 %37, %61
%63 = fmul double %38, %2
%64 = add nuw nsw i64 %36, 1
%65 = icmp eq i64 %64, %13
br i1 %65, label %14, label %35
}