#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 ACS_LLCORNER;
int ACS_LRCORNER;
int ACS_ULCORNER;
int ACS_URCORNER;
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ mvwaddch(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ mvwhline(int /*<<< orphan*/ *, int, int, int, int);
int /*<<< orphan*/ scrollok(int /*<<< orphan*/ *, int /*<<< orphan*/);
void tx_box(WINDOW *win, int vline, int hline) {
  int winwidth;
  int winheight;
  int i;
  scrollok(win, 0);
  getmaxyx(win, winheight, winwidth);
  winheight--;
  winwidth--;
  mvwaddch(win, 0, 0, ACS_ULCORNER);
  mvwhline(win, 0, 1, hline, winwidth - 1);
  mvwaddch(win, 0, winwidth, ACS_URCORNER);
  for (i = 1; i < winheight; i++) {
    mvwaddch(win, i, 0, vline);
    mvwaddch(win, i, winwidth, vline);
  }
  mvwaddch(win, winheight, 0, ACS_LLCORNER);
  mvwhline(win, winheight, 1, hline, winwidth - 1);
  mvwaddch(win, winheight, winwidth, ACS_LRCORNER);
}


x86 assembly (clang, -O0):
<tx_box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <scrollok@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getmaxyx@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e5f(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
mov    %edx,%esi
call   1060 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
sub    $0x1,%r8d
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <mvwhline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2e13(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
call   1060 <mvwaddch@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120a <tx_box+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
call   1060 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1060 <mvwaddch@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cd <tx_box+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
call   1060 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x1,%edx
call   1040 <mvwhline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    0x2d92(%rip),%rax
mov    (%rax),%ecx
call   1060 <mvwaddch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tx_box>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
call   1050 <scrollok@plt>
mov    %rbx,%rdi
call   1030 <getmaxyx@plt>
mov    0x2e8a(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <mvwaddch@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
call   1040 <mvwhline@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <mvwaddch@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <mvwaddch@plt>
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %ebp,%ecx
call   1040 <mvwhline@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <mvwaddch@plt>

LLVM IR (-O0):
@ACS_ULCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_LRCORNER = global i32 0
define void @tx_box(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** %4
%11 = call i32 @scrollok(i32* %10, i32 0)
%12 = load i32*, i32** %4
%13 = load i32, i32* %8
%14 = load i32, i32* %7
%15 = call i32 @getmaxyx(i32* %12, i32 %13, i32 %14)
%16 = load i32, i32* %8
%17 = add nsw i32 %16, -1
store i32 %17, i32* %8
%18 = load i32, i32* %7
%19 = add nsw i32 %18, -1
store i32 %19, i32* %7
%20 = load i32*, i32** %4
%21 = load i32, i32* @ACS_ULCORNER
%22 = call i32 @mvwaddch(i32* %20, i32 0, i32 0, i32 %21)
%23 = load i32*, i32** %4
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = call i32 @mvwhline(i32* %23, i32 0, i32 1, i32 %24, i32 %26)
%28 = load i32*, i32** %4
%29 = load i32, i32* %7
%30 = load i32, i32* @ACS_URCORNER
%31 = call i32 @mvwaddch(i32* %28, i32 0, i32 %29, i32 %30)
store i32 1, i32* %9
br label %32
32: ; preds = %46, %3
%33 = load i32, i32* %9
%34 = load i32, i32* %8
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %32
%37 = load i32*, i32** %4
%38 = load i32, i32* %9
%39 = load i32, i32* %5
%40 = call i32 @mvwaddch(i32* %37, i32 %38, i32 0, i32 %39)
%41 = load i32*, i32** %4
%42 = load i32, i32* %9
%43 = load i32, i32* %7
%44 = load i32, i32* %5
%45 = call i32 @mvwaddch(i32* %41, i32 %42, i32 %43, i32 %44)
br label %46
46: ; preds = %36
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %32
49: ; preds = %32
%50 = load i32*, i32** %4
%51 = load i32, i32* %8
%52 = load i32, i32* @ACS_LLCORNER
%53 = call i32 @mvwaddch(i32* %50, i32 %51, i32 0, i32 %52)
%54 = load i32*, i32** %4
%55 = load i32, i32* %8
%56 = load i32, i32* %6
%57 = load i32, i32* %7
%58 = sub nsw i32 %57, 1
%59 = call i32 @mvwhline(i32* %54, i32 %55, i32 1, i32 %56, i32 %58)
%60 = load i32*, i32** %4
%61 = load i32, i32* %8
%62 = load i32, i32* %7
%63 = load i32, i32* @ACS_LRCORNER
%64 = call i32 @mvwaddch(i32* %60, i32 %61, i32 %62, i32 %63)
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
define void @tx_box(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @scrollok(i32* %0, i32 0)
%5 = tail call i32 @getmaxyx(i32* %0, i32 undef, i32 undef)
%6 = load i32, i32* @ACS_ULCORNER
%7 = tail call i32 @mvwaddch(i32* %0, i32 0, i32 0, i32 %6)
%8 = tail call i32 @mvwhline(i32* %0, i32 0, i32 1, i32 %2, i32 undef)
%9 = load i32, i32* @ACS_URCORNER
%10 = tail call i32 @mvwaddch(i32* %0, i32 0, i32 undef, i32 %9)
%11 = load i32, i32* @ACS_LLCORNER
%12 = tail call i32 @mvwaddch(i32* %0, i32 undef, i32 0, i32 %11)
%13 = tail call i32 @mvwhline(i32* %0, i32 undef, i32 1, i32 %2, i32 undef)
%14 = load i32, i32* @ACS_LRCORNER
%15 = tail call i32 @mvwaddch(i32* %0, i32 undef, i32 undef, i32 %14)
ret void
}