#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 */
typedef size_t uint8_t;
typedef size_t int32_t;

/* Variables and functions */
double sqrt(double);
int32_t qtz_ref_cof(double *par, uint8_t ord, int32_t *q_ref) {
  for (int32_t i = 0; i < ord; i++) {
    if (i == 0)
      q_ref[i] = 64 * (-1 + 1.41421356237 * sqrt(par[i] + 1));
    else if (i == 1)
      q_ref[i] = 64 * (-1 + 1.41421356237 * sqrt(-par[i] + 1));
    else
      q_ref[i] = 64 * par[i];
  }
  return (0);
}


x86 assembly (clang, -O0):
<qtz_ref_cof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    12a8 <qtz_ref_cof+0x198>
cmpq   $0x0,-0x20(%rbp)
jne    11be <qtz_ref_cof+0xae>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xeb6(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  0xead(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe7d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,%rcx
sar    $0x3f,%rcx
movsd  0xe6a(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1292 <qtz_ref_cof+0x182>
cmpq   $0x1,-0x20(%rbp)
jne    1242 <qtz_ref_cof+0x132>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xe32(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  0xe29(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,%rcx
sar    $0x3f,%rcx
movsd  0xde6(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    128d <qtz_ref_cof+0x17d>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xda9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdx
mov    %rdx,%rcx
sar    $0x3f,%rcx
movsd  0xd96(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1292 <qtz_ref_cof+0x182>
jmp    1297 <qtz_ref_cof+0x187>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <qtz_ref_cof+0x1c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qtz_ref_cof>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     129a <qtz_ref_cof+0x18a>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
movsd  0xecc(%rip),%xmm1
xorpd  %xmm2,%xmm2
movsd  0xec8(%rip),%xmm3
movsd  0xec8(%rip),%xmm4
movsd  0xec8(%rip),%xmm5
movsd  0xec8(%rip),%xmm6
jmp    1196 <qtz_ref_cof+0x86>
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
mulsd  %xmm5,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
subsd  %xmm6,%xmm0
cvttsd2si %xmm0,%rdx
sar    $0x3f,%rcx
and    %rcx,%rdx
or     %rax,%rdx
mov    %rdx,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     129a <qtz_ref_cof+0x18a>
cmp    $0x1,%rbx
je     11c0 <qtz_ref_cof+0xb0>
test   %rbx,%rbx
jne    1160 <qtz_ref_cof+0x50>
movsd  (%r15),%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11d9 <qtz_ref_cof+0xc9>
sqrtsd %xmm0,%xmm0
jmp    120a <qtz_ref_cof+0xfa>
cs nopw 0x0(%rax,%rax,1)
movapd %xmm1,%xmm0
subsd  0x8(%r15),%xmm0
ucomisd %xmm2,%xmm0
jb     1239 <qtz_ref_cof+0x129>
sqrtsd %xmm0,%xmm0
jmp    126a <qtz_ref_cof+0x15a>
call   1030 <sqrt@plt>
movsd  0xe3a(%rip),%xmm6
movsd  0xe2a(%rip),%xmm5
movsd  0xe1a(%rip),%xmm4
movsd  0xe0a(%rip),%xmm3
xorpd  %xmm2,%xmm2
movsd  0xdf6(%rip),%xmm1
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
subsd  %xmm6,%xmm0
cvttsd2si %xmm0,%rdx
sar    $0x3f,%rcx
and    %rcx,%rdx
or     %rax,%rdx
mov    %rdx,(%r14)
jmp    1189 <qtz_ref_cof+0x79>
call   1030 <sqrt@plt>
movsd  0xdda(%rip),%xmm6
movsd  0xdca(%rip),%xmm5
movsd  0xdba(%rip),%xmm4
movsd  0xdaa(%rip),%xmm3
xorpd  %xmm2,%xmm2
movsd  0xd96(%rip),%xmm1
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
subsd  %xmm6,%xmm0
cvttsd2si %xmm0,%rdx
sar    $0x3f,%rcx
and    %rcx,%rdx
or     %rax,%rdx
mov    %rdx,0x8(%r14)
jmp    1189 <qtz_ref_cof+0x79>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @qtz_ref_cof(double* %0, i64 %1, i64* %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i64
store double* %0, double** %4
store i64 %1, i64* %5
store i64* %2, i64** %6
store i64 0, i64* %7
br label %8
8: ; preds = %57, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %60
12: ; preds = %8
%13 = load i64, i64* %7
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load double*, double** %4
%17 = load i64, i64* %7
%18 = getelementptr inbounds double, double* %16, i64 %17
%19 = load double, double* %18
%20 = fadd double %19, 1.000000e+00
%21 = call double @sqrt(double %20)
%22 = call double @llvm.fmuladd.f64(double 0x3FF6A09E667F055A, double %21, double -1.000000e+00)
%23 = fmul double 6.400000e+01, %22
%24 = fptoui double %23 to i64
%25 = load i64*, i64** %6
%26 = load i64, i64* %7
%27 = getelementptr inbounds i64, i64* %25, i64 %26
store i64 %24, i64* %27
br label %56
28: ; preds = %12
%29 = load i64, i64* %7
%30 = icmp eq i64 %29, 1
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load double*, double** %4
%33 = load i64, i64* %7
%34 = getelementptr inbounds double, double* %32, i64 %33
%35 = load double, double* %34
%36 = fneg double %35
%37 = fadd double %36, 1.000000e+00
%38 = call double @sqrt(double %37)
%39 = call double @llvm.fmuladd.f64(double 0x3FF6A09E667F055A, double %38, double -1.000000e+00)
%40 = fmul double 6.400000e+01, %39
%41 = fptoui double %40 to i64
%42 = load i64*, i64** %6
%43 = load i64, i64* %7
%44 = getelementptr inbounds i64, i64* %42, i64 %43
store i64 %41, i64* %44
br label %55
45: ; preds = %28
%46 = load double*, double** %4
%47 = load i64, i64* %7
%48 = getelementptr inbounds double, double* %46, i64 %47
%49 = load double, double* %48
%50 = fmul double 6.400000e+01, %49
%51 = fptoui double %50 to i64
%52 = load i64*, i64** %6
%53 = load i64, i64* %7
%54 = getelementptr inbounds i64, i64* %52, i64 %53
store i64 %51, i64* %54
br label %55
55: ; preds = %45, %31
br label %56
56: ; preds = %55, %15
br label %57
57: ; preds = %56
%58 = load i64, i64* %7
%59 = add i64 %58, 1
store i64 %59, i64* %7
br label %8
60: ; preds = %8
ret i64 0
}

LLVM IR (-O2):
define i64 @qtz_ref_cof(double* nocapture %0, i64 %1, i64* nocapture writeonly %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = getelementptr inbounds i64, i64* %2, i64 1
br label %9
8: ; preds = %31, %3
ret i64 0
9: ; preds = %5, %31
%10 = phi i64 [ 0, %5 ], [ %32, %31 ]
switch i64 %10, label %25 [
i64 0, label %11
i64 1, label %18
]
11: ; preds = %9
%12 = load double, double* %0
%13 = fadd double %12, 1.000000e+00
%14 = tail call double @sqrt(double %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double 0x3FF6A09E667F055A, double -1.000000e+00)
%16 = fmul double %15, 6.400000e+01
%17 = fptoui double %16 to i64
store i64 %17, i64* %2
br label %31
18: ; preds = %9
%19 = load double, double* %6
%20 = fsub double 1.000000e+00, %19
%21 = tail call double @sqrt(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0x3FF6A09E667F055A, double -1.000000e+00)
%23 = fmul double %22, 6.400000e+01
%24 = fptoui double %23 to i64
store i64 %24, i64* %7
br label %31
25: ; preds = %9
%26 = getelementptr inbounds double, double* %0, i64 %10
%27 = load double, double* %26
%28 = fmul double %27, 6.400000e+01
%29 = fptoui double %28 to i64
%30 = getelementptr inbounds i64, i64* %2, i64 %10
store i64 %29, i64* %30
br label %31
31: ; preds = %11, %25, %18
%32 = add nuw i64 %10, 1
%33 = icmp eq i64 %32, %1
br i1 %33, label %8, label %9
}