#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*/ screentext_clear();
int /*<<< orphan*/ screentext_writecharplace(char, int, int);
void draw_board(int position) {
  screentext_clear();
  int i;
  for (i = 0; i < 20; i++) {
    screentext_writecharplace('#', 10, i);
    screentext_writecharplace('#', 21, i);
  }
  for (i = 0; i < 32; i++) {
    screentext_writecharplace('#', i, 6);
    screentext_writecharplace('#', i, 13);
  }
  switch (position) {
  case 1:
    break;
  case 2:
    break;
  case 3:
    break;
  case 4:
    break;
  case 5:
    break;
  case 6:
    break;
  case 7:
    break;
  case 8:
    for (i = 14; i < 21; i++) {
      screentext_writecharplace('$', i, 13);
    }
    for (i = 13; i < 20; i++) {
      screentext_writecharplace('$', 21, i);
      screentext_writecharplace('$', 10, i);
    }
    break;
  case 9:
    for (i = 21; i < 32; i++) {
      screentext_writecharplace('$', i, 13);
    }
    for (i = 13; i < 20; i++) {
      screentext_writecharplace('$', 21, i);
    }
    break;
  }
}


x86 assembly (clang, -O0):
<draw_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <screentext_clear@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    1175 <draw_board+0x55>
mov    -0x8(%rbp),%edx
mov    $0x23,%edi
mov    $0xa,%esi
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%edx
mov    $0x23,%edi
mov    $0x15,%esi
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <draw_board+0x19>
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    11b8 <draw_board+0x98>
mov    -0x8(%rbp),%esi
mov    $0x23,%edi
mov    $0x6,%edx
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%esi
mov    $0x23,%edi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117c <draw_board+0x5c>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x8,%eax
ja     12e4 <draw_board+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xe28(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
jmp    12e4 <draw_board+0x1c4>
movl   $0xe,-0x8(%rbp)
cmpl   $0x15,-0x8(%rbp)
jge    1235 <draw_board+0x115>
mov    -0x8(%rbp),%esi
mov    $0x24,%edi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    120b <draw_board+0xeb>
movl   $0xd,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    1278 <draw_board+0x158>
mov    -0x8(%rbp),%edx
mov    $0x24,%edi
mov    $0x15,%esi
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%edx
mov    $0x24,%edi
mov    $0xa,%esi
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    123c <draw_board+0x11c>
jmp    12e4 <draw_board+0x1c4>
movl   $0x15,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    12ae <draw_board+0x18e>
mov    -0x8(%rbp),%esi
mov    $0x24,%edi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1284 <draw_board+0x164>
movl   $0xd,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    12df <draw_board+0x1bf>
mov    -0x8(%rbp),%edx
mov    $0x24,%edi
mov    $0x15,%esi
call   1040 <screentext_writecharplace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12b5 <draw_board+0x195>
jmp    12e4 <draw_board+0x1c4>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_board>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <screentext_clear@plt>
xchg   %ax,%ax
mov    $0x23,%edi
mov    $0xa,%esi
mov    %ebp,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x23,%edi
mov    $0x15,%esi
mov    %ebp,%edx
call   1040 <screentext_writecharplace@plt>
add    $0x1,%ebp
cmp    $0x14,%ebp
jne    1130 <draw_board+0x10>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x23,%edi
mov    %ebp,%esi
mov    $0x6,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x23,%edi
mov    %ebp,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
add    $0x1,%ebp
cmp    $0x20,%ebp
jne    1160 <draw_board+0x40>
cmp    $0x9,%ebx
je     1327 <draw_board+0x207>
cmp    $0x8,%ebx
jne    1499 <draw_board+0x379>
mov    $0x24,%edi
mov    $0xe,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xf,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x10,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x11,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x12,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x13,%ebp
mov    $0x24,%edi
mov    $0x13,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x14,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0xa,%ebx
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xe,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0xe,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xf,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0xf,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0x10,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0x10,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0x11,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0x11,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0x12,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0xa,%esi
mov    $0x12,%edx
call   1040 <screentext_writecharplace@plt>
jmp    1471 <draw_board+0x351>
mov    $0x15,%ebx
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x16,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x17,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x18,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x19,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1a,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1b,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1c,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1d,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1e,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x1f,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xd,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xe,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0xf,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0x10,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    $0x15,%esi
mov    $0x11,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x12,%ebp
mov    $0x24,%edi
mov    $0x15,%esi
mov    %ebp,%edx
call   1040 <screentext_writecharplace@plt>
mov    $0x24,%edi
mov    %ebx,%esi
mov    $0x13,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <screentext_writecharplace@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @draw_board(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @screentext_clear()
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @screentext_writecharplace(i8 signext 35, i32 10, i32 %9)
%11 = load i32, i32* %3
%12 = call i32 @screentext_writecharplace(i8 signext 35, i32 21, i32 %11)
br label %13
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
store i32 0, i32* %3
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32, i32* %3
%22 = call i32 @screentext_writecharplace(i8 signext 35, i32 %21, i32 6)
%23 = load i32, i32* %3
%24 = call i32 @screentext_writecharplace(i8 signext 35, i32 %23, i32 13)
br label %25
25: ; preds = %20
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %17
28: ; preds = %17
%29 = load i32, i32* %2
switch i32 %29, label %81 [
i32 1, label %30
i32 2, label %31
i32 3, label %32
i32 4, label %33
i32 5, label %34
i32 6, label %35
i32 7, label %36
i32 8, label %37
i32 9, label %60
]
30: ; preds = %28
br label %81
31: ; preds = %28
br label %81
32: ; preds = %28
br label %81
33: ; preds = %28
br label %81
34: ; preds = %28
br label %81
35: ; preds = %28
br label %81
36: ; preds = %28
br label %81
37: ; preds = %28
store i32 14, i32* %3
br label %38
38: ; preds = %44, %37
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 21
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load i32, i32* %3
%43 = call i32 @screentext_writecharplace(i8 signext 36, i32 %42, i32 13)
br label %44
44: ; preds = %41
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %38
47: ; preds = %38
store i32 13, i32* %3
br label %48
48: ; preds = %56, %47
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 20
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i32, i32* %3
%53 = call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 %52)
%54 = load i32, i32* %3
%55 = call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 %54)
br label %56
56: ; preds = %51
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %48
59: ; preds = %48
br label %81
60: ; preds = %28
store i32 21, i32* %3
br label %61
61: ; preds = %67, %60
%62 = load i32, i32* %3
%63 = icmp slt i32 %62, 32
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i32, i32* %3
%66 = call i32 @screentext_writecharplace(i8 signext 36, i32 %65, i32 13)
br label %67
67: ; preds = %64
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %61
70: ; preds = %61
store i32 13, i32* %3
br label %71
71: ; preds = %77, %70
%72 = load i32, i32* %3
%73 = icmp slt i32 %72, 20
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = load i32, i32* %3
%76 = call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 %75)
br label %77
77: ; preds = %74
%78 = load i32, i32* %3
%79 = add nsw i32 %78, 1
store i32 %79, i32* %3
br label %71
80: ; preds = %71
br label %81
81: ; preds = %28, %80, %59, %36, %35, %34, %33, %32, %31, %30
ret void
}

LLVM IR (-O2):
define void @draw_board(i32 %0) {
%2 = tail call i32 (...) @screentext_clear()
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %7, %3 ]
%5 = tail call i32 @screentext_writecharplace(i8 signext 35, i32 10, i32 %4)
%6 = tail call i32 @screentext_writecharplace(i8 signext 35, i32 21, i32 %4)
%7 = add nuw nsw i32 %4, 1
%8 = icmp eq i32 %7, 20
br i1 %8, label %9, label %3
9: ; preds = %3, %9
%10 = phi i32 [ %13, %9 ], [ 0, %3 ]
%11 = tail call i32 @screentext_writecharplace(i8 signext 35, i32 %10, i32 6)
%12 = tail call i32 @screentext_writecharplace(i8 signext 35, i32 %10, i32 13)
%13 = add nuw nsw i32 %10, 1
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %9
15: ; preds = %9
switch i32 %0, label %58 [
i32 9, label %36
i32 8, label %16
]
16: ; preds = %15
%17 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 14, i32 13)
%18 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 15, i32 13)
%19 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 16, i32 13)
%20 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 17, i32 13)
%21 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 18, i32 13)
%22 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 19, i32 13)
%23 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 20, i32 13)
%24 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 13)
%25 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 13)
%26 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 14)
%27 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 14)
%28 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 15)
%29 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 15)
%30 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 16)
%31 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 16)
%32 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 17)
%33 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 17)
%34 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 18)
%35 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 10, i32 18)
br label %53
36: ; preds = %15
%37 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 13)
%38 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 22, i32 13)
%39 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 23, i32 13)
%40 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 24, i32 13)
%41 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 25, i32 13)
%42 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 26, i32 13)
%43 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 27, i32 13)
%44 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 28, i32 13)
%45 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 29, i32 13)
%46 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 30, i32 13)
%47 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 31, i32 13)
%48 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 13)
%49 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 14)
%50 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 15)
%51 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 16)
%52 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 17)
br label %53
53: ; preds = %36, %16
%54 = phi i32 [ 19, %16 ], [ 18, %36 ]
%55 = phi i32 [ 10, %16 ], [ 21, %36 ]
%56 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 21, i32 %54)
%57 = tail call i32 @screentext_writecharplace(i8 signext 36, i32 %55, i32 19)
br label %58
58: ; preds = %53, %15
ret void
}