#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(short **, short **);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  short pixels[8][8] = {
      {0x0000, 0x008c, 0x00bd, 0x00ee, 0x011f, 0x0150, 0x0181, 0x01b2},
      {0x001b, 0x004c, 0x0133, 0x0164, 0x0195, 0x01c6, 0x01f7, 0x0228},
      {0x0036, 0x00c2, 0x0098, 0x01da, 0x020b, 0x023c, 0x026d, 0x029e},
      {0x0051, 0x0082, 0x010e, 0x00e4, 0x0281, 0x02b2, 0x02e3, 0x0314},
      {0x006c, 0x00f8, 0x0184, 0x015a, 0x0130, 0x0328, 0x0359, 0x038a},
      {0x0087, 0x00b8, 0x00e9, 0x01d0, 0x01a6, 0x017c, 0x03cf, 0x0400},
      {0x00a2, 0x012e, 0x015f, 0x0246, 0x021c, 0x01f2, 0x01c8, 0x0476},
      {0x00bd, 0x00ee, 0x01d5, 0x0150, 0x0292, 0x0268, 0x023e, 0x0214}};
  short data[8][8];
  dct(pixels, data);
  for (int row = 0; row < 8; row++) {
    for (int col = 0; col < 8; col++)
      printf("0x%08x ", data[row][col]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1050 <dct@plt>
movl   $0x0,-0x114(%rbp)
cmpl   $0x8,-0x114(%rbp)
jge    11ff <main+0xcf>
movl   $0x0,-0x118(%rbp)
cmpl   $0x8,-0x118(%rbp)
jge    11dd <main+0xad>
movslq -0x114(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x118(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    118e <main+0x5e>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1177 <main+0x47>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
movaps 0xf2f(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xf10(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xef1(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
lea    0x80(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <dct@plt>
lea    0xeb7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movswl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x2(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x4(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x6(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x8(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0xa(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0xc(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0xe(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rbx
cmp    $0x80,%rbx
jne    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.pixels = [8 x [8 x i16]] [[8 x i16] [i16 0, i16 140, i16 189, i16 238, i16 287, i16 336, i16 385, i16 434], [8 x i16] [i16 27, i16 76, i16 307, i16 356, i16 405, i16 454, i16 503, i16 552], [8 x i16] [i16 54, i16 194, i16 152, i16 474, i16 523, i16 572, i16 621, i16 670], [8 x i16] [i16 81, i16 130, i16 270, i16 228, i16 641, i16 690, i16 739, i16 788], [8 x i16] [i16 108, i16 248, i16 388, i16 346, i16 304, i16 808, i16 857, i16 906], [8 x i16] [i16 135, i16 184, i16 233, i16 464, i16 422, i16 380, i16 975, i16 1024], [8 x i16] [i16 162, i16 302, i16 351, i16 582, i16 540, i16 498, i16 456, i16 1142], [8 x i16] [i16 189, i16 238, i16 469, i16 336, i16 658, i16 616, i16 574, i16 532]]
@.str = [8 x i8] c"0x%08x \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x [8 x i16]]
%3 = alloca [8 x [8 x i16]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [8 x [8 x i16]]* %2 to i8*
%7 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 0
%8 = bitcast [8 x i16]* %7 to i16**
%9 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %3, i64 0, i64 0
%10 = bitcast [8 x i16]* %9 to i16**
%11 = call i32 @dct(i16** %8, i16** %10)
store i32 0, i32* %4
br label %12
12: ; preds = %34, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %37
15: ; preds = %12
store i32 0, i32* %5
br label %16
16: ; preds = %29, %15
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %3, i64 0, i64 %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [8 x i16], [8 x i16]* %22, i64 0, i64 %24
%26 = load i16, i16* %25
%27 = sext i16 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %19
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %16
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %12
37: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.pixels = [8 x [8 x i16]] [[8 x i16] [i16 0, i16 140, i16 189, i16 238, i16 287, i16 336, i16 385, i16 434], [8 x i16] [i16 27, i16 76, i16 307, i16 356, i16 405, i16 454, i16 503, i16 552], [8 x i16] [i16 54, i16 194, i16 152, i16 474, i16 523, i16 572, i16 621, i16 670], [8 x i16] [i16 81, i16 130, i16 270, i16 228, i16 641, i16 690, i16 739, i16 788], [8 x i16] [i16 108, i16 248, i16 388, i16 346, i16 304, i16 808, i16 857, i16 906], [8 x i16] [i16 135, i16 184, i16 233, i16 464, i16 422, i16 380, i16 975, i16 1024], [8 x i16] [i16 162, i16 302, i16 351, i16 582, i16 540, i16 498, i16 456, i16 1142], [8 x i16] [i16 189, i16 238, i16 469, i16 336, i16 658, i16 616, i16 574, i16 532]]
@.str = [8 x i8] c"0x%08x \00"
define i32 @main() {
%1 = alloca [8 x [8 x i16]]
%2 = alloca [8 x [8 x i16]]
%3 = bitcast [8 x [8 x i16]]* %1 to i8*
%4 = bitcast [8 x [8 x i16]]* %2 to i8*
%5 = bitcast [8 x [8 x i16]]* %1 to i16**
%6 = bitcast [8 x [8 x i16]]* %2 to i16**
%7 = call i32 @dct(i16** %5, i16** %6)
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %43, %8 ]
%10 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 0
%11 = load i16, i16* %10
%12 = sext i16 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 1
%15 = load i16, i16* %14
%16 = sext i16 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 2
%19 = load i16, i16* %18
%20 = sext i16 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 3
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 4
%27 = load i16, i16* %26
%28 = sext i16 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 5
%31 = load i16, i16* %30
%32 = sext i16 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 6
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [8 x [8 x i16]], [8 x [8 x i16]]* %2, i64 0, i64 %9, i64 7
%39 = load i16, i16* %38
%40 = sext i16 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = call i32 @putchar(i32 10)
%43 = add nuw nsw i64 %9, 1
%44 = icmp eq i64 %43, 8
br i1 %44, label %45, label %8
45: ; preds = %8
ret i32 0
}