#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 *, int, int, ...);
int printppm(int **img, int x, int y) {
  int i, j;
  printf("P3\n%d %d\n256\n", x, y);
  for (i = 0; i < x; i++)
    for (j = 0; j < y; j++)
      printf("%d %d %d\n", img[i][j] % 256, img[i][j] % 256, img[i][j] % 256);
  return 0;
}


x86 assembly (clang, -O0):
<printppm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e6 <printppm+0xd6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d3 <printppm+0xc3>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x1c(%rbp),%edx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1150 <printppm+0x40>
jmp    11d8 <printppm+0xc8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <printppm+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printppm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r13
lea    0xed9(%rip),%rdi
mov    %edx,0x4(%rsp)
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jle    11a4 <printppm+0x94>
mov    %ebp,%r15d
mov    0x4(%rsp),%ebp
lea    0xeca(%rip),%r12
xor    %ebx,%ebx
jmp    1159 <printppm+0x49>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r15,%rbx
je     11a4 <printppm+0x94>
cmpl   $0x0,0x4(%rsp)
jle    1150 <printppm+0x40>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r14,4),%ecx
lea    0xff(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xffffff00,%eax
sub    %eax,%ecx
mov    %r12,%rdi
mov    %ecx,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1170 <printppm+0x60>
jmp    1150 <printppm+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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