#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*/ crop(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);
    }
  }
  crop(dct_matrix);
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      block_matrix[i][j] = dct_matrix[i][j];
    }
  }
}


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 <crop@plt>
movl   $0x0,-0x21c(%rbp)
cmpl   $0x8,-0x21c(%rbp)
jge    1264 <DCT+0x144>
movl   $0x0,-0x220(%rbp)
cmpl   $0x8,-0x220(%rbp)
jge    124b <DCT+0x12b>
movslq -0x21c(%rbp),%rcx
lea    -0x210(%rbp),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movslq -0x220(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x21c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x220(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x220(%rbp)
jmp    11ed <DCT+0xcd>
jmp    1250 <DCT+0x130>
mov    -0x21c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x21c(%rbp)
jmp    11d6 <DCT+0xb6>
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 <crop@plt>
cvttpd2dq 0x10(%rsp),%xmm0
cvttpd2dq (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,(%r14)
cvttpd2dq 0x30(%rsp),%xmm0
cvttpd2dq 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x10(%r14)
cvttpd2dq 0x50(%rsp),%xmm0
cvttpd2dq 0x40(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x20(%r14)
cvttpd2dq 0x70(%rsp),%xmm0
cvttpd2dq 0x60(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x30(%r14)
cvttpd2dq 0x90(%rsp),%xmm0
cvttpd2dq 0x80(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x40(%r14)
cvttpd2dq 0xb0(%rsp),%xmm0
cvttpd2dq 0xa0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x50(%r14)
cvttpd2dq 0xd0(%rsp),%xmm0
cvttpd2dq 0xc0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x60(%r14)
cvttpd2dq 0xf0(%rsp),%xmm0
cvttpd2dq 0xe0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x70(%r14)
cvttpd2dq 0x110(%rsp),%xmm0
cvttpd2dq 0x100(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x80(%r14)
cvttpd2dq 0x130(%rsp),%xmm0
cvttpd2dq 0x120(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x90(%r14)
cvttpd2dq 0x150(%rsp),%xmm0
cvttpd2dq 0x140(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xa0(%r14)
cvttpd2dq 0x170(%rsp),%xmm0
cvttpd2dq 0x160(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xb0(%r14)
cvttpd2dq 0x190(%rsp),%xmm0
cvttpd2dq 0x180(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xc0(%r14)
cvttpd2dq 0x1b0(%rsp),%xmm0
cvttpd2dq 0x1a0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xd0(%r14)
cvttpd2dq 0x1d0(%rsp),%xmm0
cvttpd2dq 0x1c0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xe0(%r14)
cvttpd2dq 0x1f0(%rsp),%xmm0
cvttpd2dq 0x1e0(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movupd %xmm1,0xf0(%r14)
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
%6 = alloca i32
%7 = alloca i32
store [8 x i32]* %0, [8 x i32]** %2
store i32 0, i32* %4
br label %8
8: ; preds = %31, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %34
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %27, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %30
15: ; preds = %12
%16 = load [8 x i32]*, [8 x i32]** %2
%17 = bitcast [8 x i32]* %16 to i32**
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call double @spatial_to_frequency(i32** %17, i32 %18, i32 %19)
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %3, i64 0, i64 %22
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x double], [8 x double]* %23, i64 0, i64 %25
store double %20, double* %26
br label %27
27: ; preds = %15
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %12
30: ; preds = %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %8
34: ; preds = %8
%35 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %3, i64 0, i64 0
%36 = bitcast [8 x double]* %35 to double**
%37 = call i32 @crop(double** %36)
store i32 0, i32* %6
br label %38
38: ; preds = %65, %34
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 8
br i1 %40, label %41, label %68
41: ; preds = %38
store i32 0, i32* %7
br label %42
42: ; preds = %61, %41
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 8
br i1 %44, label %45, label %64
45: ; preds = %42
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %3, i64 0, i64 %47
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [8 x double], [8 x double]* %48, i64 0, i64 %50
%52 = load double, double* %51
%53 = fptosi double %52 to i32
%54 = load [8 x i32]*, [8 x i32]** %2
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [8 x i32], [8 x i32]* %54, i64 %56
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [8 x i32], [8 x i32]* %57, i64 0, i64 %59
store i32 %53, i32* %60
br label %61
61: ; preds = %45
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %42
64: ; preds = %42
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %38
68: ; preds = %38
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 @crop(double** %27)
%29 = bitcast [8 x [8 x double]]* %2 to <4 x double>*
%30 = load <4 x double>, <4 x double>* %29
%31 = fptosi <4 x double> %30 to <4 x i32>
%32 = bitcast [8 x i32]* %0 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %32
%33 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 0, i64 4
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 0, i64 4
%35 = bitcast double* %33 to <4 x double>*
%36 = load <4 x double>, <4 x double>* %35
%37 = fptosi <4 x double> %36 to <4 x i32>
%38 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %37, <4 x i32>* %38
%39 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 1, i64 0
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 1, i64 0
%41 = bitcast double* %39 to <4 x double>*
%42 = load <4 x double>, <4 x double>* %41
%43 = fptosi <4 x double> %42 to <4 x i32>
%44 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> %43, <4 x i32>* %44
%45 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 1, i64 4
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 1, i64 4
%47 = bitcast double* %45 to <4 x double>*
%48 = load <4 x double>, <4 x double>* %47
%49 = fptosi <4 x double> %48 to <4 x i32>
%50 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> %49, <4 x i32>* %50
%51 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 2, i64 0
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 2, i64 0
%53 = bitcast double* %51 to <4 x double>*
%54 = load <4 x double>, <4 x double>* %53
%55 = fptosi <4 x double> %54 to <4 x i32>
%56 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> %55, <4 x i32>* %56
%57 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 2, i64 4
%58 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 2, i64 4
%59 = bitcast double* %57 to <4 x double>*
%60 = load <4 x double>, <4 x double>* %59
%61 = fptosi <4 x double> %60 to <4 x i32>
%62 = bitcast i32* %58 to <4 x i32>*
store <4 x i32> %61, <4 x i32>* %62
%63 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 3, i64 0
%64 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 3, i64 0
%65 = bitcast double* %63 to <4 x double>*
%66 = load <4 x double>, <4 x double>* %65
%67 = fptosi <4 x double> %66 to <4 x i32>
%68 = bitcast i32* %64 to <4 x i32>*
store <4 x i32> %67, <4 x i32>* %68
%69 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 3, i64 4
%70 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 3, i64 4
%71 = bitcast double* %69 to <4 x double>*
%72 = load <4 x double>, <4 x double>* %71
%73 = fptosi <4 x double> %72 to <4 x i32>
%74 = bitcast i32* %70 to <4 x i32>*
store <4 x i32> %73, <4 x i32>* %74
%75 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 4, i64 0
%76 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 4, i64 0
%77 = bitcast double* %75 to <4 x double>*
%78 = load <4 x double>, <4 x double>* %77
%79 = fptosi <4 x double> %78 to <4 x i32>
%80 = bitcast i32* %76 to <4 x i32>*
store <4 x i32> %79, <4 x i32>* %80
%81 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 4, i64 4
%82 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 4, i64 4
%83 = bitcast double* %81 to <4 x double>*
%84 = load <4 x double>, <4 x double>* %83
%85 = fptosi <4 x double> %84 to <4 x i32>
%86 = bitcast i32* %82 to <4 x i32>*
store <4 x i32> %85, <4 x i32>* %86
%87 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 5, i64 0
%88 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 5, i64 0
%89 = bitcast double* %87 to <4 x double>*
%90 = load <4 x double>, <4 x double>* %89
%91 = fptosi <4 x double> %90 to <4 x i32>
%92 = bitcast i32* %88 to <4 x i32>*
store <4 x i32> %91, <4 x i32>* %92
%93 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 5, i64 4
%94 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 5, i64 4
%95 = bitcast double* %93 to <4 x double>*
%96 = load <4 x double>, <4 x double>* %95
%97 = fptosi <4 x double> %96 to <4 x i32>
%98 = bitcast i32* %94 to <4 x i32>*
store <4 x i32> %97, <4 x i32>* %98
%99 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 6, i64 0
%100 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 6, i64 0
%101 = bitcast double* %99 to <4 x double>*
%102 = load <4 x double>, <4 x double>* %101
%103 = fptosi <4 x double> %102 to <4 x i32>
%104 = bitcast i32* %100 to <4 x i32>*
store <4 x i32> %103, <4 x i32>* %104
%105 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 6, i64 4
%106 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 6, i64 4
%107 = bitcast double* %105 to <4 x double>*
%108 = load <4 x double>, <4 x double>* %107
%109 = fptosi <4 x double> %108 to <4 x i32>
%110 = bitcast i32* %106 to <4 x i32>*
store <4 x i32> %109, <4 x i32>* %110
%111 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 7, i64 0
%112 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 7, i64 0
%113 = bitcast double* %111 to <4 x double>*
%114 = load <4 x double>, <4 x double>* %113
%115 = fptosi <4 x double> %114 to <4 x i32>
%116 = bitcast i32* %112 to <4 x i32>*
store <4 x i32> %115, <4 x i32>* %116
%117 = getelementptr inbounds [8 x [8 x double]], [8 x [8 x double]]* %2, i64 0, i64 7, i64 4
%118 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 7, i64 4
%119 = bitcast double* %117 to <4 x double>*
%120 = load <4 x double>, <4 x double>* %119
%121 = fptosi <4 x double> %120 to <4 x i32>
%122 = bitcast i32* %118 to <4 x i32>*
store <4 x i32> %121, <4 x i32>* %122
ret void
}