#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 */
typedef int uint8_t;

/* Variables and functions */
int ACS_CKBOARD;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ addch(int);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ move(int, int);
void draw_map(uint8_t map[]) {
  attron(COLOR_PAIR(1));
  int i, j;
  for (i = 0; i < 19; i++) {
    for (j = 0; j < 78; j++) {
      move(2 + i, 1 + j);
      uint8_t val = map[i * 78 + j];
      if (val == 0) {
        addch('.');
      } else if (val == 1) {
        addch('x');
      } else if (val == 2) {
        addch(ACS_CKBOARD);
      } else {
        addch(val);
      }
    }
  }
  attroff(COLOR_PAIR(1));
}


x86 assembly (clang, -O0):
<draw_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x13,-0xc(%rbp)
jge    123b <draw_map+0xeb>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4e,-0x10(%rbp)
jge    1228 <draw_map+0xd8>
mov    -0xc(%rbp),%edi
add    $0x2,%edi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1070 <move@plt>
mov    -0x8(%rbp),%rax
imul   $0x4e,-0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11cd <draw_map+0x7d>
mov    $0x2e,%edi
call   1060 <addch@plt>
jmp    1215 <draw_map+0xc5>
cmpl   $0x1,-0x14(%rbp)
jne    11e6 <draw_map+0x96>
mov    $0x78,%edi
call   1060 <addch@plt>
jmp    1210 <draw_map+0xc0>
cmpl   $0x2,-0x14(%rbp)
jne    1203 <draw_map+0xb3>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1060 <addch@plt>
jmp    120b <draw_map+0xbb>
mov    -0x14(%rbp),%edi
call   1060 <addch@plt>
jmp    1210 <draw_map+0xc0>
jmp    1215 <draw_map+0xc5>
jmp    121a <draw_map+0xca>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <draw_map+0x35>
jmp    122d <draw_map+0xdd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <draw_map+0x24>
mov    $0x1,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
xor    %r15d,%r15d
mov    0x2e6f(%rip),%r12
jmp    1191 <draw_map+0x41>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x138,%r14
cmp    $0x13,%r15
je     11e7 <draw_map+0x97>
lea    0x2(%r15),%r13d
xor    %ebp,%ebp
jmp    11af <draw_map+0x5f>
nopl   0x0(%rax)
mov    (%r12),%edi
call   1060 <addch@plt>
cmp    $0x4e,%rbp
je     1180 <draw_map+0x30>
mov    %rbp,%rbx
add    $0x1,%rbp
mov    %r13d,%edi
mov    %ebp,%esi
call   1070 <move@plt>
mov    (%r14,%rbx,4),%edi
test   %edi,%edi
je     11e0 <draw_map+0x90>
cmp    $0x2,%edi
je     11a0 <draw_map+0x50>
cmp    $0x1,%edi
jne    11a4 <draw_map+0x54>
mov    $0x78,%edi
jmp    11a4 <draw_map+0x54>
nopl   0x0(%rax)
mov    $0x2e,%edi
jmp    11a4 <draw_map+0x54>
mov    $0x1,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <attroff@plt>

LLVM IR (-O0):
@ACS_CKBOARD = global i32 0
define void @draw_map(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = call i32 @COLOR_PAIR(i32 1)
%7 = call i32 @attron(i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %54, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 19
br i1 %10, label %11, label %57
11: ; preds = %8
store i32 0, i32* %4
br label %12
12: ; preds = %50, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 78
br i1 %14, label %15, label %53
15: ; preds = %12
%16 = load i32, i32* %3
%17 = add nsw i32 2, %16
%18 = load i32, i32* %4
%19 = add nsw i32 1, %18
%20 = call i32 @move(i32 %17, i32 %19)
%21 = load i32*, i32** %2
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 78
%24 = load i32, i32* %4
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %21, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %15
%32 = call i32 @addch(i32 46)
br label %49
33: ; preds = %15
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @addch(i32 120)
br label %48
38: ; preds = %33
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @ACS_CKBOARD
%43 = call i32 @addch(i32 %42)
br label %47
44: ; preds = %38
%45 = load i32, i32* %5
%46 = call i32 @addch(i32 %45)
br label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %47, %36
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %12
53: ; preds = %12
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %8
57: ; preds = %8
%58 = call i32 @COLOR_PAIR(i32 1)
%59 = call i32 @attroff(i32 %58)
ret void
}

LLVM IR (-O2):
@ACS_CKBOARD = global i32 0
define void @draw_map(i32* nocapture %0) {
%2 = tail call i32 @COLOR_PAIR(i32 1)
%3 = tail call i32 @attron(i32 %2)
br label %4
4: ; preds = %1, %25
%5 = phi i64 [ 0, %1 ], [ %26, %25 ]
%6 = mul nuw nsw i64 %5, 78
%7 = trunc i64 %5 to i32
%8 = add i32 %7, 2
br label %9
9: ; preds = %4, %21
%10 = phi i64 [ 0, %4 ], [ %11, %21 ]
%11 = add nuw nsw i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = tail call i32 @move(i32 %8, i32 %12)
%14 = add nuw nsw i64 %10, %6
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
switch i32 %16, label %20 [
i32 0, label %21
i32 1, label %17
i32 2, label %18
]
17: ; preds = %9
br label %21
18: ; preds = %9
%19 = load i32, i32* @ACS_CKBOARD
br label %21
20: ; preds = %9
br label %21
21: ; preds = %9, %17, %20, %18
%22 = phi i32 [ 120, %17 ], [ %16, %20 ], [ %19, %18 ], [ 46, %9 ]
%23 = tail call i32 @addch(i32 %22)
%24 = icmp eq i64 %11, 78
br i1 %24, label %25, label %9
25: ; preds = %21
%26 = add nuw nsw i64 %5, 1
%27 = icmp eq i64 %26, 19
br i1 %27, label %28, label %4
28: ; preds = %25
%29 = tail call i32 @COLOR_PAIR(i32 1)
%30 = tail call i32 @attroff(i32 %29)
ret void
}