#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 drawLevel(char level[40][20], int snakePos[1][2]) {
  int currentRow;
  int currentCol;
  for (currentCol = 0; currentCol < 20; currentCol++) {
    for (currentRow = 0; currentRow < 40; currentRow++) {
      if (snakePos[0][0] == currentRow && snakePos[0][1] == currentCol) {
        printf("%c", 'O');
      } else {
        printf("%c", level[currentRow][currentCol]);
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<drawLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    11cd <drawLevel+0xbd>
movl   $0x0,-0x14(%rbp)
cmpl   $0x28,-0x14(%rbp)
jge    11b1 <drawLevel+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    1179 <drawLevel+0x69>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
cmp    -0x18(%rbp),%eax
jne    1179 <drawLevel+0x69>
lea    0xe98(%rip),%rdi
mov    $0x4f,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <drawLevel+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a3 <drawLevel+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <drawLevel+0x28>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1127 <drawLevel+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawLevel>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
xor    %r15d,%r15d
jmp    1148 <drawLevel+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x1,%r14
cmp    $0x14,%r15
je     1182 <drawLevel+0x72>
mov    %r14,%r13
xor    %ebx,%ebx
jmp    1168 <drawLevel+0x58>
nop
movsbl 0x0(%r13),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
add    $0x14,%r13
cmp    $0x28,%rbx
je     1130 <drawLevel+0x20>
mov    (%r12),%eax
cmp    %rax,%rbx
jne    1150 <drawLevel+0x40>
mov    0x4(%r12),%eax
mov    $0x4f,%edi
cmp    %rax,%r15
jne    1150 <drawLevel+0x40>
jmp    1155 <drawLevel+0x45>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @drawLevel([20 x i8]* nocapture %0, [2 x i32]* nocapture %1) {
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %5
5: ; preds = %2, %25
%6 = phi i64 [ 0, %2 ], [ %27, %25 ]
br label %7
7: ; preds = %5, %20
%8 = phi i64 [ 0, %5 ], [ %23, %20 ]
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = icmp eq i64 %8, %10
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* %4
%14 = zext i32 %13 to i64
%15 = icmp eq i64 %6, %14
br i1 %15, label %20, label %16
16: ; preds = %12, %7
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %0, i64 %8, i64 %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
br label %20
20: ; preds = %12, %16
%21 = phi i32 [ %19, %16 ], [ 79, %12 ]
%22 = tail call i32 @putchar(i32 %21)
%23 = add nuw nsw i64 %8, 1
%24 = icmp eq i64 %23, 40
br i1 %24, label %25, label %7
25: ; preds = %20
%26 = tail call i32 @putchar(i32 10)
%27 = add nuw nsw i64 %6, 1
%28 = icmp eq i64 %27, 20
br i1 %28, label %29, label %5
29: ; preds = %25
ret void
}