#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 chtype;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int A_ATTRIBUTES;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ setcolor(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ touchwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ wbkgd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ werase(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void colorbox(WINDOW *win, chtype color, int hasbox) {
  int maxy;
  int maxx;
  chtype attr = color & (A_ATTRIBUTES);
  setcolor(win, color);
  wbkgd(win, attr);
  werase(win);
  getmaxyx(win, maxy, maxx);
  if (hasbox && (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    0x2e54(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <setcolor@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <wbkgd@plt>
mov    -0x8(%rbp),%rdi
call   1090 <werase@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <getmaxyx@plt>
cmpl   $0x0,-0x10(%rbp)
je     11e2 <colorbox+0x72>
cmpl   $0x2,-0x14(%rbp)
jle    11e2 <colorbox+0x72>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <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   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e73(%rip),%rax
mov    (%rax),%ebp
and    %esi,%ebp
call   1070 <setcolor@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <wbkgd@plt>
mov    %rbx,%rdi
call   1080 <werase@plt>
mov    %rbx,%rdi
call   1060 <getmaxyx@plt>
mov    %rbx,%rdi
call   1030 <touchwin@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <wrefresh@plt>

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

LLVM IR (-O2):
@A_ATTRIBUTES = global i32 0
define void @colorbox(i32* %0, i32 %1, i32 %2) {
%4 = load i32, i32* @A_ATTRIBUTES
%5 = and i32 %4, %1
%6 = tail call i32 @setcolor(i32* %0, i32 %1)
%7 = tail call i32 @wbkgd(i32* %0, i32 %5)
%8 = tail call i32 @werase(i32* %0)
%9 = tail call i32 @getmaxyx(i32* %0, i32 undef, i32 undef)
%10 = tail call i32 @touchwin(i32* %0)
%11 = tail call i32 @wrefresh(i32* %0)
ret void
}