#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 /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ system(char *);
void printGrid(char grid[21][21]) {
  int x, y, middleRow, middleColumn;
  system("cls");
  for (x = 0; x < (21 + 2); ++x)
    putchar('-');
  putchar('\n');
  middleRow = (21 - 1) / 2;
  middleColumn = (21 - 1) / 2;
  for (y = 0; y < 21; y++) {
    putchar('|');
    for (x = 0; x < 21; x++) {
      if ((x == middleColumn) && (y == middleRow))
        putchar('P');
      else
        putchar(grid[x][y]);
    }
    printf("|\n");
  }
  for (x = 0; x < (21 + 2); ++x)
    putchar('_');
  putchar('\n');
  return;
}


x86 assembly (clang, -O0):
<printGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x17,-0xc(%rbp)
jge    1171 <printGrid+0x41>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <printGrid+0x1f>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0xa,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x15,-0x10(%rbp)
jge    1225 <printGrid+0xf5>
mov    $0x7c,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x15,-0xc(%rbp)
jge    120b <printGrid+0xdb>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11dc <printGrid+0xac>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11dc <printGrid+0xac>
mov    $0x50,%edi
call   1030 <putchar@plt>
jmp    11f8 <printGrid+0xc8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    11fd <printGrid+0xcd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <printGrid+0x7b>
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1190 <printGrid+0x60>
movl   $0x0,-0xc(%rbp)
cmpl   $0x17,-0xc(%rbp)
jge    124e <printGrid+0x11e>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    122c <printGrid+0xfc>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGrid>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xebe(%rip),%rdi
call   1050 <system@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r12d,%r12d
lea    0xdc3(%rip),%r14
jmp    1266 <printGrid+0x136>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x1,%r12
add    $0x1,%r15
cmp    $0x15,%r12
je     12ad <printGrid+0x17d>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    $0xffffffffffffff2e,%rbx
jmp    129e <printGrid+0x16e>
nopl   0x0(%rax)
movzbl 0xd2(%r15,%rbx,1),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x15,%rbx
cmp    $0xe7,%rbx
je     1250 <printGrid+0x120>
test   %rbx,%rbx
jne    1280 <printGrid+0x150>
mov    $0x50,%al
cmp    $0xa,%r12
je     1289 <printGrid+0x159>
jmp    1280 <printGrid+0x150>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0x5f,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@str = [2 x i8] c"|\00"
define void @printGrid([21 x i8]* nocapture %0) {
%2 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @putchar(i8 signext 45)
%4 = tail call i32 @putchar(i8 signext 45)
%5 = tail call i32 @putchar(i8 signext 45)
%6 = tail call i32 @putchar(i8 signext 45)
%7 = tail call i32 @putchar(i8 signext 45)
%8 = tail call i32 @putchar(i8 signext 45)
%9 = tail call i32 @putchar(i8 signext 45)
%10 = tail call i32 @putchar(i8 signext 45)
%11 = tail call i32 @putchar(i8 signext 45)
%12 = tail call i32 @putchar(i8 signext 45)
%13 = tail call i32 @putchar(i8 signext 45)
%14 = tail call i32 @putchar(i8 signext 45)
%15 = tail call i32 @putchar(i8 signext 45)
%16 = tail call i32 @putchar(i8 signext 45)
%17 = tail call i32 @putchar(i8 signext 45)
%18 = tail call i32 @putchar(i8 signext 45)
%19 = tail call i32 @putchar(i8 signext 45)
%20 = tail call i32 @putchar(i8 signext 45)
%21 = tail call i32 @putchar(i8 signext 45)
%22 = tail call i32 @putchar(i8 signext 45)
%23 = tail call i32 @putchar(i8 signext 45)
%24 = tail call i32 @putchar(i8 signext 45)
%25 = tail call i32 @putchar(i8 signext 45)
%26 = tail call i32 @putchar(i8 signext 10)
br label %27
27: ; preds = %1, %43
%28 = phi i64 [ 0, %1 ], [ %45, %43 ]
%29 = tail call i32 @putchar(i8 signext 124)
%30 = icmp eq i64 %28, 10
br label %31
31: ; preds = %27, %38
%32 = phi i64 [ 0, %27 ], [ %41, %38 ]
%33 = icmp eq i64 %32, 10
%34 = select i1 %33, i1 %30, i1 false
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = getelementptr inbounds [21 x i8], [21 x i8]* %0, i64 %32, i64 %28
%37 = load i8, i8* %36
br label %38
38: ; preds = %31, %35
%39 = phi i8 [ %37, %35 ], [ 80, %31 ]
%40 = tail call i32 @putchar(i8 signext %39)
%41 = add nuw nsw i64 %32, 1
%42 = icmp eq i64 %41, 21
br i1 %42, label %43, label %31
43: ; preds = %38
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%45 = add nuw nsw i64 %28, 1
%46 = icmp eq i64 %45, 21
br i1 %46, label %47, label %27
47: ; preds = %43
%48 = tail call i32 @putchar(i8 signext 95)
%49 = tail call i32 @putchar(i8 signext 95)
%50 = tail call i32 @putchar(i8 signext 95)
%51 = tail call i32 @putchar(i8 signext 95)
%52 = tail call i32 @putchar(i8 signext 95)
%53 = tail call i32 @putchar(i8 signext 95)
%54 = tail call i32 @putchar(i8 signext 95)
%55 = tail call i32 @putchar(i8 signext 95)
%56 = tail call i32 @putchar(i8 signext 95)
%57 = tail call i32 @putchar(i8 signext 95)
%58 = tail call i32 @putchar(i8 signext 95)
%59 = tail call i32 @putchar(i8 signext 95)
%60 = tail call i32 @putchar(i8 signext 95)
%61 = tail call i32 @putchar(i8 signext 95)
%62 = tail call i32 @putchar(i8 signext 95)
%63 = tail call i32 @putchar(i8 signext 95)
%64 = tail call i32 @putchar(i8 signext 95)
%65 = tail call i32 @putchar(i8 signext 95)
%66 = tail call i32 @putchar(i8 signext 95)
%67 = tail call i32 @putchar(i8 signext 95)
%68 = tail call i32 @putchar(i8 signext 95)
%69 = tail call i32 @putchar(i8 signext 95)
%70 = tail call i32 @putchar(i8 signext 95)
%71 = tail call i32 @putchar(i8 signext 10)
ret void
}