#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 /*<<< orphan*/ waku;

/* Variables and functions */
int /*<<< orphan*/ COLOR_PAIR(short);
short NTZ(unsigned long);
int /*<<< orphan*/ attrset(int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *, int);
int /*<<< orphan*/ standend();
int strlen(char *);
int draw(int field[][4]) {
  char *tile[] = {
      "       ",
      "  % 4d ",
      "       ",
  };
  char *waku[] = {
      "       ",
      "       ",
      "       ",
  };
  short colors = 0,
        color[] = {
            235, 225, 226, 215, 216, 210, 209, 222, 223, 224, 220, 221, 59, 59,
        };
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      colors = NTZ((unsigned long)field[i][j]);
      attrset(COLOR_PAIR(color[colors == 32 ? 0 : colors]));
      for (int k = 0; k < (int)(sizeof(waku) / sizeof(waku[0])); k++) {
        mvprintw(i * (int)(sizeof(waku) / sizeof(waku[0])) + k,
                 j * strlen(waku[0]), field[i][j] ? tile[k] : waku[k],
                 field[i][j]);
      }
      standend();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2c6a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c67(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c64(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c69(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c66(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c63(%rip),%rax
mov    %rax,-0x30(%rbp)
movw   $0x0,-0x42(%rbp)
mov    0xe52(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe4f(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe4c(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe4a(%rip),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    132c <draw+0x1cc>
movl   $0x0,-0x68(%rbp)
cmpl   $0x4,-0x68(%rbp)
jge    1319 <draw+0x1b9>
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
movslq (%rax,%rcx,4),%rdi
call   1050 <NTZ@plt>
mov    %ax,-0x42(%rbp)
movswl -0x42(%rbp),%eax
cmp    $0x20,%eax
jne    123a <draw+0xda>
xor    %eax,%eax
mov    %eax,-0x70(%rbp)
jmp    1241 <draw+0xe1>
movswl -0x42(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cltq
movswl -0x60(%rbp,%rax,2),%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1070 <attrset@plt>
movl   $0x0,-0x6c(%rbp)
cmpl   $0x3,-0x6c(%rbp)
jge    1304 <draw+0x1a4>
imul   $0x3,-0x64(%rbp),%eax
add    -0x6c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x74(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     12be <draw+0x15e>
movslq -0x6c(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0x88(%rbp)
jmp    12ce <draw+0x16e>
movslq -0x6c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x88(%rbp)
mov    -0x74(%rbp),%esi
mov    -0x7c(%rbp),%edi
mov    -0x88(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
call   1080 <mvprintw@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    125e <draw+0xfe>
mov    $0x0,%al
call   1030 <standend@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11f9 <draw+0x99>
jmp    131e <draw+0x1be>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11e8 <draw+0x88>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe8b(%rip),%r14
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
lea    (%rax,%rax,2),%r15d
lea    (%rax,%rax,2),%r12d
add    $0x1,%r12d
mov    %rax,(%rsp)
lea    (%rax,%rax,2),%ebp
add    $0x2,%ebp
xor    %r13d,%r13d
nopl   0x0(%rax)
movslq (%rbx,%r13,4),%rdi
call   1050 <NTZ@plt>
cmp    $0x20,%ax
mov    $0x0,%ecx
cmove  %ecx,%eax
movswq %ax,%rax
lea    0xe50(%rip),%rcx
movswl (%rcx,%rax,2),%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1070 <attrset@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
imul   %r13d,%eax
mov    (%rbx,%r13,4),%ecx
mov    %r15d,%edi
mov    %eax,%esi
mov    %r14,%rdx
call   1080 <mvprintw@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
imul   %r13d,%eax
mov    (%rbx,%r13,4),%ecx
test   %ecx,%ecx
lea    0xe02(%rip),%rdx
cmove  %r14,%rdx
mov    %r12d,%edi
mov    %eax,%esi
call   1080 <mvprintw@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r13d,%esi
imul   %eax,%esi
mov    (%rbx,%r13,4),%ecx
mov    %ebp,%edi
mov    %r14,%rdx
call   1080 <mvprintw@plt>
xor    %eax,%eax
call   1030 <standend@plt>
add    $0x1,%r13
cmp    $0x4,%r13
jne    11a0 <draw+0x40>
mov    (%rsp),%rax
add    $0x1,%rax
add    $0x10,%rbx
cmp    $0x4,%rax
jne    1180 <draw+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c" \00"
@.str.1 = [8 x i8] c" % 4d \00"
@__const.draw.tile = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0)]
@__const.draw.waku = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0)]
@__const.draw.color = [14 x i16] [i16 235, i16 225, i16 226, i16 215, i16 216, i16 210, i16 209, i16 222, i16 223, i16 224, i16 220, i16 221, i16 59, i16 59]
define i32 @draw([4 x i32]* %0) {
%2 = alloca [4 x i32]*
%3 = alloca [3 x i8*]
%4 = alloca [3 x i8*]
%5 = alloca i16
%6 = alloca [14 x i16]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store [4 x i32]* %0, [4 x i32]** %2
%10 = bitcast [3 x i8*]* %3 to i8*
%11 = bitcast [3 x i8*]* %4 to i8*
store i16 0, i16* %5
%12 = bitcast [14 x i16]* %6 to i8*
store i32 0, i32* %7
br label %13
13: ; preds = %97, %1
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %100
16: ; preds = %13
store i32 0, i32* %8
br label %17
17: ; preds = %93, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %96
20: ; preds = %17
%21 = load [4 x i32]*, [4 x i32]** %2
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %21, i64 %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %24, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = call signext i16 @NTZ(i64 %29)
store i16 %30, i16* %5
%31 = load i16, i16* %5
%32 = sext i16 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %35
34: ; preds = %20
br label %38
35: ; preds = %20
%36 = load i16, i16* %5
%37 = sext i16 %36 to i32
br label %38
38: ; preds = %35, %34
%39 = phi i32 [ 0, %34 ], [ %37, %35 ]
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [14 x i16], [14 x i16]* %6, i64 0, i64 %40
%42 = load i16, i16* %41
%43 = call i32 @COLOR_PAIR(i16 signext %42)
%44 = call i32 @attrset(i32 %43)
store i32 0, i32* %9
br label %45
45: ; preds = %88, %38
%46 = load i32, i32* %9
%47 = icmp slt i32 %46, 3
br i1 %47, label %48, label %91
48: ; preds = %45
%49 = load i32, i32* %7
%50 = mul nsw i32 %49, 3
%51 = load i32, i32* %9
%52 = add nsw i32 %50, %51
%53 = load i32, i32* %8
%54 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @strlen(i8* %55)
%57 = mul nsw i32 %53, %56
%58 = load [4 x i32]*, [4 x i32]** %2
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [4 x i32], [4 x i32]* %58, i64 %60
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [4 x i32], [4 x i32]* %61, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %48
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 %69
%71 = load i8*, i8** %70
br label %77
72: ; preds = %48
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 %74
%76 = load i8*, i8** %75
br label %77
77: ; preds = %72, %67
%78 = phi i8* [ %71, %67 ], [ %76, %72 ]
%79 = load [4 x i32]*, [4 x i32]** %2
%80 = load i32, i32* %7
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [4 x i32], [4 x i32]* %79, i64 %81
%83 = load i32, i32* %8
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [4 x i32], [4 x i32]* %82, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = call i32 @mvprintw(i32 %52, i32 %57, i8* %78, i32 %86)
br label %88
88: ; preds = %77
%89 = load i32, i32* %9
%90 = add nsw i32 %89, 1
store i32 %90, i32* %9
br label %45
91: ; preds = %45
%92 = call i32 (...) @standend()
br label %93
93: ; preds = %91
%94 = load i32, i32* %8
%95 = add nsw i32 %94, 1
store i32 %95, i32* %8
br label %17
96: ; preds = %17
br label %97
97: ; preds = %96
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %13
100: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c" \00"
@.str.1 = [8 x i8] c" % 4d \00"
@__const.draw.color = [14 x i16] [i16 235, i16 225, i16 226, i16 215, i16 216, i16 210, i16 209, i16 222, i16 223, i16 224, i16 220, i16 221, i16 59, i16 59]
define i32 @draw([4 x i32]* nocapture %0) {
br label %2
2: ; preds = %1, %11
%3 = phi i64 [ 0, %1 ], [ %12, %11 ]
%4 = mul nuw nsw i64 %3, 3
%5 = trunc i64 %4 to i32
%6 = trunc i64 %4 to i32
%7 = add i32 %6, 1
%8 = trunc i64 %4 to i32
%9 = add i32 %8, 2
br label %14
10: ; preds = %11
ret i32 0
11: ; preds = %14
%12 = add nuw nsw i64 %3, 1
%13 = icmp eq i64 %12, 4
br i1 %13, label %10, label %2
14: ; preds = %2, %14
%15 = phi i64 [ 0, %2 ], [ %43, %14 ]
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %3, i64 %15
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = tail call signext i16 @NTZ(i64 %18)
%20 = icmp eq i16 %19, 32
%21 = select i1 %20, i16 0, i16 %19
%22 = sext i16 %21 to i64
%23 = getelementptr inbounds [14 x i16], [14 x i16]* @__const.draw.color, i64 0, i64 %22
%24 = load i16, i16* %23
%25 = tail call i32 @COLOR_PAIR(i16 signext %24)
%26 = tail call i32 @attrset(i32 %25)
%27 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%28 = trunc i64 %15 to i32
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %16
%31 = tail call i32 @mvprintw(i32 %5, i32 %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%33 = mul nsw i32 %32, %28
%34 = load i32, i32* %16
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%37 = tail call i32 @mvprintw(i32 %7, i32 %33, i8* %36, i32 %34)
%38 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%39 = mul nsw i32 %38, %28
%40 = load i32, i32* %16
%41 = tail call i32 @mvprintw(i32 %9, i32 %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = tail call i32 (...) @standend()
%43 = add nuw nsw i64 %15, 1
%44 = icmp eq i64 %43, 4
br i1 %44, label %11, label %14
}