#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*/ printf(char *, ...);
void print_dct_coeffs(int num_pixel, int dct[]) {
  int i;
  for (i = 0; i < num_pixel; i++) {
    int j = i;
    while (dct[j++] == 0 && j <= num_pixel)
      if (j % 64 == 0)
        i = j;
    if (i == num_pixel)
      break;
    if (i % 64 == 0)
      printf("\nBlock %2d: ", i / 64);
    printf("%3d ", dct[i]);
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<print_dct_coeffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fb <print_dct_coeffs+0xeb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %eax,%rdx
xor    %eax,%eax
cmpl   $0x0,(%rcx,%rdx,4)
mov    %al,-0x19(%rbp)
jne    1165 <print_dct_coeffs+0x55>
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
setle  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1175 <print_dct_coeffs+0x65>
jmp    1194 <print_dct_coeffs+0x84>
mov    -0x18(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118f <print_dct_coeffs+0x7f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <print_dct_coeffs+0x28>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11a5 <print_dct_coeffs+0x95>
jmp    11fb <print_dct_coeffs+0xeb>
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d4 <print_dct_coeffs+0xc4>
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <print_dct_coeffs+0x16>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_dct_coeffs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11b9 <print_dct_coeffs+0x99>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %edi,%r13d
lea    0xebd(%rip),%r14
lea    0xec3(%rip),%r15
xor    %ebp,%ebp
jmp    1168 <print_dct_coeffs+0x48>
xchg   %ax,%ax
movslq %ebp,%rax
mov    (%rbx,%rax,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
jge    11b9 <print_dct_coeffs+0x99>
movslq %ebp,%rax
cmpl   $0x0,(%rbx,%rax,4)
jne    1197 <print_dct_coeffs+0x77>
cmp    %r12d,%ebp
jge    1197 <print_dct_coeffs+0x77>
add    $0x1,%rax
nopw   0x0(%rax,%rax,1)
test   $0x3f,%al
cmove  %eax,%ebp
cmpl   $0x0,(%rbx,%rax,4)
jne    1197 <print_dct_coeffs+0x77>
lea    0x1(%rax),%rcx
cmp    %r13,%rax
mov    %rcx,%rax
jl     1180 <print_dct_coeffs+0x60>
cmp    %r12d,%ebp
je     11b9 <print_dct_coeffs+0x99>
test   $0x3f,%bpl
jne    1150 <print_dct_coeffs+0x30>
lea    0x3f(%rbp),%esi
test   %ebp,%ebp
cmovns %ebp,%esi
sar    $0x6,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1150 <print_dct_coeffs+0x30>
lea    0xe52(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"\0ABlock %2d: \00"
@.str.1 = [5 x i8] c"%3d \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @print_dct_coeffs(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %54, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %57
11: ; preds = %7
%12 = load i32, i32* %5
store i32 %12, i32* %6
br label %13
13: ; preds = %33, %11
%14 = load i32*, i32** %4
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = load i32, i32* %6
%23 = load i32, i32* %3
%24 = icmp sle i32 %22, %23
br label %25
25: ; preds = %21, %13
%26 = phi i1 [ false, %13 ], [ %24, %21 ]
br i1 %26, label %27, label %34
27: ; preds = %25
%28 = load i32, i32* %6
%29 = srem i32 %28, 64
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* %6
store i32 %32, i32* %5
br label %33
33: ; preds = %31, %27
br label %13
34: ; preds = %25
%35 = load i32, i32* %5
%36 = load i32, i32* %3
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %39
38: ; preds = %34
br label %57
39: ; preds = %34
%40 = load i32, i32* %5
%41 = srem i32 %40, 64
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i32, i32* %5
%45 = sdiv i32 %44, 64
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %43, %39
%48 = load i32*, i32** %4
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %7
57: ; preds = %38, %7
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\0ABlock %2d: \00"
@.str.1 = [5 x i8] c"%3d \00"
@str = [2 x i8] c"\0A\00"
define void @print_dct_coeffs(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %43
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %36
%7 = phi i32 [ %41, %36 ], [ 0, %4 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
%12 = icmp slt i32 %7, %0
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %14, label %27
14: ; preds = %6, %14
%15 = phi i64 [ %17, %14 ], [ %8, %6 ]
%16 = phi i32 [ %21, %14 ], [ %7, %6 ]
%17 = add nsw i64 %15, 1
%18 = trunc i64 %17 to i32
%19 = and i32 %18, 63
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 %18, i32 %16
%22 = getelementptr inbounds i32, i32* %1, i64 %17
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
%25 = icmp slt i64 %17, %5
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %14, label %27
27: ; preds = %14, %6
%28 = phi i32 [ %7, %6 ], [ %21, %14 ]
%29 = icmp eq i32 %28, %0
br i1 %29, label %43, label %30
30: ; preds = %27
%31 = and i32 %28, 63
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = sdiv i32 %28, 64
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30, %33
%37 = sext i32 %28 to i64
%38 = getelementptr inbounds i32, i32* %1, i64 %37
%39 = load i32, i32* %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = add nsw i32 %28, 1
%42 = icmp slt i32 %41, %0
br i1 %42, label %6, label %43
43: ; preds = %36, %27, %2
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}