#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 */
typedef struct TYPE_9__ TYPE_1__;

/* Type definitions */
typedef int chtype;
struct TYPE_9__ {
  int _maxy;
};
typedef TYPE_1__ WINDOW;

/* Variables and functions */
int A_ATTRIBUTES;
int /*<<< orphan*/ box(TYPE_1__ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ setcolor(TYPE_1__ *, int);
int /*<<< orphan*/ touchwin(TYPE_1__ *);
int /*<<< orphan*/ wbkgd(TYPE_1__ *, int);
int /*<<< orphan*/ werase(TYPE_1__ *);
int /*<<< orphan*/ wrefresh(TYPE_1__ *);
void colorbox(WINDOW *win, chtype color, int hasbox) {
  chtype attr = color & (A_ATTRIBUTES);
  setcolor(win, color);
  wbkgd(win, color);
  werase(win);
  if (hasbox && win->_maxy > 2)
    box(win, 0, 0);
  touchwin(win);
  wrefresh(win);
}


x86 assembly (clang, -O0):
<colorbox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e64(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <setcolor@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <wbkgd@plt>
mov    -0x8(%rbp),%rdi
call   1080 <werase@plt>
cmpl   $0x0,-0x10(%rbp)
je     11c6 <colorbox+0x66>
mov    -0x8(%rbp),%rax
cmpl   $0x2,(%rax)
jle    11c6 <colorbox+0x66>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <box@plt>
mov    -0x8(%rbp),%rdi
call   1030 <touchwin@plt>
mov    -0x8(%rbp),%rdi
call   1050 <wrefresh@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colorbox>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1070 <setcolor@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <wbkgd@plt>
mov    %rbx,%rdi
call   1080 <werase@plt>
test   %r14d,%r14d
je     1199 <colorbox+0x39>
cmpl   $0x3,(%rbx)
jl     1199 <colorbox+0x39>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <box@plt>
mov    %rbx,%rdi
call   1030 <touchwin@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <wrefresh@plt>

LLVM IR (-O0):
%struct.TYPE_9__ = type { i32 }
@A_ATTRIBUTES = global i32 0
define void @colorbox(%struct.TYPE_9__* %0, i32 %1, i32 %2) {
%4 = alloca %struct.TYPE_9__*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.TYPE_9__* %0, %struct.TYPE_9__** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* @A_ATTRIBUTES
%10 = and i32 %8, %9
store i32 %10, i32* %7
%11 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%12 = load i32, i32* %5
%13 = call i32 @setcolor(%struct.TYPE_9__* %11, i32 %12)
%14 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%15 = load i32, i32* %5
%16 = call i32 @wbkgd(%struct.TYPE_9__* %14, i32 %15)
%17 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%18 = call i32 @werase(%struct.TYPE_9__* %17)
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %3
%22 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = icmp sgt i32 %24, 2
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%28 = call i32 @box(%struct.TYPE_9__* %27, i32 0, i32 0)
br label %29
29: ; preds = %26, %21, %3
%30 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%31 = call i32 @touchwin(%struct.TYPE_9__* %30)
%32 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%33 = call i32 @wrefresh(%struct.TYPE_9__* %32)
ret void
}

LLVM IR (-O2):
%struct.TYPE_9__ = type { i32 }
@A_ATTRIBUTES = global i32 0
define void @colorbox(%struct.TYPE_9__* %0, i32 %1, i32 %2) {
%4 = tail call i32 @setcolor(%struct.TYPE_9__* %0, i32 %1)
%5 = tail call i32 @wbkgd(%struct.TYPE_9__* %0, i32 %1)
%6 = tail call i32 @werase(%struct.TYPE_9__* %0)
%7 = icmp eq i32 %2, 0
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 0
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @box(%struct.TYPE_9__* %0, i32 0, i32 0)
br label %14
14: ; preds = %12, %8, %3
%15 = tail call i32 @touchwin(%struct.TYPE_9__* %0)
%16 = tail call i32 @wrefresh(%struct.TYPE_9__* %0)
ret void
}