#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*/ clear();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ toupper(unsigned char);
void tty_showboard(const char *b) {
  int i;
  int line;
  clear();
  move(0, 0);
  line = 0;
  printw("+---+---+---+---+");
  move(++line, 0);
  for (i = 0; i < 16; i++) {
    if (b[i] == 'q')
      printw("| Qu");
    else
      printw("| %c ", toupper((unsigned char)b[i]));
    if ((i + 1) % 4 == 0) {
      printw("|");
      move(++line, 0);
      printw("+---+---+---+---+");
      move(++line, 0);
    }
  }
  move(0, 20);
  printw("Type '?' for help");
  refresh();
}


x86 assembly (clang, -O0):
<tty_showboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <clear@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1070 <move@plt>
movl   $0x0,-0x10(%rbp)
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x10(%rbp)
xor    %esi,%esi
call   1070 <move@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1251 <tty_showboard+0x101>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x71,%eax
jne    11ca <tty_showboard+0x7a>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
jmp    11eb <tty_showboard+0x9b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    123e <tty_showboard+0xee>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x10(%rbp)
xor    %esi,%esi
call   1070 <move@plt>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x10(%rbp)
xor    %esi,%esi
call   1070 <move@plt>
jmp    1243 <tty_showboard+0xf3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1198 <tty_showboard+0x48>
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <move@plt>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tty_showboard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %eax,%eax
call   1060 <clear@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1040 <printw@plt>
mov    $0x1,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    $0x1,%r14d
lea    0xe78(%rip),%r12
lea    0xe7c(%rip),%r13
lea    0xe6f(%rip),%rbp
jmp    11ba <tty_showboard+0x6a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    $0x11,%r14
je     122a <tty_showboard+0xda>
movzbl -0x1(%r15,%r14,1),%eax
cmp    $0x71,%al
jne    11e0 <tty_showboard+0x90>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printw@plt>
test   $0x3,%r14b
jne    11b0 <tty_showboard+0x60>
jmp    11fa <tty_showboard+0xaa>
cs nopw 0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printw@plt>
test   $0x3,%r14b
jne    11b0 <tty_showboard+0x60>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printw@plt>
lea    0x1(%rbx),%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1040 <printw@plt>
add    $0x2,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <move@plt>
jmp    11b0 <tty_showboard+0x60>
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <move@plt>
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1040 <printw@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <refresh@plt>

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

LLVM IR (-O2):
@.str = [18 x i8] c"+---+---+---+---+\00"
@.str.1 = [5 x i8] c"| Qu\00"
@.str.2 = [6 x i8] c"| %c \00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [18 x i8] c"Type '?' for help\00"
define void @tty_showboard(i8* nocapture %0) {
%2 = tail call i32 (...) @clear()
%3 = tail call i32 @move(i32 0, i32 0)
%4 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @move(i32 1, i32 0)
br label %6
6: ; preds = %1, %28
%7 = phi i64 [ 0, %1 ], [ %18, %28 ]
%8 = phi i32 [ 1, %1 ], [ %29, %28 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 113
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %17
14: ; preds = %6
%15 = tail call i32 @toupper(i8 zeroext %10)
%16 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %12
%18 = add nuw nsw i64 %7, 1
%19 = and i64 %18, 3
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = add nsw i32 %8, 1
%24 = tail call i32 @move(i32 %23, i32 0)
%25 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%26 = add nsw i32 %8, 2
%27 = tail call i32 @move(i32 %26, i32 0)
br label %28
28: ; preds = %17, %21
%29 = phi i32 [ %26, %21 ], [ %8, %17 ]
%30 = icmp eq i64 %18, 16
br i1 %30, label %31, label %6
31: ; preds = %28
%32 = tail call i32 @move(i32 0, i32 20)
%33 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i32 (...) @refresh()
ret void
}