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

/* Variables and functions */
int /*<<< orphan*/ ACS_HLINE;
int /*<<< orphan*/ ACS_LLCORNER;
int /*<<< orphan*/ ACS_LRCORNER;
int /*<<< orphan*/ ACS_ULCORNER;
int /*<<< orphan*/ ACS_URCORNER;
int /*<<< orphan*/ ACS_VLINE;
int /*<<< orphan*/ attroff(int);
int /*<<< orphan*/ attron(int);
int /*<<< orphan*/ getbegyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ mvaddch(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ mvhline(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ mvvline(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ refresh();
void printBox(WINDOW *win, int color) {
  int y, x, h, w;
  getbegyx(win, y, x);
  getmaxyx(win, h, w);
  y--;
  h++;
  x -= 2;
  w += 3;
  attron(color);
  mvaddch(y, x, ACS_ULCORNER);
  mvaddch(y, x + w, ACS_URCORNER);
  mvaddch(y + h, x, ACS_LLCORNER);
  mvaddch(y + h, x + w, ACS_LRCORNER);
  mvhline(y, x + 1, ACS_HLINE, w - 1);
  mvhline(y + h, x + 1, ACS_HLINE, w - 1);
  mvvline(y + 1, x, ACS_VLINE, h - 1);
  mvvline(y + 1, x + w, ACS_VLINE, h - 1);
  attroff(color);
  refresh();
}


x86 assembly (clang, -O0):
<printBox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <getbegyx@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <getmaxyx@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <attron@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    0x2dd3(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    0x2db2(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    0x2d83(%rip),%rax
mov    (%rax),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1080 <mvhline@plt>
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1080 <mvhline@plt>
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x14(%rbp),%esi
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
call   1090 <mvvline@plt>
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    -0x14(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
call   1090 <mvvline@plt>
mov    -0xc(%rbp),%edi
call   1030 <attroff@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBox>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1060 <getbegyx@plt>
mov    %rbx,%rdi
call   1050 <getmaxyx@plt>
mov    %ebp,%edi
call   1040 <attron@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edx
call   10a0 <mvaddch@plt>
mov    0x2ded(%rip),%rbx
mov    (%rbx),%edx
call   1080 <mvhline@plt>
mov    (%rbx),%edx
call   1080 <mvhline@plt>
mov    0x2dd0(%rip),%rbx
mov    (%rbx),%edx
call   1090 <mvvline@plt>
mov    (%rbx),%edx
call   1090 <mvvline@plt>
mov    %ebp,%edi
call   1030 <attroff@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <refresh@plt>

LLVM IR (-O0):
@ACS_ULCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_LRCORNER = global i32 0
@ACS_HLINE = global i32 0
@ACS_VLINE = global i32 0
define void @printBox(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32*, i32** %3
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @getbegyx(i32* %9, i32 %10, i32 %11)
%13 = load i32*, i32** %3
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @getmaxyx(i32* %13, i32 %14, i32 %15)
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = sub nsw i32 %21, 2
store i32 %22, i32* %6
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 3
store i32 %24, i32* %8
%25 = load i32, i32* %4
%26 = call i32 @attron(i32 %25)
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = load i32, i32* @ACS_ULCORNER
%30 = call i32 @mvaddch(i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = add nsw i32 %32, %33
%35 = load i32, i32* @ACS_URCORNER
%36 = call i32 @mvaddch(i32 %31, i32 %34, i32 %35)
%37 = load i32, i32* %5
%38 = load i32, i32* %7
%39 = add nsw i32 %37, %38
%40 = load i32, i32* %6
%41 = load i32, i32* @ACS_LLCORNER
%42 = call i32 @mvaddch(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %5
%44 = load i32, i32* %7
%45 = add nsw i32 %43, %44
%46 = load i32, i32* %6
%47 = load i32, i32* %8
%48 = add nsw i32 %46, %47
%49 = load i32, i32* @ACS_LRCORNER
%50 = call i32 @mvaddch(i32 %45, i32 %48, i32 %49)
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
%54 = load i32, i32* @ACS_HLINE
%55 = load i32, i32* %8
%56 = sub nsw i32 %55, 1
%57 = call i32 @mvhline(i32 %51, i32 %53, i32 %54, i32 %56)
%58 = load i32, i32* %5
%59 = load i32, i32* %7
%60 = add nsw i32 %58, %59
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
%63 = load i32, i32* @ACS_HLINE
%64 = load i32, i32* %8
%65 = sub nsw i32 %64, 1
%66 = call i32 @mvhline(i32 %60, i32 %62, i32 %63, i32 %65)
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
%69 = load i32, i32* %6
%70 = load i32, i32* @ACS_VLINE
%71 = load i32, i32* %7
%72 = sub nsw i32 %71, 1
%73 = call i32 @mvvline(i32 %68, i32 %69, i32 %70, i32 %72)
%74 = load i32, i32* %5
%75 = add nsw i32 %74, 1
%76 = load i32, i32* %6
%77 = load i32, i32* %8
%78 = add nsw i32 %76, %77
%79 = load i32, i32* @ACS_VLINE
%80 = load i32, i32* %7
%81 = sub nsw i32 %80, 1
%82 = call i32 @mvvline(i32 %75, i32 %78, i32 %79, i32 %81)
%83 = load i32, i32* %4
%84 = call i32 @attroff(i32 %83)
%85 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@ACS_ULCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_LRCORNER = global i32 0
@ACS_HLINE = global i32 0
@ACS_VLINE = global i32 0
define void @printBox(i32* %0, i32 %1) {
%3 = tail call i32 @getbegyx(i32* %0, i32 undef, i32 undef)
%4 = tail call i32 @getmaxyx(i32* %0, i32 undef, i32 undef)
%5 = tail call i32 @attron(i32 %1)
%6 = load i32, i32* @ACS_ULCORNER
%7 = tail call i32 @mvaddch(i32 undef, i32 undef, i32 %6)
%8 = load i32, i32* @ACS_URCORNER
%9 = tail call i32 @mvaddch(i32 undef, i32 undef, i32 %8)
%10 = load i32, i32* @ACS_LLCORNER
%11 = tail call i32 @mvaddch(i32 undef, i32 undef, i32 %10)
%12 = load i32, i32* @ACS_LRCORNER
%13 = tail call i32 @mvaddch(i32 undef, i32 undef, i32 %12)
%14 = load i32, i32* @ACS_HLINE
%15 = tail call i32 @mvhline(i32 undef, i32 undef, i32 %14, i32 undef)
%16 = load i32, i32* @ACS_HLINE
%17 = tail call i32 @mvhline(i32 undef, i32 undef, i32 %16, i32 undef)
%18 = load i32, i32* @ACS_VLINE
%19 = tail call i32 @mvvline(i32 undef, i32 undef, i32 %18, i32 undef)
%20 = load i32, i32* @ACS_VLINE
%21 = tail call i32 @mvvline(i32 undef, i32 undef, i32 %20, i32 undef)
%22 = tail call i32 @attroff(i32 %1)
%23 = tail call i32 (...) @refresh()
ret void
}