#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*/ mvwaddch(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
void DrawBox(WINDOW *Win, int x, int y, int w, int h) {
  int i;
  for (i = x; i < w + x; i++) {
    mvwaddch(Win, y, i, ACS_HLINE);
    mvwaddch(Win, y + h - 1, i, ACS_HLINE);
  }
  for (i = y; i < h + y; i++) {
    mvwaddch(Win, i, x, ACS_VLINE);
    mvwaddch(Win, i, x + w - 1, ACS_VLINE);
  }
  mvwaddch(Win, y, x, ACS_ULCORNER);
  mvwaddch(Win, y, x + w - 1, ACS_URCORNER);
  mvwaddch(Win, y + h - 1, x, ACS_LLCORNER);
  mvwaddch(Win, y + h - 1, x + w - 1, ACS_LRCORNER);
}


x86 assembly (clang, -O0):
<DrawBox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1184 <DrawBox+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2e77(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    0x2e59(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <DrawBox+0x1f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11df <DrawBox+0xcf>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    0x2e14(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
add    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    0x2df6(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <DrawBox+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    0x2df8(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
add    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    0x2dc2(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0xc(%rbp),%edx
mov    0x2d84(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0xc(%rbp),%edx
add    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    0x2d90(%rip),%rax
mov    (%rax),%ecx
call   1030 <mvwaddch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawBox>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r12d
mov    %rdi,%rbx
mov    %rsi,0x18(%rsp)
lea    (%rcx,%rsi,1),%r15d
mov    %r8,%rax
mov    %r8,0x20(%rsp)
lea    (%r8,%r12,1),%eax
mov    %rax,0x10(%rsp)
test   %ecx,%ecx
jle    118b <DrawBox+0x7b>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r13d
mov    0x2e76(%rip),%rbp
mov    0x18(%rsp),%rax
mov    %eax,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <mvwaddch@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1030 <mvwaddch@plt>
add    $0x1,%r14d
cmp    %r15d,%r14d
jl     1160 <DrawBox+0x50>
mov    %r12,0x8(%rsp)
add    $0xffffffff,%r15d
cmpl   $0x0,0x20(%rsp)
mov    0x18(%rsp),%r13
mov    0x10(%rsp),%r12
jle    11e8 <DrawBox+0xd8>
mov    0x2e14(%rip),%r14
mov    0x8(%rsp),%rax
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
call   1030 <mvwaddch@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <mvwaddch@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
jl     11c0 <DrawBox+0xb0>
mov    0x2df9(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    0x8(%rsp),%rbp
mov    %ebp,%esi
mov    %r13d,%edx
call   1030 <mvwaddch@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <mvwaddch@plt>
add    $0xffffffff,%r12d
mov    0x2d8c(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
call   1030 <mvwaddch@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mvwaddch@plt>

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

LLVM IR (-O2):
@ACS_HLINE = global i32 0
@ACS_VLINE = global i32 0
@ACS_ULCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_LRCORNER = global i32 0
define void @DrawBox(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = add nsw i32 %3, %1
%7 = icmp sgt i32 %3, 0
%8 = add nsw i32 %4, %2
br i1 %7, label %9, label %11
9: ; preds = %5
%10 = add nsw i32 %8, -1
br label %14
11: ; preds = %14, %5
%12 = icmp sgt i32 %4, 0
%13 = add nsw i32 %6, -1
br i1 %12, label %22, label %30
14: ; preds = %9, %14
%15 = phi i32 [ %1, %9 ], [ %20, %14 ]
%16 = load i32, i32* @ACS_HLINE
%17 = tail call i32 @mvwaddch(i32* %0, i32 %2, i32 %15, i32 %16)
%18 = load i32, i32* @ACS_HLINE
%19 = tail call i32 @mvwaddch(i32* %0, i32 %10, i32 %15, i32 %18)
%20 = add nsw i32 %15, 1
%21 = icmp slt i32 %20, %6
br i1 %21, label %14, label %11
22: ; preds = %11, %22
%23 = phi i32 [ %28, %22 ], [ %2, %11 ]
%24 = load i32, i32* @ACS_VLINE
%25 = tail call i32 @mvwaddch(i32* %0, i32 %23, i32 %1, i32 %24)
%26 = load i32, i32* @ACS_VLINE
%27 = tail call i32 @mvwaddch(i32* %0, i32 %23, i32 %13, i32 %26)
%28 = add nsw i32 %23, 1
%29 = icmp slt i32 %28, %8
br i1 %29, label %22, label %30
30: ; preds = %22, %11
%31 = load i32, i32* @ACS_ULCORNER
%32 = tail call i32 @mvwaddch(i32* %0, i32 %2, i32 %1, i32 %31)
%33 = load i32, i32* @ACS_URCORNER
%34 = tail call i32 @mvwaddch(i32* %0, i32 %2, i32 %13, i32 %33)
%35 = add nsw i32 %8, -1
%36 = load i32, i32* @ACS_LLCORNER
%37 = tail call i32 @mvwaddch(i32* %0, i32 %35, i32 %1, i32 %36)
%38 = load i32, i32* @ACS_LRCORNER
%39 = tail call i32 @mvwaddch(i32* %0, i32 %35, i32 %13, i32 %38)
ret void
}