#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 */
int cos(double);
int /*<<< orphan*/ modf(double, double *);
void create_dct_matrix(double filter[16][32]) {
  register int i, k;
  for (i = 0; i < 16; i++)
    for (k = 0; k < 32; k++) {
      if ((filter[i][k] = 1e9 * cos((double)((2 * i + 1) * k *
                                             3.14159265358979 / 64))) >= 0)
        modf(filter[i][k] + 0.5, &filter[i][k]);
      else
        modf(filter[i][k] - 0.5, &filter[i][k]);
      filter[i][k] *= 1e-9;
    }
}


x86 assembly (clang, -O0):
<create_dct_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    127e <create_dct_matrix+0x15e>
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    126b <create_dct_matrix+0x14b>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
imul   -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xea9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe95(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe78(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f5 <create_dct_matrix+0xd5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  0xe4c(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1030 <modf@plt>
jmp    1238 <create_dct_matrix+0x118>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe03(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1030 <modf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  0xdcd(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <create_dct_matrix+0x24>
jmp    1270 <create_dct_matrix+0x150>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <create_dct_matrix+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_dct_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
mov    $0x1,%r12d
xor    %r14d,%r14d
movsd  0xec1(%rip),%xmm1
movsd  0xec1(%rip),%xmm2
lea    0xeda(%rip),%r15
xchg   %ax,%ax
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe8d(%rip),%xmm0
xor    %eax,%eax
ucomisd 0xe93(%rip),%xmm0
setb   %al
mov    %r13,%rdi
add    %rbp,%rdi
movsd  %xmm0,0x0(%r13,%rbp,1)
addsd  (%r15,%rax,8),%xmm0
call   1030 <modf@plt>
movsd  0xe68(%rip),%xmm3
movsd  0xe50(%rip),%xmm2
movsd  0xe40(%rip),%xmm1
movsd  0x0(%r13,%rbp,1),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x0(%r13,%rbp,1)
add    %r12d,%ebx
add    $0x8,%rbp
cmp    $0x100,%rbp
jne    1160 <create_dct_matrix+0x40>
add    $0x1,%r14
add    $0x2,%r12d
add    $0x100,%r13
cmp    $0x10,%r14
jne    1150 <create_dct_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @create_dct_matrix([32 x double]* nocapture %0) {
br label %2
2: ; preds = %1, %25
%3 = phi i64 [ 0, %1 ], [ %26, %25 ]
%4 = shl nuw nsw i64 %3, 1
%5 = or i64 %4, 1
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %23, %6 ]
%8 = mul nuw nsw i64 %7, %5
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 0x400921FB54442D11
%12 = fmul double %11, 1.562500e-02
%13 = tail call i32 @cos(double %12)
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.000000e+09
%16 = getelementptr inbounds [32 x double], [32 x double]* %0, i64 %3, i64 %7
store double %15, double* %16
%17 = fcmp ult double %15, 0.000000e+00
%18 = select i1 %17, double -5.000000e-01, double 5.000000e-01
%19 = fadd double %15, %18
%20 = tail call i32 @modf(double %19, double* %16)
%21 = load double, double* %16
%22 = fmul double %21, 1.000000e-09
store double %22, double* %16
%23 = add nuw nsw i64 %7, 1
%24 = icmp eq i64 %23, 32
br i1 %24, label %25, label %6
25: ; preds = %6
%26 = add nuw nsw i64 %3, 1
%27 = icmp eq i64 %26, 16
br i1 %27, label %28, label %2
28: ; preds = %25
ret void
}