#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 printResult(int printOrder[][2], int numSheet, int numPage) {
  int line, numLine = numSheet << 1, sheet = 1, col;
  printf("Printing order for %d pages:\n", numPage);
  for (line = 0; line < numLine; line++) {
    if (printOrder[line][0] < 0 && printOrder[line][1] < 0)
      continue;
    if (line & 1) {
      printf("Sheet %d, back : ", sheet);
      sheet++;
    } else
      printf("Sheet %d, front: ", sheet);
    for (col = 0; col <= 1; col++) {
      if (printOrder[line][col] < 0)
        printf("Blank");
      else
        printf("%d", printOrder[line][col]);
      if (col)
        printf("\n");
      else
        printf(", ");
    }
  }
}


x86 assembly (clang, -O0):
<printResult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1275 <printResult+0x165>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,8)
jge    1180 <printResult+0x70>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,0x4(%rax,%rcx,8)
jge    1180 <printResult+0x70>
jmp    1267 <printResult+0x157>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ae <printResult+0x9e>
mov    -0x1c(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bf <printResult+0xaf>
mov    -0x1c(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jg     1262 <printResult+0x152>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    1200 <printResult+0xf0>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <printResult+0x114>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
je     1241 <printResult+0x131>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124f <printResult+0x13f>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <printResult+0x144>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c6 <printResult+0xb6>
jmp    1267 <printResult+0x157>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <printResult+0x3a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printResult>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
add    %esi,%ebp
lea    0xec7(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    121c <printResult+0xfc>
mov    %ebp,%r14d
mov    $0x1,%ebp
lea    0xeef(%rip),%r13
xor    %r15d,%r15d
jmp    1181 <printResult+0x61>
xchg   %ax,%ax
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     121c <printResult+0xfc>
cmpl   $0x0,(%rbx,%r15,8)
jns    1190 <printResult+0x70>
cmpl   $0x0,0x4(%rbx,%r15,8)
js     1174 <printResult+0x54>
lea    (%r15,%r15,1),%r12
test   $0x1,%r15b
jne    11b0 <printResult+0x90>
lea    0xe8f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c3 <printResult+0xa3>
nopl   0x0(%rax)
lea    0xe67(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    (%rbx,%r12,4),%esi
test   %esi,%esi
js     11e0 <printResult+0xc0>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ee <printResult+0xce>
nopw   0x0(%rax,%rax,1)
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx,%r15,8),%esi
test   %esi,%esi
jns    1160 <printResult+0x40>
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116a <printResult+0x4a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Printing order for %d pages:\0A\00"
@.str.1 = [18 x i8] c"Sheet %d, back : \00"
@.str.2 = [18 x i8] c"Sheet %d, front: \00"
@.str.3 = [6 x i8] c"Blank\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [3 x i8] c", \00"
define void @printResult([2 x i32]* %0, i32 %1, i32 %2) {
%4 = alloca [2 x i32]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store [2 x i32]* %0, [2 x i32]** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = shl i32 %11, 1
store i32 %12, i32* %8
store i32 1, i32* %9
%13 = load i32, i32* %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %7
br label %15
15: ; preds = %86, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %89
19: ; preds = %15
%20 = load [2 x i32]*, [2 x i32]** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %20, i64 %22
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 0
%25 = load i32, i32* %24
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %19
%28 = load [2 x i32]*, [2 x i32]** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %28, i64 %30
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %31, i64 0, i64 1
%33 = load i32, i32* %32
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %27
br label %86
36: ; preds = %27, %19
%37 = load i32, i32* %7
%38 = and i32 %37, 1
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %9
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %48
45: ; preds = %36
%46 = load i32, i32* %9
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %40
store i32 0, i32* %10
br label %49
49: ; preds = %82, %48
%50 = load i32, i32* %10
%51 = icmp sle i32 %50, 1
br i1 %51, label %52, label %85
52: ; preds = %49
%53 = load [2 x i32]*, [2 x i32]** %4
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %53, i64 %55
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %56, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %52
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %74
64: ; preds = %52
%65 = load [2 x i32]*, [2 x i32]** %4
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %65, i64 %67
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %68, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %64, %62
%75 = load i32, i32* %10
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %81
79: ; preds = %74
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %81
81: ; preds = %79, %77
br label %82
82: ; preds = %81
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %49
85: ; preds = %49
br label %86
86: ; preds = %85, %35
%87 = load i32, i32* %7
%88 = add nsw i32 %87, 1
store i32 %88, i32* %7
br label %15
89: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Printing order for %d pages:\0A\00"
@.str.1 = [18 x i8] c"Sheet %d, back : \00"
@.str.2 = [18 x i8] c"Sheet %d, front: \00"
@.str.3 = [6 x i8] c"Blank\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c", \00"
define void @printResult([2 x i32]* nocapture %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %2)
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %50
7: ; preds = %3
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %46
%10 = phi i64 [ 0, %7 ], [ %48, %46 ]
%11 = phi i32 [ 1, %7 ], [ %47, %46 ]
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 %10, i64 0
%13 = load i32, i32* %12
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 %10, i64 1
%17 = load i32, i32* %16
%18 = icmp slt i32 %17, 0
br i1 %18, label %46, label %19
19: ; preds = %15, %9
%20 = and i64 %10, 1
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%24 = add nsw i32 %11, 1
br label %27
25: ; preds = %19
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %27
27: ; preds = %25, %22
%28 = phi i32 [ %24, %22 ], [ %11, %25 ]
%29 = load i32, i32* %12
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %35
33: ; preds = %27
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %35
35: ; preds = %33, %31
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 %10, i64 1
%38 = load i32, i32* %37
%39 = icmp slt i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %44
42: ; preds = %35
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
%45 = tail call i32 @putchar(i32 10)
br label %46
46: ; preds = %44, %15
%47 = phi i32 [ %11, %15 ], [ %28, %44 ]
%48 = add nuw nsw i64 %10, 1
%49 = icmp eq i64 %48, %8
br i1 %49, label %50, label %9
50: ; preds = %46, %3
ret void
}