#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*/ COLOR_PAIR(int);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ getyx(int /*<<< orphan*/, int, int);
scalar_t__ log2(int);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ stdscr;
void draw_cell(int num) {
  int prevx, prevy;
  getyx(stdscr, prevy, prevx);
  if (num != 0) {
    attron(COLOR_PAIR((int)log2(num)));
    printw("+----+");
    move(prevy + 1, prevx);
    printw("+    +");
    move(prevy + 2, prevx);
    printw("+%4d+", num);
    move(prevy + 3, prevx);
    printw("+----+");
    move(prevy, prevx + 6);
    attroff(COLOR_PAIR((int)log2(num)));
  } else {
    printw("......");
    move(prevy + 1, prevx);
    printw(".    .");
    move(prevy + 2, prevx);
    printw(".    .");
    move(prevy + 3, prevx);
    printw("......");
    move(prevy, prevx + 6);
  }
}


x86 assembly (clang, -O0):
<draw_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <getyx@plt>
cmpl   $0x0,-0x4(%rbp)
je     123d <draw_cell+0xcd>
mov    -0x4(%rbp),%edi
call   1040 <log2@plt>
mov    %eax,%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1060 <attron@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
mov    -0x4(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x3,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
add    $0x6,%esi
call   1090 <move@plt>
mov    -0x4(%rbp),%edi
call   1040 <log2@plt>
mov    %eax,%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    12ad <draw_cell+0x13d>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
add    $0x3,%edi
mov    -0x8(%rbp),%esi
call   1090 <move@plt>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printw@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
add    $0x6,%esi
call   1090 <move@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_cell>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1050 <getyx@plt>
test   %ebx,%ebx
je     1206 <draw_cell+0x96>
mov    %ebx,%edi
call   1040 <log2@plt>
mov    %eax,%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1060 <attron@plt>
lea    0xe5c(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
lea    0xe41(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
mov    %ebx,%edi
call   1040 <log2@plt>
mov    %eax,%edi
call   1080 <COLOR_PAIR@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <attroff@plt>
lea    0xe07(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
lea    0xdf8(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
call   1090 <move@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printw@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <move@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@.str = [7 x i8] c"+----+\00"
@.str.1 = [7 x i8] c"+ +\00"
@.str.2 = [6 x i8] c"+%4d+\00"
@.str.3 = [7 x i8] c"......\00"
@.str.4 = [7 x i8] c". .\00"
define void @draw_cell(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* @stdscr
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @getyx(i32 %5, i32 %6, i32 %7)
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %43
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i64 @log2(i32 %12)
%14 = trunc i64 %13 to i32
%15 = call i32 @COLOR_PAIR(i32 %14)
%16 = call i32 @attron(i32 %15)
%17 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %3
%21 = call i32 @move(i32 %19, i32 %20)
%22 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 2
%25 = load i32, i32* %3
%26 = call i32 @move(i32 %24, i32 %25)
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 3
%31 = load i32, i32* %3
%32 = call i32 @move(i32 %30, i32 %31)
%33 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 6
%37 = call i32 @move(i32 %34, i32 %36)
%38 = load i32, i32* %2
%39 = call i64 @log2(i32 %38)
%40 = trunc i64 %39 to i32
%41 = call i32 @COLOR_PAIR(i32 %40)
%42 = call i32 @attroff(i32 %41)
br label %64
43: ; preds = %1
%44 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
%47 = load i32, i32* %3
%48 = call i32 @move(i32 %46, i32 %47)
%49 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 2
%52 = load i32, i32* %3
%53 = call i32 @move(i32 %51, i32 %52)
%54 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 3
%57 = load i32, i32* %3
%58 = call i32 @move(i32 %56, i32 %57)
%59 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32, i32* %4
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 6
%63 = call i32 @move(i32 %60, i32 %62)
br label %64
64: ; preds = %43, %11
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@.str = [7 x i8] c"+----+\00"
@.str.1 = [7 x i8] c"+ +\00"
@.str.2 = [6 x i8] c"+%4d+\00"
@.str.3 = [7 x i8] c"......\00"
@.str.4 = [7 x i8] c". .\00"
define void @draw_cell(i32 %0) {
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getyx(i32 %2, i32 undef, i32 undef)
%4 = icmp eq i32 %0, 0
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = tail call i64 @log2(i32 %0)
%7 = trunc i64 %6 to i32
%8 = tail call i32 @COLOR_PAIR(i32 %7)
%9 = tail call i32 @attron(i32 %8)
%10 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @move(i32 undef, i32 undef)
%12 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @move(i32 undef, i32 undef)
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%15 = tail call i32 @move(i32 undef, i32 undef)
%16 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @move(i32 undef, i32 undef)
%18 = tail call i64 @log2(i32 %0)
%19 = trunc i64 %18 to i32
%20 = tail call i32 @COLOR_PAIR(i32 %19)
%21 = tail call i32 @attroff(i32 %20)
br label %31
22: ; preds = %1
%23 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @move(i32 undef, i32 undef)
%25 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%26 = tail call i32 @move(i32 undef, i32 undef)
%27 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%28 = tail call i32 @move(i32 undef, i32 undef)
%29 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @move(i32 undef, i32 undef)
br label %31
31: ; preds = %22, %5
ret void
}