#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_block(int, int *, double *);
void dct(int blocks_horiz, int blocks_vert, int in[], double out[]) {
  int h, v;
  for (v = 0; v < blocks_vert; v++)
    for (h = 0; h < blocks_horiz; h++)
      dct_block(8 * blocks_horiz, in + v * blocks_horiz * 64 + h * 8,
                out + (v * blocks_horiz + h) * 64);
}


x86 assembly (clang, -O0):
<dct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <dct+0xa8>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <dct+0x95>
mov    -0x4(%rbp),%edi
shl    $0x3,%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%eax
imul   -0x4(%rbp),%eax
shl    $0x6,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%eax
imul   -0x4(%rbp),%eax
add    -0x1c(%rbp),%eax
shl    $0x6,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1030 <dct_block@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <dct+0x30>
jmp    11aa <dct+0x9a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <dct+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,0x20(%rsp)
mov    %rdi,0x10(%rsp)
test   %esi,%esi
jle    11c1 <dct+0xb1>
mov    %rcx,%r12
mov    0x10(%rsp),%rax
lea    0x0(,%rax,8),%ebp
mov    %esi,%ecx
mov    %rcx,0x28(%rsp)
mov    %eax,%ecx
mov    %rcx,0x18(%rsp)
shl    $0x6,%eax
mov    %eax,0xc(%rsp)
xor    %r15d,%r15d
xor    %eax,%eax
jmp    1175 <dct+0x65>
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsp),%rax
add    $0x1,%rax
add    0xc(%rsp),%r15d
cmp    0x28(%rsp),%rax
je     11c1 <dct+0xb1>
mov    %rax,0x30(%rsp)
cmpl   $0x0,0x10(%rsp)
jle    1160 <dct+0x50>
movslq %r15d,%rax
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
mov    0x18(%rsp),%r14
mov    %r15d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
movslq %r13d,%r13
lea    (%r12,%r13,8),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <dct_block@plt>
add    $0x40,%r13d
add    $0x20,%rbx
add    $0xffffffffffffffff,%r14
jne    11a0 <dct+0x90>
jmp    1160 <dct+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dct(i32 %0, i32 %1, i32* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store double* %3, double** %8
store i32 0, i32* %10
br label %11
11: ; preds = %48, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %51
15: ; preds = %11
store i32 0, i32* %9
br label %16
16: ; preds = %44, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load i32, i32* %5
%22 = mul nsw i32 8, %21
%23 = load i32*, i32** %7
%24 = load i32, i32* %10
%25 = load i32, i32* %5
%26 = mul nsw i32 %24, %25
%27 = mul nsw i32 %26, 64
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %23, i64 %28
%30 = load i32, i32* %9
%31 = mul nsw i32 %30, 8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %29, i64 %32
%34 = load double*, double** %8
%35 = load i32, i32* %10
%36 = load i32, i32* %5
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %9
%39 = add nsw i32 %37, %38
%40 = mul nsw i32 %39, 64
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %34, i64 %41
%43 = call i32 @dct_block(i32 %22, i32* %33, double* %42)
br label %44
44: ; preds = %20
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %16
47: ; preds = %16
br label %48
48: ; preds = %47
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %11
51: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @dct(i32 %0, i32 %1, i32* %2, double* %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %34
6: ; preds = %4
%7 = icmp sgt i32 %0, 0
%8 = shl nsw i32 %0, 3
%9 = zext i32 %1 to i64
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %6, %31
%12 = phi i64 [ 0, %6 ], [ %32, %31 ]
br i1 %7, label %13, label %31
13: ; preds = %11
%14 = trunc i64 %12 to i32
%15 = mul i32 %14, %0
%16 = shl nsw i32 %15, 6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %2, i64 %17
br label %19
19: ; preds = %13, %19
%20 = phi i64 [ 0, %13 ], [ %29, %19 ]
%21 = trunc i64 %20 to i32
%22 = shl nsw i64 %20, 3
%23 = getelementptr inbounds i32, i32* %18, i64 %22
%24 = add nsw i32 %15, %21
%25 = shl nsw i32 %24, 6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %3, i64 %26
%28 = tail call i32 @dct_block(i32 %8, i32* %23, double* %27)
%29 = add nuw nsw i64 %20, 1
%30 = icmp eq i64 %29, %10
br i1 %30, label %31, label %19
31: ; preds = %19, %11
%32 = add nuw nsw i64 %12, 1
%33 = icmp eq i64 %32, %9
br i1 %33, label %34, label %11
34: ; preds = %31, %4
ret void
}