#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 cos(double);
double log2(int);
double *build_fullres_curve(int black) {
  static double fullres_curve[1 << 20];
  static int previous_black = -1;
  if (previous_black == black)
    return fullres_curve;
  previous_black = black;
  const double fullres_start = 4;
  const double fullres_transition = 4;
  for (int i = 0; i < (1 << 20); i++) {
    double ev2 = log2(
        (((i / 64.0 - black / 64.0) > (1)) ? (i / 64.0 - black / 64.0) : (1)));
    double c2 = -cos((((((((ev2 - fullres_start)) < ((fullres_transition)))
                             ? ((ev2 - fullres_start))
                             : ((fullres_transition)))) > ((0)))
                          ? (((((ev2 - fullres_start)) < ((fullres_transition)))
                                  ? ((ev2 - fullres_start))
                                  : ((fullres_transition))))
                          : ((0))) *
                     M_PI / fullres_transition);
    double f = (c2 + 1) / 2;
    fullres_curve[i] = f;
  }
  return fullres_curve;
}


x86 assembly (clang, -O0):
<build_fullres_curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    0x2eff(%rip),%eax
cmp    -0xc(%rbp),%eax
jne    114a <build_fullres_curve+0x2a>
lea    0x2f0f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1365 <build_fullres_curve+0x245>
mov    -0xc(%rbp),%eax
mov    %eax,0x2edd(%rip)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x100000,-0x24(%rbp)
jge    135a <build_fullres_curve+0x23a>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe71(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe59(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e9 <build_fullres_curve+0xc9>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe39(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11fb <build_fullres_curve+0xdb>
movsd  0xe17(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11fb <build_fullres_curve+0xdb>
movsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  0xde5(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xdd9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    124c <build_fullres_curve+0x12c>
movsd  -0x30(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    125e <build_fullres_curve+0x13e>
movsd  0xdac(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    125e <build_fullres_curve+0x13e>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12cf <build_fullres_curve+0x1af>
movsd  -0x30(%rbp),%xmm1
movsd  0xd83(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xd77(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ae <build_fullres_curve+0x18e>
movsd  -0x30(%rbp),%xmm0
movsd  0xd60(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12c0 <build_fullres_curve+0x1a0>
movsd  0xd4a(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12c0 <build_fullres_curve+0x1a0>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12dc <build_fullres_curve+0x1bc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12dc <build_fullres_curve+0x1bc>
movsd  -0x60(%rbp),%xmm0
mov    0x2d00(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xd0c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xce7(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xcea(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movslq -0x24(%rbp),%rcx
lea    0x2d09(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <build_fullres_curve+0x54>
lea    0x2cef(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_fullres_curve>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    %edi,0x2f01(%rip)
je     11de <build_fullres_curve+0xbe>
mov    %edi,0x2ef5(%rip)
cvtsi2sd %edi,%xmm0
mulsd  0xeb9(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2efc(%rip),%r14
xor    %ebx,%ebx
mov    0x2e8b(%rip),%r15
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe91(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  0xe8b(%rip),%xmm1
maxsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log2@plt>
addsd  0xe7e(%rip),%xmm0
minsd  0xe7e(%rip),%xmm0
maxsd  0xe8e(%rip),%xmm0
mulsd  (%r15),%xmm0
mulsd  0xe71(%rip),%xmm0
call   1040 <cos@plt>
movsd  0xe4c(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe60(%rip),%xmm1
movsd  %xmm1,(%r14)
add    $0x1,%rbx
add    $0x8,%r14
cmp    $0x100000,%rbx
jne    1160 <build_fullres_curve+0x40>
lea    0x2e6b(%rip),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@build_fullres_curve.fullres_curve = internal global [1048576 x double] zeroinitializer
@build_fullres_curve.previous_black = internal global i32 -1
@M_PI = global double 0.000000e+00
define double* @build_fullres_curve(i32 %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %3
%10 = load i32, i32* @build_fullres_curve.previous_black
%11 = load i32, i32* %3
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %1
store double* getelementptr inbounds ([1048576 x double], [1048576 x double]* @build_fullres_curve.fullres_curve, i64 0, i64 0), double** %2
br label %80
14: ; preds = %1
%15 = load i32, i32* %3
store i32 %15, i32* @build_fullres_curve.previous_black
store double 4.000000e+00, double* %4
store double 4.000000e+00, double* %5
store i32 0, i32* %6
br label %16
16: ; preds = %76, %14
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 1048576
br i1 %18, label %19, label %79
19: ; preds = %16
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 6.400000e+01
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to double
%25 = fdiv double %24, 6.400000e+01
%26 = fsub double %22, %25
%27 = fcmp ogt double %26, 1.000000e+00
br i1 %27, label %28, label %36
28: ; preds = %19
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to double
%31 = fdiv double %30, 6.400000e+01
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to double
%34 = fdiv double %33, 6.400000e+01
%35 = fsub double %31, %34
br label %37
36: ; preds = %19
br label %37
37: ; preds = %36, %28
%38 = phi double [ %35, %28 ], [ 1.000000e+00, %36 ]
%39 = fptosi double %38 to i32
%40 = call double @log2(i32 %39)
store double %40, double* %7
%41 = load double, double* %7
%42 = fsub double %41, 4.000000e+00
%43 = fcmp olt double %42, 4.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = load double, double* %7
%46 = fsub double %45, 4.000000e+00
br label %48
47: ; preds = %37
br label %48
48: ; preds = %47, %44
%49 = phi double [ %46, %44 ], [ 4.000000e+00, %47 ]
%50 = fcmp ogt double %49, 0.000000e+00
br i1 %50, label %51, label %61
51: ; preds = %48
%52 = load double, double* %7
%53 = fsub double %52, 4.000000e+00
%54 = fcmp olt double %53, 4.000000e+00
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load double, double* %7
%57 = fsub double %56, 4.000000e+00
br label %59
58: ; preds = %51
br label %59
59: ; preds = %58, %55
%60 = phi double [ %57, %55 ], [ 4.000000e+00, %58 ]
br label %62
61: ; preds = %48
br label %62
62: ; preds = %61, %59
%63 = phi double [ %60, %59 ], [ 0.000000e+00, %61 ]
%64 = load double, double* @M_PI
%65 = fmul double %63, %64
%66 = fdiv double %65, 4.000000e+00
%67 = call double @cos(double %66)
%68 = fneg double %67
store double %68, double* %8
%69 = load double, double* %8
%70 = fadd double %69, 1.000000e+00
%71 = fdiv double %70, 2.000000e+00
store double %71, double* %9
%72 = load double, double* %9
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [1048576 x double], [1048576 x double]* @build_fullres_curve.fullres_curve, i64 0, i64 %74
store double %72, double* %75
br label %76
76: ; preds = %62
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %16
79: ; preds = %16
store double* getelementptr inbounds ([1048576 x double], [1048576 x double]* @build_fullres_curve.fullres_curve, i64 0, i64 0), double** %2
br label %80
80: ; preds = %79, %13
%81 = load double*, double** %2
ret double* %81
}

LLVM IR (-O2):
@build_fullres_curve.fullres_curve = internal global [1048576 x double] zeroinitializer
@build_fullres_curve.previous_black = internal unnamed_addr global i32 -1
@M_PI = global double 0.000000e+00
define double* @build_fullres_curve(i32 %0) {
%2 = load i32, i32* @build_fullres_curve.previous_black
%3 = icmp eq i32 %2, %0
br i1 %3, label %31, label %4
4: ; preds = %1
store i32 %0, i32* @build_fullres_curve.previous_black
%5 = sitofp i32 %0 to double
%6 = fmul double %5, 1.562500e-02
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %29, %7 ]
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 1.562500e-02
%12 = fsub double %11, %6
%13 = fcmp ogt double %12, 1.000000e+00
%14 = select i1 %13, double %12, double 1.000000e+00
%15 = fptosi double %14 to i32
%16 = tail call double @log2(i32 %15)
%17 = fadd double %16, -4.000000e+00
%18 = fcmp olt double %17, 4.000000e+00
%19 = select i1 %18, double %17, double 4.000000e+00
%20 = fcmp ogt double %19, 0.000000e+00
%21 = select i1 %20, double %19, double 0.000000e+00
%22 = load double, double* @M_PI
%23 = fmul double %22, %21
%24 = fmul double %23, 2.500000e-01
%25 = tail call double @cos(double %24)
%26 = fsub double 1.000000e+00, %25
%27 = fmul double %26, 5.000000e-01
%28 = getelementptr inbounds [1048576 x double], [1048576 x double]* @build_fullres_curve.fullres_curve, i64 0, i64 %8
store double %27, double* %28
%29 = add nuw nsw i64 %8, 1
%30 = icmp eq i64 %29, 1048576
br i1 %30, label %31, label %7
31: ; preds = %7, %1
ret double* getelementptr inbounds ([1048576 x double], [1048576 x double]* @build_fullres_curve.fullres_curve, i64 0, i64 0)
}