#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 /*<<< orphan*/ DCT_to_quant_matrix(double **);
double spatial_to_frequency(int **, int, int);
void DCT(int block_matrix[8][8]) {
  double dct_matrix[8][8];
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      dct_matrix[i][j] = spatial_to_frequency(block_matrix, i, j);
    }
  }
  DCT_to_quant_matrix(dct_matrix);
}


x86 assembly (clang, -O0):
<DCT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x214(%rbp)
cmpl   $0x8,-0x214(%rbp)
jge    11c0 <DCT+0xa0>
movl   $0x0,-0x218(%rbp)
cmpl   $0x8,-0x218(%rbp)
jge    11a7 <DCT+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x214(%rbp),%esi
mov    -0x218(%rbp),%edx
call   1030 <spatial_to_frequency@plt>
movslq -0x214(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movslq -0x218(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x218(%rbp)
jmp    1150 <DCT+0x30>
jmp    11ac <DCT+0x8c>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    1139 <DCT+0x19>
lea    -0x210(%rbp),%rdi
call   1040 <DCT_to_quant_matrix@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DCT>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%r14
lea    0x38(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x38(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x30(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x28(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x20(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x18(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x5,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x10(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x6,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,-0x8(%r15)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x7,%edx
call   1030 <spatial_to_frequency@plt>
movsd  %xmm0,(%r15)
add    $0x1,%rbx
add    $0x40,%r15
cmp    $0x8,%rbx
jne    1140 <DCT+0x20>
mov    %rsp,%rdi
call   1040 <DCT_to_quant_matrix@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @DCT([8 x i32]* %0) {
%2 = alloca [8 x i32]*
%3 = alloca [8 x [8 x double]]
%4 = alloca i32
%5 = alloca i32
store [8 x i32]* %0, [8 x i32]** %2
store i32 0, i32* %4
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %32
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %25, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load [8 x i32]*, [8 x i32]** %2
%15 = bitcast [8 x i32]* %14 to i32**
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call double @spatial_to_frequency(i32** %15, i32 %16, i32 %17)
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %3, i64 0, i64 %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 %23
store double %18, double* %24
br label %25
25: ; preds = %13
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %10
28: ; preds = %10
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %6
32: ; preds = %6
%33 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %3, i64 0, i64 0
%34 = bitcast [8 x double]* %33 to double**
%35 = call i32 @DCT_to_quant_matrix(double** %34)
ret void
}

LLVM IR (-O2):
define void @DCT([8 x i32]* %0) {
%2 = alloca [8 x [8 x double]]
%3 = bitcast [8 x [8 x double]]* %2 to i8*
%4 = bitcast [8 x i32]* %0 to i32**
br label %5
5: ; preds = %1, %5
%6 = phi i64 [ 0, %1 ], [ %24, %5 ]
%7 = trunc i64 %6 to i32
%8 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 0)
%9 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 0
store double %8, double* %9
%10 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 1)
%11 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 1
store double %10, double* %11
%12 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 2)
%13 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 2
store double %12, double* %13
%14 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 3)
%15 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 3
store double %14, double* %15
%16 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 4)
%17 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 4
store double %16, double* %17
%18 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 5)
%19 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 5
store double %18, double* %19
%20 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 6)
%21 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 6
store double %20, double* %21
%22 = tail call double @spatial_to_frequency(i32** %4, i32 %7, i32 7)
%23 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 %6, i64 7
store double %22, double* %23
%24 = add nuw nsw i64 %6, 1
%25 = icmp eq i64 %24, 8
br i1 %25, label %26, label %5
26: ; preds = %5
%27 = bitcast [8 x [8 x double]]* %2 to double**
%28 = call i32 @DCT_to_quant_matrix(double** %27)
ret void
}