#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 pretty_print(const int ROWS, const int COLS, int table[ROWS][COLS],
                  const char *X, const char *Y) {
  int i, j;
  printf("  ");
  for (i = 0; i < COLS; i++) {
    printf("%c ", Y[i]);
  }
  printf("\n");
  for (i = 0; i < ROWS; i++) {
    for (j = 0; j < COLS; j++) {
      if (j == 0) {
        printf("%c ", X[i]);
      }
      printf("%d ", table[i][j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<pretty_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x30(%rbp)
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    117a <pretty_print+0x6a>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1146 <pretty_print+0x36>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1228 <pretty_print+0x118>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120c <pretty_print+0xfc>
cmpl   $0x0,-0x28(%rbp)
jne    11d2 <pretty_print+0xc2>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a2 <pretty_print+0x92>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118f <pretty_print+0x7f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbx
mov    %rcx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
mov    %esi,%ebp
mov    %edi,%r14d
mov    %esi,%r15d
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    1187 <pretty_print+0x67>
lea    0xea3(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1170 <pretty_print+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
mov    0x4(%rsp),%ebp
jle    1249 <pretty_print+0x129>
mov    %r14d,%eax
mov    %rax,0x20(%rsp)
lea    0x0(,%r15,4),%rax
mov    %rax,0x18(%rsp)
lea    0xe4d(%rip),%rbx
mov    0x8(%rsp),%r12
xor    %r13d,%r13d
jmp    11ea <pretty_print+0xca>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    0x18(%rsp),%r12
cmp    0x20(%rsp),%r13
je     1249 <pretty_print+0x129>
test   %ebp,%ebp
jle    11d0 <pretty_print+0xb0>
mov    %r13,%rbp
imul   %r15,%rbp
mov    0x10(%rsp),%rax
movsbl (%rax,%r13,1),%esi
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax,%rbp,4),%esi
mov    0x4(%rsp),%ebp
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebp
je     11d0 <pretty_print+0xb0>
mov    $0x1,%r14d
xchg   %ax,%ax
mov    (%r12,%r14,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    1230 <pretty_print+0x110>
jmp    11d0 <pretty_print+0xb0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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