#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 *, double, ...);
int /*<<< orphan*/ putchar(char);
void print_mnist_pixel(double data_image[][784], int num_data) {
  int i, j;
  for (i = 0; i < num_data; i++) {
    printf("image %d/%d\n", i + 1, num_data);
    for (j = 0; j < 784; j++) {
      printf("%1.1f ", data_image[i][j]);
      if ((j + 1) % 28 == 0)
        putchar('\n');
    }
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<print_mnist_pixel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e6 <print_mnist_pixel+0xc6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0xc(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x310,-0x14(%rbp)
jge    11ce <print_mnist_pixel+0xae>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x1880,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bb <print_mnist_pixel+0x9b>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c0 <print_mnist_pixel+0xa0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <print_mnist_pixel+0x44>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <print_mnist_pixel+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mnist_pixel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    11f9 <print_mnist_pixel+0xd9>
mov    %rdi,%rbx
mov    0x4(%rsp),%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
jmp    1171 <print_mnist_pixel+0x51>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1880,%rbx
mov    0x10(%rsp),%rax
cmp    0x8(%rsp),%rax
je     11f9 <print_mnist_pixel+0xd9>
add    $0x1,%rax
mov    %rax,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe78(%rip),%rdi
mov    0x4(%rsp),%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%r14w
xor    %r15d,%r15d
jmp    11ad <print_mnist_pixel+0x8d>
nopl   (%rax)
add    $0x1,%r14d
cmp    $0x310,%r15
je     1150 <print_mnist_pixel+0x30>
mov    %r15,%r12
movzwl %r14w,%eax
shr    $0x2,%eax
imul   $0x4925,%eax,%r13d
shr    $0x11,%r13d
lea    0x0(%r13,%r13,8),%eax
lea    (%rax,%rax,2),%ebp
movsd  (%rbx,%r15,8),%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r15
lea    -0x1(%r13,%rbp,1),%eax
cmp    %r12w,%ax
jne    11a0 <print_mnist_pixel+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <print_mnist_pixel+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"image %d/%d\0A\00"
@.str.1 = [7 x i8] c"%1.1f \00"
define void @print_mnist_pixel([784 x double]* %0, i32 %1) {
%3 = alloca [784 x double]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [784 x double]* %0, [784 x double]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %42, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %7
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
%14 = sitofp i32 %13 to double
%15 = load i32, i32* %4
%16 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %14, i32 %15)
store i32 0, i32* %6
br label %17
17: ; preds = %37, %11
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 784
br i1 %19, label %20, label %40
20: ; preds = %17
%21 = load [784 x double]*, [784 x double]** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [784 x double], [784 x double]* %21, i64 %23
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [784 x double], [784 x double]* %24, i64 0, i64 %26
%28 = load double, double* %27
%29 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = srem i32 %31, 28
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %20
%35 = call i32 @putchar(i8 signext 10)
br label %36
36: ; preds = %34, %20
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %17
40: ; preds = %17
%41 = call i32 @putchar(i8 signext 10)
br label %42
42: ; preds = %40
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %7
45: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"image %d/%d\0A\00"
@.str.1 = [7 x i8] c"%1.1f \00"
define void @print_mnist_pixel([784 x double]* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %25
%7 = phi i64 [ 0, %4 ], [ %8, %25 ]
%8 = add nuw nsw i64 %7, 1
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %10, i32 %1)
br label %12
12: ; preds = %6, %23
%13 = phi i64 [ 0, %6 ], [ %17, %23 ]
%14 = getelementptr inbounds [784 x double], [784 x double]* %0, i64 %7, i64 %13
%15 = load double, double* %14
%16 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = add nuw nsw i64 %13, 1
%18 = trunc i64 %17 to i16
%19 = urem i16 %18, 28
%20 = icmp eq i16 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = tail call i32 @putchar(i8 signext 10)
br label %23
23: ; preds = %12, %21
%24 = icmp eq i64 %17, 784
br i1 %24, label %25, label %12
25: ; preds = %23
%26 = tail call i32 @putchar(i8 signext 10)
%27 = icmp eq i64 %8, %5
br i1 %27, label %28, label %6
28: ; preds = %25, %2
ret void
}