#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*/ check_end(int *);
int /*<<< orphan*/ endwin();
char get_key();
int /*<<< orphan*/ init_scr();
int /*<<< orphan*/ move_tile(int *, char);
int /*<<< orphan*/ place_tile(int *);
int /*<<< orphan*/ print_border();
int /*<<< orphan*/ print_info(int);
int /*<<< orphan*/ print_status(int);
int /*<<< orphan*/ print_tile(int, int);
int main(int argc, char **argv) {
  char key;
  bool changed = false;
  bool reached = false;
  int i;
  int turn;
  int score = 0;
  int tile[16];
  int tile_bak[16];
  init_scr();
  print_border();
start:
  for (i = 0; i < 16; i++)
    tile[i] = 0;
  place_tile(tile);
  place_tile(tile);
  for (i = 0; i < 16; i++)
    print_tile(tile[i], i);
  score = 0;
  print_info(0);
  print_status(score);
  for (turn = 1; !check_end(tile); turn++) {
    for (i = 0; i < 16; i++)
      tile_bak[i] = tile[i];
    if (!reached) {
      for (i = 0; i < 16; i++) {
        if (tile[i] == 2048) {
          print_info(1);
          reached = true;
        }
      }
    } else
      print_info(0);
    key = get_key();
    switch (key) {
    case 'U':
    case 'D':
    case 'R':
    case 'L':
      score += move_tile(tile, key);
      break;
    case 'q':
      goto end;
      break;
    case 'r':
      goto start;
      break;
    case 'h':
      break;
    default:
      break;
    }
    changed = false;
    for (i = 0; i < 16; i++)
      if (tile[i] != tile_bak[i])
        changed = true;
    if (changed)
      place_tile(tile);
    for (i = 0; i < 16; i++)
      print_tile(tile[i], i);
    print_status(score);
  }
  print_info(2);
  while (true) {
    switch (get_key()) {
    case 'q':
      goto end;
    case 'r':
      goto start;
    default:
      continue;
    }
  }
end:
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1090 <init_scr@plt>
mov    $0x0,%al
call   1070 <print_border@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    1207 <main+0x67>
movslq -0x20(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0x43>
lea    -0x70(%rbp),%rdi
call   1050 <place_tile@plt>
lea    -0x70(%rbp),%rdi
call   1050 <place_tile@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    1248 <main+0xa8>
movslq -0x20(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
mov    -0x20(%rbp),%esi
call   1040 <print_tile@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1220 <main+0x80>
movl   $0x0,-0x28(%rbp)
xor    %edi,%edi
call   10c0 <print_info@plt>
mov    -0x28(%rbp),%edi
call   1060 <print_status@plt>
movl   $0x1,-0x24(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <check_end@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1283 <main+0xe3>
jmp    141b <main+0x27b>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    12b5 <main+0x115>
movslq -0x20(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%ecx
movslq -0x20(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    128a <main+0xea>
cmpl   $0x0,-0x1c(%rbp)
jne    130b <main+0x16b>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    1306 <main+0x166>
movslq -0x20(%rbp),%rax
cmpl   $0x800,-0x70(%rbp,%rax,4)
jne    12f3 <main+0x153>
mov    $0x1,%edi
call   10c0 <print_info@plt>
movl   $0x1,-0x1c(%rbp)
jmp    12f8 <main+0x158>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12c6 <main+0x126>
jmp    1312 <main+0x172>
xor    %edi,%edi
call   10c0 <print_info@plt>
xor    %eax,%eax
call   1080 <get_key@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0xb8(%rbp)
sub    $0x2e,%eax
ja     1373 <main+0x1d3>
mov    -0xb8(%rbp),%rax
lea    0xcbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x70(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   10a0 <move_tile@plt>
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1378 <main+0x1d8>
jmp    1466 <main+0x2c6>
jmp    11dc <main+0x3c>
jmp    1378 <main+0x1d8>
jmp    1378 <main+0x1d8>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    13c3 <main+0x223>
movslq -0x20(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
movslq -0x20(%rbp),%rcx
cmp    -0xb0(%rbp,%rcx,4),%eax
je     13b0 <main+0x210>
movl   $0x1,-0x18(%rbp)
jmp    13b5 <main+0x215>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1386 <main+0x1e6>
cmpl   $0x0,-0x18(%rbp)
je     13d6 <main+0x236>
lea    -0x70(%rbp),%rdi
call   1050 <place_tile@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    1405 <main+0x265>
movslq -0x20(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
mov    -0x20(%rbp),%esi
call   1040 <print_tile@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13dd <main+0x23d>
mov    -0x28(%rbp),%edi
call   1060 <print_status@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1265 <main+0xc5>
mov    $0x2,%edi
call   10c0 <print_info@plt>
xor    %eax,%eax
call   1080 <get_key@plt>
movsbl %al,%eax
mov    %eax,-0xbc(%rbp)
sub    $0x71,%eax
je     1457 <main+0x2b7>
jmp    1443 <main+0x2a3>
mov    -0xbc(%rbp),%eax
sub    $0x72,%eax
je     145c <main+0x2bc>
jmp    1461 <main+0x2c1>
jmp    1466 <main+0x2c6>
jmp    11dc <main+0x3c>
jmp    1425 <main+0x285>
mov    $0x0,%al
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
xor    %eax,%eax
call   1090 <init_scr@plt>
xor    %eax,%eax
call   1070 <print_border@plt>
pxor   %xmm0,%xmm0
mov    %rsp,%r15
mov    $0x24101,%r14d
xor    %ebx,%ebx
movdqa %xmm0,0x30(%rsp)
movdqa %xmm0,0x20(%rsp)
movdqa %xmm0,0x10(%rsp)
movdqa %xmm0,(%rsp)
mov    %r15,%rdi
call   1050 <place_tile@plt>
mov    %r15,%rdi
call   1050 <place_tile@plt>
mov    (%rsp),%edi
xor    %esi,%esi
call   1040 <print_tile@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%esi
call   1040 <print_tile@plt>
mov    0x8(%rsp),%edi
mov    $0x2,%esi
call   1040 <print_tile@plt>
mov    0xc(%rsp),%edi
mov    $0x3,%esi
call   1040 <print_tile@plt>
mov    0x10(%rsp),%edi
mov    $0x4,%esi
call   1040 <print_tile@plt>
mov    0x14(%rsp),%edi
mov    $0x5,%esi
call   1040 <print_tile@plt>
mov    0x18(%rsp),%edi
mov    $0x6,%esi
call   1040 <print_tile@plt>
mov    0x1c(%rsp),%edi
mov    $0x7,%esi
call   1040 <print_tile@plt>
mov    0x20(%rsp),%edi
mov    $0x8,%esi
call   1040 <print_tile@plt>
mov    0x24(%rsp),%edi
mov    $0x9,%esi
call   1040 <print_tile@plt>
mov    0x28(%rsp),%edi
mov    $0xa,%esi
call   1040 <print_tile@plt>
mov    0x2c(%rsp),%edi
mov    $0xb,%esi
call   1040 <print_tile@plt>
mov    0x30(%rsp),%edi
mov    $0xc,%esi
call   1040 <print_tile@plt>
mov    0x34(%rsp),%edi
mov    $0xd,%esi
call   1040 <print_tile@plt>
mov    0x38(%rsp),%edi
mov    $0xe,%esi
call   1040 <print_tile@plt>
mov    0x3c(%rsp),%edi
mov    $0xf,%esi
call   1040 <print_tile@plt>
xor    %edi,%edi
call   10c0 <print_info@plt>
xor    %edi,%edi
call   1060 <print_status@plt>
mov    %r15,%rdi
call   1030 <check_end@plt>
test   %eax,%eax
je     1320 <main+0x180>
mov    $0x2,%edi
call   10c0 <print_info@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <get_key@plt>
movsbl %al,%eax
cmp    $0x72,%eax
je     1780 <main+0x5e0>
cmp    $0x71,%eax
jne    1300 <main+0x160>
jmp    1789 <main+0x5e9>
nopl   (%rax)
xor    %ebp,%ebp
jmp    142b <main+0x28b>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <place_tile@plt>
mov    (%rsp),%edi
xor    %esi,%esi
call   1040 <print_tile@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%esi
call   1040 <print_tile@plt>
mov    0x8(%rsp),%edi
mov    $0x2,%esi
call   1040 <print_tile@plt>
mov    0xc(%rsp),%edi
mov    $0x3,%esi
call   1040 <print_tile@plt>
mov    0x10(%rsp),%edi
mov    $0x4,%esi
call   1040 <print_tile@plt>
mov    0x14(%rsp),%edi
mov    $0x5,%esi
call   1040 <print_tile@plt>
mov    0x18(%rsp),%edi
mov    $0x6,%esi
call   1040 <print_tile@plt>
mov    0x1c(%rsp),%edi
mov    $0x7,%esi
call   1040 <print_tile@plt>
mov    0x20(%rsp),%edi
mov    $0x8,%esi
call   1040 <print_tile@plt>
mov    0x24(%rsp),%edi
mov    $0x9,%esi
call   1040 <print_tile@plt>
mov    0x28(%rsp),%edi
mov    $0xa,%esi
call   1040 <print_tile@plt>
mov    0x2c(%rsp),%edi
mov    $0xb,%esi
call   1040 <print_tile@plt>
mov    0x30(%rsp),%edi
mov    $0xc,%esi
call   1040 <print_tile@plt>
mov    0x34(%rsp),%edi
mov    $0xd,%esi
call   1040 <print_tile@plt>
mov    0x38(%rsp),%edi
mov    $0xe,%esi
call   1040 <print_tile@plt>
mov    0x3c(%rsp),%edi
mov    $0xf,%esi
call   1040 <print_tile@plt>
mov    %ebp,%edi
call   1060 <print_status@plt>
mov    %r15,%rdi
call   1030 <check_end@plt>
test   %eax,%eax
jne    12e7 <main+0x147>
movaps (%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x10(%rsp),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x20(%rsp),%xmm0
movaps %xmm0,0x70(%rsp)
movdqa 0x30(%rsp),%xmm0
movdqa %xmm0,0x60(%rsp)
mov    $0x0,%edi
test   %ebx,%ebx
jne    157f <main+0x3df>
movdqa 0x40(%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x800,%eax
jne    148e <main+0x2ee>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
mov    0x4(%rsp),%eax
cmp    $0x800,%eax
je     14a0 <main+0x300>
jmp    14af <main+0x30f>
xor    %ebx,%ebx
pshufd $0x55,%xmm0,%xmm0
movd   %xmm0,%eax
cmp    $0x800,%eax
jne    14af <main+0x30f>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x8(%rsp)
je     160a <main+0x46a>
cmpl   $0x800,0xc(%rsp)
je     1627 <main+0x487>
cmpl   $0x800,0x10(%rsp)
je     1644 <main+0x4a4>
cmpl   $0x800,0x14(%rsp)
je     1661 <main+0x4c1>
cmpl   $0x800,0x18(%rsp)
je     167e <main+0x4de>
cmpl   $0x800,0x1c(%rsp)
je     169b <main+0x4fb>
cmpl   $0x800,0x20(%rsp)
je     16b8 <main+0x518>
cmpl   $0x800,0x24(%rsp)
je     16d5 <main+0x535>
cmpl   $0x800,0x28(%rsp)
je     16f2 <main+0x552>
cmpl   $0x800,0x2c(%rsp)
je     170f <main+0x56f>
cmpl   $0x800,0x30(%rsp)
je     172c <main+0x58c>
cmpl   $0x800,0x34(%rsp)
je     1749 <main+0x5a9>
cmpl   $0x800,0x38(%rsp)
jne    1570 <main+0x3d0>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
mov    $0x1,%edi
cmpl   $0x800,0x3c(%rsp)
jne    1589 <main+0x3e9>
call   10c0 <print_info@plt>
mov    $0x1,%ebx
xor    %eax,%eax
call   1080 <get_key@plt>
movsbl %al,%esi
lea    -0x44(%rsi),%eax
cmp    $0x2e,%eax
ja     15af <main+0x40f>
bt     %rax,%r14
jae    176b <main+0x5cb>
mov    %r15,%rdi
call   10a0 <move_tile@plt>
add    %eax,%ebp
movdqa (%rsp),%xmm0
movdqa 0x40(%rsp),%xmm1
pcmpeqd %xmm0,%xmm1
movdqa 0x50(%rsp),%xmm3
pcmpeqd 0x10(%rsp),%xmm3
movdqa 0x70(%rsp),%xmm2
pcmpeqd 0x20(%rsp),%xmm2
packssdw %xmm3,%xmm1
movdqa 0x60(%rsp),%xmm3
pcmpeqd 0x30(%rsp),%xmm3
packssdw %xmm3,%xmm2
packsswb %xmm2,%xmm1
psllw  $0x7,%xmm1
pmovmskb %xmm1,%eax
cmp    $0xffff,%ax
jne    1330 <main+0x190>
movd   %xmm0,%edi
jmp    133b <main+0x19b>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0xc(%rsp)
jne    14cb <main+0x32b>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x10(%rsp)
jne    14d9 <main+0x339>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x14(%rsp)
jne    14e7 <main+0x347>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x18(%rsp)
jne    14f5 <main+0x355>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x1c(%rsp)
jne    1503 <main+0x363>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x20(%rsp)
jne    1511 <main+0x371>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x24(%rsp)
jne    151f <main+0x37f>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x28(%rsp)
jne    152d <main+0x38d>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x2c(%rsp)
jne    153b <main+0x39b>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x30(%rsp)
jne    1549 <main+0x3a9>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x34(%rsp)
jne    1557 <main+0x3b7>
mov    $0x1,%ebx
mov    $0x1,%edi
call   10c0 <print_info@plt>
cmpl   $0x800,0x38(%rsp)
je     1561 <main+0x3c1>
jmp    1570 <main+0x3d0>
cmp    $0x2d,%rax
je     1789 <main+0x5e9>
cmp    $0x2e,%rax
jne    15af <main+0x40f>
nopl   0x0(%rax,%rax,1)
pxor   %xmm0,%xmm0
jmp    11ca <main+0x2a>
xor    %eax,%eax
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [16 x i32]
%13 = alloca [16 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %11
%14 = call i32 (...) @init_scr()
%15 = call i32 (...) @print_border()
br label %16
16: ; preds = %156, %102, %2
store i32 0, i32* %9
br label %17
17: ; preds = %24, %16
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 16
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %22
store i32 0, i32* %23
br label %24
24: ; preds = %20
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %17
27: ; preds = %17
%28 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%29 = call i32 @place_tile(i32* %28)
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%31 = call i32 @place_tile(i32* %30)
store i32 0, i32* %9
br label %32
32: ; preds = %42, %27
%33 = load i32, i32* %9
%34 = icmp slt i32 %33, 16
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %9
%41 = call i32 @print_tile(i32 %39, i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %32
45: ; preds = %32
store i32 0, i32* %11
%46 = call i32 @print_info(i32 0)
%47 = load i32, i32* %11
%48 = call i32 @print_status(i32 %47)
store i32 1, i32* %10
br label %49
49: ; preds = %147, %45
%50 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%51 = call i32 @check_end(i32* %50)
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
br i1 %53, label %54, label %150
54: ; preds = %49
store i32 0, i32* %9
br label %55
55: ; preds = %66, %54
%56 = load i32, i32* %9
%57 = icmp slt i32 %56, 16
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [16 x i32], [16 x i32]* %13, i64 0, i64 %64
store i32 %62, i32* %65
br label %66
66: ; preds = %58
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %55
69: ; preds = %55
%70 = load i32, i32* %8
%71 = icmp ne i32 %70, 0
br i1 %71, label %89, label %72
72: ; preds = %69
store i32 0, i32* %9
br label %73
73: ; preds = %85, %72
%74 = load i32, i32* %9
%75 = icmp slt i32 %74, 16
br i1 %75, label %76, label %88
76: ; preds = %73
%77 = load i32, i32* %9
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 2048
br i1 %81, label %82, label %84
82: ; preds = %76
%83 = call i32 @print_info(i32 1)
store i32 1, i32* %8
br label %84
84: ; preds = %82, %76
br label %85
85: ; preds = %84
%86 = load i32, i32* %9
%87 = add nsw i32 %86, 1
store i32 %87, i32* %9
br label %73
88: ; preds = %73
br label %91
89: ; preds = %69
%90 = call i32 @print_info(i32 0)
br label %91
91: ; preds = %89, %88
%92 = call signext i8 (...) @get_key()
store i8 %92, i8* %6
%93 = load i8, i8* %6
%94 = sext i8 %93 to i32
switch i32 %94, label %104 [
i32 85, label %95
i32 68, label %95
i32 82, label %95
i32 76, label %95
i32 113, label %101
i32 114, label %102
i32 104, label %103
]
95: ; preds = %91, %91, %91, %91
%96 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%97 = load i8, i8* %6
%98 = call i32 @move_tile(i32* %96, i8 signext %97)
%99 = load i32, i32* %11
%100 = add nsw i32 %99, %98
store i32 %100, i32* %11
br label %105
101: ; preds = %91
br label %158
102: ; preds = %91
br label %16
103: ; preds = %91
br label %105
104: ; preds = %91
br label %105
105: ; preds = %104, %103, %95
store i32 0, i32* %7
store i32 0, i32* %9
br label %106
106: ; preds = %121, %105
%107 = load i32, i32* %9
%108 = icmp slt i32 %107, 16
br i1 %108, label %109, label %124
109: ; preds = %106
%110 = load i32, i32* %9
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %111
%113 = load i32, i32* %112
%114 = load i32, i32* %9
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [16 x i32], [16 x i32]* %13, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = icmp ne i32 %113, %117
br i1 %118, label %119, label %120
119: ; preds = %109
store i32 1, i32* %7
br label %120
120: ; preds = %119, %109
br label %121
121: ; preds = %120
%122 = load i32, i32* %9
%123 = add nsw i32 %122, 1
store i32 %123, i32* %9
br label %106
124: ; preds = %106
%125 = load i32, i32* %7
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %124
%128 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%129 = call i32 @place_tile(i32* %128)
br label %130
130: ; preds = %127, %124
store i32 0, i32* %9
br label %131
131: ; preds = %141, %130
%132 = load i32, i32* %9
%133 = icmp slt i32 %132, 16
br i1 %133, label %134, label %144
134: ; preds = %131
%135 = load i32, i32* %9
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 %136
%138 = load i32, i32* %137
%139 = load i32, i32* %9
%140 = call i32 @print_tile(i32 %138, i32 %139)
br label %141
141: ; preds = %134
%142 = load i32, i32* %9
%143 = add nsw i32 %142, 1
store i32 %143, i32* %9
br label %131
144: ; preds = %131
%145 = load i32, i32* %11
%146 = call i32 @print_status(i32 %145)
br label %147
147: ; preds = %144
%148 = load i32, i32* %10
%149 = add nsw i32 %148, 1
store i32 %149, i32* %10
br label %49
150: ; preds = %49
%151 = call i32 @print_info(i32 2)
br label %152
152: ; preds = %150, %157
%153 = call signext i8 (...) @get_key()
%154 = sext i8 %153 to i32
switch i32 %154, label %157 [
i32 113, label %155
i32 114, label %156
]
155: ; preds = %152
br label %158
156: ; preds = %152
br label %16
157: ; preds = %152
br label %152
158: ; preds = %155, %101
%159 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca <16 x i32>
%4 = bitcast <16 x i32>* %3 to i8*
%5 = tail call i32 (...) @init_scr()
%6 = tail call i32 (...) @print_border()
%7 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 0
%8 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 1
%9 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 2
%10 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 3
%11 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 4
%12 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 5
%13 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 6
%14 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 7
%15 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 8
%16 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 9
%17 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 10
%18 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 11
%19 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 12
%20 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 13
%21 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 14
%22 = getelementptr inbounds <16 x i32>, <16 x i32>* %3, i64 0, i64 15
br label %25
23: ; preds = %168, %225
%24 = phi i32 [ %223, %225 ], [ %169, %168 ]
br label %25
25: ; preds = %23, %2
%26 = phi i32 [ 0, %2 ], [ %24, %23 ]
%27 = call i32 @place_tile(i32* %7)
%28 = call i32 @place_tile(i32* %7)
%29 = load i32, i32* %7
%30 = call i32 @print_tile(i32 %29, i32 0)
%31 = load i32, i32* %8
%32 = call i32 @print_tile(i32 %31, i32 1)
%33 = load i32, i32* %9
%34 = call i32 @print_tile(i32 %33, i32 2)
%35 = load i32, i32* %10
%36 = call i32 @print_tile(i32 %35, i32 3)
%37 = load i32, i32* %11
%38 = call i32 @print_tile(i32 %37, i32 4)
%39 = load i32, i32* %12
%40 = call i32 @print_tile(i32 %39, i32 5)
%41 = load i32, i32* %13
%42 = call i32 @print_tile(i32 %41, i32 6)
%43 = load i32, i32* %14
%44 = call i32 @print_tile(i32 %43, i32 7)
%45 = load i32, i32* %15
%46 = call i32 @print_tile(i32 %45, i32 8)
%47 = load i32, i32* %16
%48 = call i32 @print_tile(i32 %47, i32 9)
%49 = load i32, i32* %17
%50 = call i32 @print_tile(i32 %49, i32 10)
%51 = load i32, i32* %18
%52 = call i32 @print_tile(i32 %51, i32 11)
%53 = load i32, i32* %19
%54 = call i32 @print_tile(i32 %53, i32 12)
%55 = load i32, i32* %20
%56 = call i32 @print_tile(i32 %55, i32 13)
%57 = load i32, i32* %21
%58 = call i32 @print_tile(i32 %57, i32 14)
%59 = load i32, i32* %22
%60 = call i32 @print_tile(i32 %59, i32 15)
%61 = call i32 @print_info(i32 0)
%62 = call i32 @print_status(i32 0)
%63 = call i32 @check_end(i32* %7)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %222
65: ; preds = %25, %186
%66 = phi i32 [ %176, %186 ], [ 0, %25 ]
%67 = phi i32 [ %169, %186 ], [ %26, %25 ]
%68 = load <16 x i32>, <16 x i32>* %3
%69 = icmp eq i32 %67, 0
br i1 %69, label %70, label %165
70: ; preds = %65
%71 = extractelement <16 x i32> %68, i64 0
%72 = icmp eq i32 %71, 2048
%73 = extractelement <16 x i32> %68, i64 1
br i1 %72, label %74, label %77
74: ; preds = %70
%75 = call i32 @print_info(i32 1)
%76 = load i32, i32* %8
br label %77
77: ; preds = %70, %74
%78 = phi i32 [ %76, %74 ], [ %73, %70 ]
%79 = phi i32 [ 1, %74 ], [ 0, %70 ]
%80 = icmp eq i32 %78, 2048
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = call i32 @print_info(i32 1)
br label %83
83: ; preds = %81, %77
%84 = phi i32 [ 1, %81 ], [ %79, %77 ]
%85 = load i32, i32* %9
%86 = icmp eq i32 %85, 2048
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @print_info(i32 1)
br label %89
89: ; preds = %87, %83
%90 = phi i32 [ 1, %87 ], [ %84, %83 ]
%91 = load i32, i32* %10
%92 = icmp eq i32 %91, 2048
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @print_info(i32 1)
br label %95
95: ; preds = %93, %89
%96 = phi i32 [ 1, %93 ], [ %90, %89 ]
%97 = load i32, i32* %11
%98 = icmp eq i32 %97, 2048
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = call i32 @print_info(i32 1)
br label %101
101: ; preds = %99, %95
%102 = phi i32 [ 1, %99 ], [ %96, %95 ]
%103 = load i32, i32* %12
%104 = icmp eq i32 %103, 2048
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = call i32 @print_info(i32 1)
br label %107
107: ; preds = %105, %101
%108 = phi i32 [ 1, %105 ], [ %102, %101 ]
%109 = load i32, i32* %13
%110 = icmp eq i32 %109, 2048
br i1 %110, label %111, label %113
111: ; preds = %107
%112 = call i32 @print_info(i32 1)
br label %113
113: ; preds = %111, %107
%114 = phi i32 [ 1, %111 ], [ %108, %107 ]
%115 = load i32, i32* %14
%116 = icmp eq i32 %115, 2048
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = call i32 @print_info(i32 1)
br label %119
119: ; preds = %117, %113
%120 = phi i32 [ 1, %117 ], [ %114, %113 ]
%121 = load i32, i32* %15
%122 = icmp eq i32 %121, 2048
br i1 %122, label %123, label %125
123: ; preds = %119
%124 = call i32 @print_info(i32 1)
br label %125
125: ; preds = %123, %119
%126 = phi i32 [ 1, %123 ], [ %120, %119 ]
%127 = load i32, i32* %16
%128 = icmp eq i32 %127, 2048
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = call i32 @print_info(i32 1)
br label %131
131: ; preds = %129, %125
%132 = phi i32 [ 1, %129 ], [ %126, %125 ]
%133 = load i32, i32* %17
%134 = icmp eq i32 %133, 2048
br i1 %134, label %135, label %137
135: ; preds = %131
%136 = call i32 @print_info(i32 1)
br label %137
137: ; preds = %135, %131
%138 = phi i32 [ 1, %135 ], [ %132, %131 ]
%139 = load i32, i32* %18
%140 = icmp eq i32 %139, 2048
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 @print_info(i32 1)
br label %143
143: ; preds = %141, %137
%144 = phi i32 [ 1, %141 ], [ %138, %137 ]
%145 = load i32, i32* %19
%146 = icmp eq i32 %145, 2048
br i1 %146, label %147, label %149
147: ; preds = %143
%148 = call i32 @print_info(i32 1)
br label %149
149: ; preds = %147, %143
%150 = phi i32 [ 1, %147 ], [ %144, %143 ]
%151 = load i32, i32* %20
%152 = icmp eq i32 %151, 2048
br i1 %152, label %153, label %155
153: ; preds = %149
%154 = call i32 @print_info(i32 1)
br label %155
155: ; preds = %153, %149
%156 = phi i32 [ 1, %153 ], [ %150, %149 ]
%157 = load i32, i32* %21
%158 = icmp eq i32 %157, 2048
br i1 %158, label %159, label %161
159: ; preds = %155
%160 = call i32 @print_info(i32 1)
br label %161
161: ; preds = %159, %155
%162 = phi i32 [ 1, %159 ], [ %156, %155 ]
%163 = load i32, i32* %22
%164 = icmp eq i32 %163, 2048
br i1 %164, label %165, label %168
165: ; preds = %65, %161
%166 = phi i32 [ 1, %161 ], [ 0, %65 ]
%167 = call i32 @print_info(i32 %166)
br label %168
168: ; preds = %165, %161
%169 = phi i32 [ %162, %161 ], [ 1, %165 ]
%170 = call signext i8 (...) @get_key()
%171 = sext i8 %170 to i32
switch i32 %171, label %175 [
i32 85, label %172
i32 68, label %172
i32 82, label %172
i32 76, label %172
i32 113, label %228
i32 114, label %23
]
172: ; preds = %168, %168, %168, %168
%173 = call i32 @move_tile(i32* %7, i8 signext %170)
%174 = add nsw i32 %173, %66
br label %175
175: ; preds = %168, %172
%176 = phi i32 [ %66, %168 ], [ %174, %172 ]
%177 = load <16 x i32>, <16 x i32>* %3
%178 = icmp eq <16 x i32> %177, %68
%179 = freeze <16 x i1> %178
%180 = bitcast <16 x i1> %179 to i16
%181 = icmp eq i16 %180, -1
%182 = extractelement <16 x i32> %177, i64 0
br i1 %181, label %186, label %183
183: ; preds = %175
%184 = call i32 @place_tile(i32* %7)
%185 = load i32, i32* %7
br label %186
186: ; preds = %183, %175
%187 = phi i32 [ %185, %183 ], [ %182, %175 ]
%188 = call i32 @print_tile(i32 %187, i32 0)
%189 = load i32, i32* %8
%190 = call i32 @print_tile(i32 %189, i32 1)
%191 = load i32, i32* %9
%192 = call i32 @print_tile(i32 %191, i32 2)
%193 = load i32, i32* %10
%194 = call i32 @print_tile(i32 %193, i32 3)
%195 = load i32, i32* %11
%196 = call i32 @print_tile(i32 %195, i32 4)
%197 = load i32, i32* %12
%198 = call i32 @print_tile(i32 %197, i32 5)
%199 = load i32, i32* %13
%200 = call i32 @print_tile(i32 %199, i32 6)
%201 = load i32, i32* %14
%202 = call i32 @print_tile(i32 %201, i32 7)
%203 = load i32, i32* %15
%204 = call i32 @print_tile(i32 %203, i32 8)
%205 = load i32, i32* %16
%206 = call i32 @print_tile(i32 %205, i32 9)
%207 = load i32, i32* %17
%208 = call i32 @print_tile(i32 %207, i32 10)
%209 = load i32, i32* %18
%210 = call i32 @print_tile(i32 %209, i32 11)
%211 = load i32, i32* %19
%212 = call i32 @print_tile(i32 %211, i32 12)
%213 = load i32, i32* %20
%214 = call i32 @print_tile(i32 %213, i32 13)
%215 = load i32, i32* %21
%216 = call i32 @print_tile(i32 %215, i32 14)
%217 = load i32, i32* %22
%218 = call i32 @print_tile(i32 %217, i32 15)
%219 = call i32 @print_status(i32 %176)
%220 = call i32 @check_end(i32* %7)
%221 = icmp eq i32 %220, 0
br i1 %221, label %65, label %222
222: ; preds = %186, %25
%223 = phi i32 [ %26, %25 ], [ %169, %186 ]
%224 = call i32 @print_info(i32 2)
br label %225
225: ; preds = %225, %222
%226 = call signext i8 (...) @get_key()
%227 = sext i8 %226 to i32
switch i32 %227, label %225 [
i32 113, label %228
i32 114, label %23
]
228: ; preds = %168, %225
%229 = call i32 (...) @endwin()
ret i32 0
}