#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_double(int num_pixel, double 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("%3.0f ", dct[i]);
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<print_dct_coeffs_double>:
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    120b <print_dct_coeffs_double+0xfb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jne    1173 <print_dct_coeffs_double+0x63>
jp     1173 <print_dct_coeffs_double+0x63>
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
setle  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1183 <print_dct_coeffs_double+0x73>
jmp    11a2 <print_dct_coeffs_double+0x92>
mov    -0x18(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119d <print_dct_coeffs_double+0x8d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <print_dct_coeffs_double+0x28>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11b3 <print_dct_coeffs_double+0xa3>
jmp    120b <print_dct_coeffs_double+0xfb>
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e2 <print_dct_coeffs_double+0xd2>
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe17(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <print_dct_coeffs_double+0x16>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_dct_coeffs_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11e0 <print_dct_coeffs_double+0xc0>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %edi,%r13d
xorpd  %xmm1,%xmm1
lea    0xeb9(%rip),%r14
lea    0xebf(%rip),%r15
xor    %ebp,%ebp
jmp    117e <print_dct_coeffs_double+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ebp,%rax
movsd  (%rbx,%rax,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
xorpd  %xmm1,%xmm1
jge    11e0 <print_dct_coeffs_double+0xc0>
movslq %ebp,%rax
movsd  (%rbx,%rax,8),%xmm0
ucomisd %xmm1,%xmm0
jne    11be <print_dct_coeffs_double+0x9e>
jp     11be <print_dct_coeffs_double+0x9e>
cmp    %r12d,%ebp
jge    11be <print_dct_coeffs_double+0x9e>
add    $0x1,%rax
nopw   0x0(%rax,%rax,1)
test   $0x3f,%al
cmove  %eax,%ebp
movsd  (%rbx,%rax,8),%xmm0
ucomisd %xmm1,%xmm0
jne    11be <print_dct_coeffs_double+0x9e>
jp     11be <print_dct_coeffs_double+0x9e>
lea    0x1(%rax),%rcx
cmp    %r13,%rax
mov    %rcx,%rax
jl     11a0 <print_dct_coeffs_double+0x80>
cmp    %r12d,%ebp
je     11e0 <print_dct_coeffs_double+0xc0>
test   $0x3f,%bpl
jne    1160 <print_dct_coeffs_double+0x40>
lea    0x3f(%rbp),%esi
test   %ebp,%ebp
cmovns %ebp,%esi
sar    $0x6,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <print_dct_coeffs_double+0x40>
lea    0xe2d(%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 = [7 x i8] c"%3.0f \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @print_dct_coeffs_double(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %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 double*, double** %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 double, double* %14, i64 %17
%19 = load double, double* %18
%20 = fcmp oeq double %19, 0.000000e+00
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 double*, double** %4
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %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 = [7 x i8] c"%3.0f \00"
@str = [2 x i8] c"\0A\00"
define void @print_dct_coeffs_double(i32 %0, double* 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 double, double* %1, i64 %8
%10 = load double, double* %9
%11 = fcmp oeq double %10, 0.000000e+00
%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 double, double* %1, i64 %17
%23 = load double, double* %22
%24 = fcmp oeq double %23, 0.000000e+00
%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 double, double* %1, i64 %37
%39 = load double, double* %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %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
}