#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);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_up_one_table(int);
double sqrt(double);
int main(int argc, char *argv[]) {
  int length_log;
  int i;
  int k;
  int dct_size;
  double scale;
  dct_size = 640;
  length_log = 0;
  while ((dct_size & 1) == 0) {
    length_log++;
    dct_size >>= 1;
  }
  scale = sqrt(2.0 / 640);
  printf("static const float max_dct_core_a[] =\n");
  printf("{\n");
  for (k = 0; k < 10; ++k) {
    for (i = 0; i < 10; ++i) {
      printf("    %22.15ef%s\n",
             cos(3.141592653589793238462 * (k + 0.5) * (i + 0.5) / 10.0) *
                 scale,
             (k == 9 && i == 9) ? "" : ",");
    }
  }
  printf("};\n\n");
  scale = sqrt(2.0 / (640 >> 1));
  printf("static const float dct_core_a[] =\n");
  printf("{\n");
  for (k = 0; k < 10; ++k) {
    for (i = 0; i < 10; ++i) {
      printf("    %22.15ef%s\n",
             cos(3.141592653589793238462 * (k + 0.5) * (i + 0.5) / 10.0) *
                 scale,
             (k == 9 && i == 9) ? "" : ",");
    }
  }
  printf("};\n\n");
  for (i = 0; i <= length_log; i++)
    set_up_one_table(dct_size << i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x280,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    118a <main+0x4a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1164 <main+0x24>
movsd  0xe6e(%rip),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    128c <main+0x14c>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    1279 <main+0x139>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe31(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe2d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe14(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdfc(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x1c(%rbp)
mov    %al,-0x29(%rbp)
jne    1240 <main+0x100>
cmpl   $0x9,-0x18(%rbp)
sete   %al
mov    %al,-0x29(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x29(%rbp),%cl
lea    0xe13(%rip),%rsi
lea    0xe12(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
lea    0xdee(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d0 <main+0x90>
jmp    127e <main+0x13e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bf <main+0x7f>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  0xd66(%rip),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    139c <main+0x25c>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    1389 <main+0x249>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xd21(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd1d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xd04(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcec(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x1c(%rbp)
mov    %al,-0x39(%rbp)
jne    1350 <main+0x210>
cmpl   $0x9,-0x18(%rbp)
sete   %al
mov    %al,-0x39(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x39(%rbp),%cl
lea    0xd03(%rip),%rsi
lea    0xd02(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
lea    0xcde(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12e0 <main+0x1a0>
jmp    138e <main+0x24e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12cf <main+0x18f>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     13d8 <main+0x298>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%ecx
shl    %cl,%edi
call   1060 <set_up_one_table@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    13b1 <main+0x271>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xf29(%rip),%rdi
call   1030 <puts@plt>
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
movsd  0xe8b(%rip),%xmm1
movsd  0xe93(%rip),%xmm2
lea    0xf0b(%rip),%r15
lea    0xeb5(%rip),%r12
lea    0xe9e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
addsd  %xmm1,%xmm0
mulsd  0xe57(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%ebx
xorpd  %xmm3,%xmm3
movsd  %xmm3,0x10(%rsp)
mov    %r13d,%ebp
xor    $0x9,%ebp
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  %xmm2,%xmm0
call   1050 <cos@plt>
mulsd  0xe2d(%rip),%xmm0
mov    %ebx,%eax
xor    $0x1,%eax
or     %ebp,%eax
mov    %r12,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm3
movsd  0xe0f(%rip),%xmm0
movsd  0xdf7(%rip),%xmm2
movsd  0xddf(%rip),%xmm1
addsd  %xmm0,%xmm3
add    $0xffffffff,%ebx
jne    11c0 <main+0x80>
movsd  (%rsp),%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0x1,%r13d
cmp    $0xa,%r13d
jne    11a0 <main+0x60>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
movsd  0xd8f(%rip),%xmm1
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
lea    0xdb1(%rip),%r14
nop
movsd  %xmm0,(%rsp)
addsd  %xmm1,%xmm0
mulsd  0xd77(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%ebx
xorpd  %xmm2,%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %r13d,%ebp
xor    $0x9,%ebp
movapd %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0xd4e(%rip),%xmm0
call   1050 <cos@plt>
mulsd  0xd59(%rip),%xmm0
mov    %ebx,%eax
xor    $0x1,%eax
or     %ebp,%eax
mov    %r12,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm2
movsd  0xd2b(%rip),%xmm0
movsd  0xd03(%rip),%xmm1
addsd  %xmm0,%xmm2
add    $0xffffffff,%ebx
jne    12a0 <main+0x160>
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x1,%r13d
cmp    $0xa,%r13d
jne    1280 <main+0x140>
lea    0xd64(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1060 <set_up_one_table@plt>
mov    $0xa,%edi
call   1060 <set_up_one_table@plt>
mov    $0x14,%edi
call   1060 <set_up_one_table@plt>
mov    $0x28,%edi
call   1060 <set_up_one_table@plt>
mov    $0x50,%edi
call   1060 <set_up_one_table@plt>
mov    $0xa0,%edi
call   1060 <set_up_one_table@plt>
mov    $0x140,%edi
call   1060 <set_up_one_table@plt>
mov    $0x280,%edi
call   1060 <set_up_one_table@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"static const float max_dct_core_a[] =\0A\00"
@.str.1 = [3 x i8] c"{\0A\00"
@.str.2 = [16 x i8] c" %22.15ef%s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c",\00"
@.str.5 = [5 x i8] c"};\0A\0A\00"
@.str.6 = [35 x i8] c"static const float dct_core_a[] =\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 640, i32* %9
store i32 0, i32* %6
br label %11
11: ; preds = %15, %2
%12 = load i32, i32* %9
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = load i32, i32* %9
%19 = ashr i32 %18, 1
store i32 %19, i32* %9
br label %11
20: ; preds = %11
%21 = call double @sqrt(double 3.125000e-03)
store double %21, double* %10
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %24
24: ; preds = %58, %20
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %61
27: ; preds = %24
store i32 0, i32* %7
br label %28
28: ; preds = %54, %27
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 10
br i1 %30, label %31, label %57
31: ; preds = %28
%32 = load i32, i32* %8
%33 = sitofp i32 %32 to double
%34 = fadd double %33, 5.000000e-01
%35 = fmul double 0x400921FB54442D18, %34
%36 = load i32, i32* %7
%37 = sitofp i32 %36 to double
%38 = fadd double %37, 5.000000e-01
%39 = fmul double %35, %38
%40 = fdiv double %39, 1.000000e+01
%41 = call double @cos(double %40)
%42 = load double, double* %10
%43 = fmul double %41, %42
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, 9
br i1 %45, label %46, label %49
46: ; preds = %31
%47 = load i32, i32* %7
%48 = icmp eq i32 %47, 9
br label %49
49: ; preds = %46, %31
%50 = phi i1 [ false, %31 ], [ %48, %46 ]
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %43, i8* %52)
br label %54
54: ; preds = %49
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %28
57: ; preds = %28
br label %58
58: ; preds = %57
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %24
61: ; preds = %24
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%63 = call double @sqrt(double 6.250000e-03)
store double %63, double* %10
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %66
66: ; preds = %100, %61
%67 = load i32, i32* %8
%68 = icmp slt i32 %67, 10
br i1 %68, label %69, label %103
69: ; preds = %66
store i32 0, i32* %7
br label %70
70: ; preds = %96, %69
%71 = load i32, i32* %7
%72 = icmp slt i32 %71, 10
br i1 %72, label %73, label %99
73: ; preds = %70
%74 = load i32, i32* %8
%75 = sitofp i32 %74 to double
%76 = fadd double %75, 5.000000e-01
%77 = fmul double 0x400921FB54442D18, %76
%78 = load i32, i32* %7
%79 = sitofp i32 %78 to double
%80 = fadd double %79, 5.000000e-01
%81 = fmul double %77, %80
%82 = fdiv double %81, 1.000000e+01
%83 = call double @cos(double %82)
%84 = load double, double* %10
%85 = fmul double %83, %84
%86 = load i32, i32* %8
%87 = icmp eq i32 %86, 9
br i1 %87, label %88, label %91
88: ; preds = %73
%89 = load i32, i32* %7
%90 = icmp eq i32 %89, 9
br label %91
91: ; preds = %88, %73
%92 = phi i1 [ false, %73 ], [ %90, %88 ]
%93 = zext i1 %92 to i64
%94 = select i1 %92, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %85, i8* %94)
br label %96
96: ; preds = %91
%97 = load i32, i32* %7
%98 = add nsw i32 %97, 1
store i32 %98, i32* %7
br label %70
99: ; preds = %70
br label %100
100: ; preds = %99
%101 = load i32, i32* %8
%102 = add nsw i32 %101, 1
store i32 %102, i32* %8
br label %66
103: ; preds = %66
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %105
105: ; preds = %114, %103
%106 = load i32, i32* %7
%107 = load i32, i32* %6
%108 = icmp sle i32 %106, %107
br i1 %108, label %109, label %117
109: ; preds = %105
%110 = load i32, i32* %9
%111 = load i32, i32* %7
%112 = shl i32 %110, %111
%113 = call i32 @set_up_one_table(i32 %112)
br label %114
114: ; preds = %109
%115 = load i32, i32* %7
%116 = add nsw i32 %115, 1
store i32 %116, i32* %7
br label %105
117: ; preds = %105
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c" %22.15ef%s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c",\00"
@str = [38 x i8] c"static const float max_dct_core_a[] =\00"
@str.9 = [34 x i8] c"static const float dct_core_a[] =\00"
@str.10 = [2 x i8] c"{\00"
@str.11 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
br label %5
5: ; preds = %2, %25
%6 = phi i32 [ 0, %2 ], [ %26, %25 ]
%7 = sitofp i32 %6 to double
%8 = fadd double %7, 5.000000e-01
%9 = fmul double %8, 0x400921FB54442D18
%10 = icmp eq i32 %6, 9
br label %11
11: ; preds = %5, %11
%12 = phi i32 [ 0, %5 ], [ %23, %11 ]
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 5.000000e-01
%15 = fmul double %9, %14
%16 = fdiv double %15, 1.000000e+01
%17 = tail call double @cos(double %16)
%18 = fmul double %17, 0x3FAC9F25C5BFEDD9
%19 = icmp eq i32 %12, 9
%20 = select i1 %10, i1 %19, i1 false
%21 = select i1 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %18, i8* %21)
%23 = add nuw nsw i32 %12, 1
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %11
25: ; preds = %11
%26 = add nuw nsw i32 %6, 1
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %5
28: ; preds = %25
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
br label %32
32: ; preds = %28, %52
%33 = phi i32 [ 0, %28 ], [ %53, %52 ]
%34 = sitofp i32 %33 to double
%35 = fadd double %34, 5.000000e-01
%36 = fmul double %35, 0x400921FB54442D18
%37 = icmp eq i32 %33, 9
br label %38
38: ; preds = %32, %38
%39 = phi i32 [ 0, %32 ], [ %50, %38 ]
%40 = sitofp i32 %39 to double
%41 = fadd double %40, 5.000000e-01
%42 = fmul double %36, %41
%43 = fdiv double %42, 1.000000e+01
%44 = tail call double @cos(double %43)
%45 = fmul double %44, 0x3FB43D136248490F
%46 = icmp eq i32 %39, 9
%47 = select i1 %37, i1 %46, i1 false
%48 = select i1 %47, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %45, i8* %48)
%50 = add nuw nsw i32 %39, 1
%51 = icmp eq i32 %50, 10
br i1 %51, label %52, label %38
52: ; preds = %38
%53 = add nuw nsw i32 %33, 1
%54 = icmp eq i32 %53, 10
br i1 %54, label %55, label %32
55: ; preds = %52
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0))
%57 = tail call i32 @set_up_one_table(i32 5)
%58 = tail call i32 @set_up_one_table(i32 10)
%59 = tail call i32 @set_up_one_table(i32 20)
%60 = tail call i32 @set_up_one_table(i32 40)
%61 = tail call i32 @set_up_one_table(i32 80)
%62 = tail call i32 @set_up_one_table(i32 160)
%63 = tail call i32 @set_up_one_table(i32 320)
%64 = tail call i32 @set_up_one_table(i32 640)
ret i32 0
}