#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 printPixelsBW(unsigned char *image, unsigned int *width,
                   unsigned int *height) {
  for (int row = 0; row < *height; row++) {
    for (int col = 0; col < *width; col++) {
      printf("%d ", image[col]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printPixelsBW>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jae    1194 <printPixelsBW+0x84>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jae    1178 <printPixelsBW+0x68>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <printPixelsBW+0x31>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <printPixelsBW+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPixelsBW>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpl   $0x0,(%rdx)
je     118c <printPixelsBW+0x6c>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xec0(%rip),%r12
xor    %r13d,%r13d
jmp    1163 <printPixelsBW+0x43>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
cmp    (%r14),%r13d
jae    118c <printPixelsBW+0x6c>
cmpl   $0x0,(%rbx)
je     1150 <printPixelsBW+0x30>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r15,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
mov    (%rbx),%eax
cmp    %rax,%rbp
jb     1170 <printPixelsBW+0x50>
jmp    1150 <printPixelsBW+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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