#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 cos(double);
unsigned int updateSplane(unsigned int order, double *QValsList) {
  unsigned int pairs = order >> 1;
  unsigned int oddPoles = order & 1;
  double poleInc = 3.14159265358979323846 / (double)order;
  double firstAngle = poleInc;
  unsigned int offset;
  if (!oddPoles) {
    firstAngle = firstAngle / 2.0;
    offset = 0;
  } else {
    QValsList[0] = 0.5;
    offset = 1;
  }
  for (unsigned int idx = 0; idx < pairs; idx++)
    QValsList[offset + idx] = 1.0 / (2.0 * cos(firstAngle + idx * poleInc));
  return pairs + offset;
}


x86 assembly (clang, -O0):
<updateSplane>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shr    %eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  0xec0(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    117f <updateSplane+0x6f>
movsd  -0x28(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
jmp    1196 <updateSplane+0x86>
mov    -0x10(%rbp),%rax
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11ff <updateSplane+0xef>
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0xe38(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe3c(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119d <updateSplane+0x8d>
mov    -0x14(%rbp),%eax
add    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateSplane>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%eax
cvtsi2sd %rax,%xmm0
mov    %rsi,%r12
movsd  0xed0(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
test   $0x1,%dil
jne    114f <updateSplane+0x3f>
movsd  0xec2(%rip),%xmm2
mulsd  %xmm0,%xmm2
xor    %r14d,%r14d
jmp    1167 <updateSplane+0x57>
movabs $0x3fe0000000000000,%rax
mov    %rax,(%r12)
mov    $0x1,%r14d
movapd %xmm0,%xmm2
mov    %edi,%r15d
shr    %r15d
cmp    $0x2,%edi
jb     1290 <updateSplane+0x180>
mov    %r14d,%ebp
cmp    $0x2,%r15d
mov    $0x1,%r13d
cmovae %r15d,%r13d
cmp    $0x4,%edi
jae    119d <updateSplane+0x8d>
xor    %ebx,%ebx
test   $0x1,%r13b
jne    125c <updateSplane+0x14c>
jmp    1290 <updateSplane+0x180>
mov    %r14d,0x14(%rsp)
mov    %r13,0x20(%rsp)
and    $0xfffffffe,%r13d
lea    (%r12,%rbp,8),%r14
add    $0x8,%r14
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
call   1030 <cos@plt>
addsd  %xmm0,%xmm0
movsd  0xe1b(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %rbx,%rax
or     %rbp,%rax
movsd  %xmm1,(%r12,%rax,8)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0x18(%rsp),%xmm2
addsd  %xmm0,%xmm0
movsd  0xddd(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %r13,%rbx
jne    11d0 <updateSplane+0xc0>
mov    0x14(%rsp),%r14d
movsd  0x8(%rsp),%xmm0
mov    0x20(%rsp),%r13
test   $0x1,%r13b
je     1290 <updateSplane+0x180>
mov    %ebx,%eax
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
call   1030 <cos@plt>
addsd  %xmm0,%xmm0
movsd  0xd8d(%rip),%xmm1
divsd  %xmm0,%xmm1
add    %rbx,%rbp
movsd  %xmm1,(%r12,%rbp,8)
add    %r15d,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @updateSplane(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%11 = load i32, i32* %3
%12 = lshr i32 %11, 1
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = and i32 %13, 1
store i32 %14, i32* %6
%15 = load i32, i32* %3
%16 = uitofp i32 %15 to double
%17 = fdiv double 0x400921FB54442D18, %16
store double %17, double* %7
%18 = load double, double* %7
store double %18, double* %8
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %2
%22 = load double, double* %8
%23 = fdiv double %22, 2.000000e+00
store double %23, double* %8
store i32 0, i32* %9
br label %27
24: ; preds = %2
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 0
store double 5.000000e-01, double* %26
store i32 1, i32* %9
br label %27
27: ; preds = %24, %21
store i32 0, i32* %10
br label %28
28: ; preds = %47, %27
%29 = load i32, i32* %10
%30 = load i32, i32* %5
%31 = icmp ult i32 %29, %30
br i1 %31, label %32, label %50
32: ; preds = %28
%33 = load double, double* %8
%34 = load i32, i32* %10
%35 = uitofp i32 %34 to double
%36 = load double, double* %7
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double %33)
%38 = call double @cos(double %37)
%39 = fmul double 2.000000e+00, %38
%40 = fdiv double 1.000000e+00, %39
%41 = load double*, double** %4
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = add i32 %42, %43
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds double, double* %41, i64 %45
store double %40, double* %46
br label %47
47: ; preds = %32
%48 = load i32, i32* %10
%49 = add i32 %48, 1
store i32 %49, i32* %10
br label %28
50: ; preds = %28
%51 = load i32, i32* %5
%52 = load i32, i32* %9
%53 = add i32 %51, %52
ret i32 %53
}

LLVM IR (-O2):
define i32 @updateSplane(i32 %0, double* nocapture writeonly %1) {
%3 = lshr i32 %0, 1
%4 = and i32 %0, 1
%5 = uitofp i32 %0 to double
%6 = fdiv double 0x400921FB54442D18, %5
%7 = icmp eq i32 %4, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = fmul double %6, 5.000000e-01
br label %11
10: ; preds = %2
store double 5.000000e-01, double* %1
br label %11
11: ; preds = %10, %8
%12 = phi double [ %6, %10 ], [ %9, %8 ]
%13 = phi i32 [ 1, %10 ], [ 0, %8 ]
%14 = icmp ult i32 %0, 2
br i1 %14, label %35, label %15
15: ; preds = %11
%16 = zext i32 %13 to i64
%17 = call i32 @llvm.umax.i32(i32 %3, i32 1)
%18 = zext i32 %17 to i64
%19 = and i64 %18, 1
%20 = icmp ult i32 %0, 4
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = and i64 %18, 2147483646
br label %37
23: ; preds = %37, %15
%24 = phi i64 [ 0, %15 ], [ %57, %37 ]
%25 = icmp eq i64 %19, 0
br i1 %25, label %35, label %26
26: ; preds = %23
%27 = trunc i64 %24 to i32
%28 = uitofp i32 %27 to double
%29 = tail call double @llvm.fmuladd.f64(double %28, double %6, double %12)
%30 = tail call double @cos(double %29)
%31 = fmul double %30, 2.000000e+00
%32 = fdiv double 1.000000e+00, %31
%33 = add nuw nsw i64 %24, %16
%34 = getelementptr inbounds double, double* %1, i64 %33
store double %32, double* %34
br label %35
35: ; preds = %26, %23, %11
%36 = add nuw i32 %13, %3
ret i32 %36
37: ; preds = %37, %21
%38 = phi i64 [ 0, %21 ], [ %57, %37 ]
%39 = phi i64 [ 0, %21 ], [ %58, %37 ]
%40 = trunc i64 %38 to i32
%41 = uitofp i32 %40 to double
%42 = tail call double @llvm.fmuladd.f64(double %41, double %6, double %12)
%43 = tail call double @cos(double %42)
%44 = fmul double %43, 2.000000e+00
%45 = fdiv double 1.000000e+00, %44
%46 = or i64 %38, %16
%47 = getelementptr inbounds double, double* %1, i64 %46
store double %45, double* %47
%48 = or i64 %38, 1
%49 = trunc i64 %48 to i32
%50 = uitofp i32 %49 to double
%51 = tail call double @llvm.fmuladd.f64(double %50, double %6, double %12)
%52 = tail call double @cos(double %51)
%53 = fmul double %52, 2.000000e+00
%54 = fdiv double 1.000000e+00, %53
%55 = add nuw nsw i64 %48, %16
%56 = getelementptr inbounds double, double* %1, i64 %55
store double %54, double* %56
%57 = add nuw nsw i64 %38, 2
%58 = add i64 %39, 2
%59 = icmp eq i64 %58, %22
br i1 %59, label %23, label %37
}