#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 atan(double);
double cos(double);
float *dct_coef_addr();
void gencoef() {
  static int iOnceOnly = 0;
  int p, n, i, k;
  double t, pi;
  float *coef32;
  if (!iOnceOnly++) {
    coef32 = dct_coef_addr();
    pi = 4.0 * atan(1.0);
    n = 16;
    k = 0;
    for (i = 0; i < 5; i++, n = n / 2) {
      for (p = 0; p < n; p++, k++) {
        t = (pi / (4 * n)) * (2 * p + 1);
        coef32[k] = (float)(0.50 / cos(t));
      }
    }
  }
}


x86 assembly (clang, -O0):
<gencoef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2efe(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ef3(%rip)
cmp    $0x0,%eax
jne    1240 <gencoef+0x110>
mov    $0x0,%al
call   1040 <dct_coef_addr@plt>
mov    %rax,-0x28(%rbp)
movsd  0xea3(%rip),%xmm0
call   1030 <atan@plt>
movaps %xmm0,%xmm1
movsd  0xe8b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x10,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    123b <gencoef+0x10b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <gencoef+0xea>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe22(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <gencoef+0x74>
jmp    121f <gencoef+0xef>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1193 <gencoef+0x63>
jmp    1240 <gencoef+0x110>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gencoef>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ef8(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2eef(%rip)
test   %eax,%eax
je     1160 <gencoef+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <dct_coef_addr@plt>
mov    %rax,0x8(%rsp)
movsd  0xe89(%rip),%xmm0
call   1030 <atan@plt>
mov    $0x10,%r13d
xor    %ecx,%ecx
jmp    11a8 <gencoef+0x78>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    %r13d,%eax
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
mov    %eax,%r13d
cmp    $0x5,%r15d
je     1151 <gencoef+0x21>
test   %r13d,%r13d
jle    1190 <gencoef+0x60>
lea    0x0(,%r13,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %ecx,0x4(%rsp)
movslq %ecx,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,4),%rbp
mov    %r13d,%ebx
mov    $0x1,%r12d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0xe05(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x0(%rbp,%r14,4)
add    $0x1,%r14
add    $0x2,%r12d
cmp    %r14d,%ebx
jne    11f0 <gencoef+0xc0>
mov    0x4(%rsp),%ecx
add    %r14d,%ecx
jmp    1190 <gencoef+0x60>

LLVM IR (-O0):
@gencoef.iOnceOnly = internal global i32 0
define void @gencoef() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca float*
%8 = load i32, i32* @gencoef.iOnceOnly
%9 = add nsw i32 %8, 1
store i32 %9, i32* @gencoef.iOnceOnly
%10 = icmp ne i32 %8, 0
br i1 %10, label %54, label %11
11: ; preds = %0
%12 = call float* (...) @dct_coef_addr()
store float* %12, float** %7
%13 = call double @atan(double 1.000000e+00)
%14 = fmul double 4.000000e+00, %13
store double %14, double* %6
store i32 16, i32* %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %15
15: ; preds = %48, %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 5
br i1 %17, label %18, label %53
18: ; preds = %15
store i32 0, i32* %1
br label %19
19: ; preds = %42, %18
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %47
23: ; preds = %19
%24 = load double, double* %6
%25 = load i32, i32* %2
%26 = mul nsw i32 4, %25
%27 = sitofp i32 %26 to double
%28 = fdiv double %24, %27
%29 = load i32, i32* %1
%30 = mul nsw i32 2, %29
%31 = add nsw i32 %30, 1
%32 = sitofp i32 %31 to double
%33 = fmul double %28, %32
store double %33, double* %5
%34 = load double, double* %5
%35 = call double @cos(double %34)
%36 = fdiv double 5.000000e-01, %35
%37 = fptrunc double %36 to float
%38 = load float*, float** %7
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
store float %37, float* %41
br label %42
42: ; preds = %23
%43 = load i32, i32* %1
%44 = add nsw i32 %43, 1
store i32 %44, i32* %1
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %19
47: ; preds = %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
%51 = load i32, i32* %2
%52 = sdiv i32 %51, 2
store i32 %52, i32* %2
br label %15
53: ; preds = %15
br label %54
54: ; preds = %53, %0
ret void
}

LLVM IR (-O2):
@gencoef.iOnceOnly = internal unnamed_addr global i32 0
define void @gencoef() {
%1 = load i32, i32* @gencoef.iOnceOnly
%2 = add nsw i32 %1, 1
store i32 %2, i32* @gencoef.iOnceOnly
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %38
4: ; preds = %0
%5 = tail call float* (...) @dct_coef_addr()
%6 = tail call double @atan(double 1.000000e+00)
br label %7
7: ; preds = %4, %33
%8 = phi i32 [ 16, %4 ], [ %36, %33 ]
%9 = phi i32 [ 0, %4 ], [ %35, %33 ]
%10 = phi i32 [ 0, %4 ], [ %34, %33 ]
%11 = icmp sgt i32 %8, 0
br i1 %11, label %12, label %33
12: ; preds = %7
%13 = shl nsw i32 %8, 2
%14 = sitofp i32 %13 to double
%15 = fdiv double 0x400921FB54442D18, %14
%16 = sext i32 %10 to i64
br label %17
17: ; preds = %12, %17
%18 = phi i64 [ %16, %12 ], [ %29, %17 ]
%19 = phi i32 [ 0, %12 ], [ %28, %17 ]
%20 = shl nuw nsw i32 %19, 1
%21 = or i32 %20, 1
%22 = sitofp i32 %21 to double
%23 = fmul double %15, %22
%24 = tail call double @cos(double %23)
%25 = fdiv double 5.000000e-01, %24
%26 = fptrunc double %25 to float
%27 = getelementptr inbounds float, float* %5, i64 %18
store float %26, float* %27
%28 = add nuw nsw i32 %19, 1
%29 = add nsw i64 %18, 1
%30 = icmp eq i32 %28, %8
br i1 %30, label %31, label %17
31: ; preds = %17
%32 = trunc i64 %29 to i32
br label %33
33: ; preds = %31, %7
%34 = phi i32 [ %10, %7 ], [ %32, %31 ]
%35 = add nuw nsw i32 %9, 1
%36 = sdiv i32 %8, 2
%37 = icmp eq i32 %35, 5
br i1 %37, label %38, label %7
38: ; preds = %33, %0
ret void
}