#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*/ mvprintw(int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char);
void draw(char ch, int col, int row, int color) {
  char buf[2];
  if (col >= (80) || col < 0 || row >= (24) || row < 0)
    return;
  sprintf(buf, "%c", ch);
  attron(COLOR_PAIR(color));
  mvprintw(row, col, buf);
  attroff(COLOR_PAIR(color));
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    118f <draw+0x3f>
cmpl   $0x0,-0x8(%rbp)
jl     118f <draw+0x3f>
cmpl   $0x18,-0xc(%rbp)
jge    118f <draw+0x3f>
cmpl   $0x0,-0xc(%rbp)
jge    1194 <draw+0x44>
jmp    11d5 <draw+0x85>
lea    -0x12(%rbp),%rdi
lea    0xe61(%rip),%rsi
movsbl -0x1(%rbp),%edx
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x12(%rbp),%rdx
call   1070 <mvprintw@plt>
mov    -0x10(%rbp),%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x4f,%esi
ja     118e <draw+0x4e>
mov    %edx,%ebx
cmp    $0x17,%edx
ja     118e <draw+0x4e>
mov    %ecx,%r14d
mov    %esi,%ebp
mov    %dil,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %ecx,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
lea    0xe(%rsp),%rdx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <mvprintw@plt>
mov    %r14d,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @draw(i8 signext %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i8]
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = icmp sge i32 %10, 80
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 24
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18, %15, %12, %4
br label %36
22: ; preds = %18
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%24 = load i8, i8* %5
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %24)
%26 = load i32, i32* %8
%27 = call i32 @COLOR_PAIR(i32 %26)
%28 = call i32 @attron(i32 %27)
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%32 = call i32 @mvprintw(i32 %29, i32 %30, i8* %31)
%33 = load i32, i32* %8
%34 = call i32 @COLOR_PAIR(i32 %33)
%35 = call i32 @attroff(i32 %34)
br label %36
36: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
define void @draw(i8 signext %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [2 x i8]
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%7 = icmp ugt i32 %1, 79
%8 = icmp ugt i32 %2, 23
%9 = or i1 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %4
store i8 %0, i8* %6
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 0, i8* %11
%12 = tail call i32 @COLOR_PAIR(i32 %3)
%13 = tail call i32 @attron(i32 %12)
%14 = call i32 @mvprintw(i32 %2, i32 %1, i8* %6)
%15 = call i32 @COLOR_PAIR(i32 %3)
%16 = call i32 @attroff(i32 %15)
br label %17
17: ; preds = %4, %10
ret void
}