#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_pixel_array(int rows, int cols, char (*pixel_array)[cols]) {
  for (int row = rows - 1; row >= 0; row--) {
    for (int col = 0; col < cols; col++) {
      printf("%c ", pixel_array[row][col]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_pixel_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a2 <print_pixel_array+0x92>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1186 <print_pixel_array+0x76>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <print_pixel_array+0x33>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <print_pixel_array+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pixel_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11aa <print_pixel_array+0x8a>
mov    %rdx,%rbx
mov    0x4(%rsp),%ebp
mov    %edi,%r12d
lea    -0x1(%r12),%rax
imul   %rbp,%rax
add    %rax,%rbx
mov    %rbp,%r13
neg    %r13
lea    0xeaa(%rip),%r15
jmp    117b <print_pixel_array+0x5b>
nopl   0x0(%rax,%rax,1)
lea    -0x1(%r12),%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %r13,%rbx
cmp    $0x1,%r12
mov    %r14,%r12
jle    11aa <print_pixel_array+0x8a>
cmpl   $0x0,0x4(%rsp)
jle    1160 <print_pixel_array+0x40>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx,%r14,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1190 <print_pixel_array+0x70>
jmp    1160 <print_pixel_array+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%c \00"
define void @print_pixel_array(i32 %0, i32 %1, i8* nocapture %2) {
%4 = zext i32 %1 to i64
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %16
%10 = phi i64 [ %8, %6 ], [ %11, %16 ]
%11 = add nsw i64 %10, -1
br i1 %7, label %12, label %16
12: ; preds = %9
%13 = mul nsw i64 %11, %4
%14 = getelementptr inbounds i8, i8* %2, i64 %13
br label %19
15: ; preds = %16, %3
ret void
16: ; preds = %19, %9
%17 = tail call i32 @putchar(i32 10)
%18 = icmp sgt i64 %10, 1
br i1 %18, label %9, label %15
19: ; preds = %12, %19
%20 = phi i64 [ 0, %12 ], [ %25, %19 ]
%21 = getelementptr inbounds i8, i8* %14, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %4
br i1 %26, label %16, label %19
}