#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ ACS_LLCORNER;
int /*<<< orphan*/ ACS_LRCORNER;
int /*<<< orphan*/ ACS_ULCORNER;
int /*<<< orphan*/ ACS_URCORNER;
int /*<<< orphan*/ mvaddch(scalar_t__, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ mvhline(scalar_t__, scalar_t__, int /*<<< orphan*/,
                           scalar_t__);
int /*<<< orphan*/ mvvline(scalar_t__, scalar_t__, int /*<<< orphan*/,
                           scalar_t__);
void rectangle(uint8_t y1, uint8_t x1, uint8_t y2, uint8_t x2) {
  mvhline(y1, x1, 0, x2 - x1);
  mvhline(y2, x1, 0, x2 - x1);
  mvvline(y1, x1, 0, y2 - y1);
  mvvline(y1, x2, 0, y2 - y1);
  mvaddch(y1, x1, ACS_ULCORNER);
  mvaddch(y2, x1, ACS_LLCORNER);
  mvaddch(y1, x2, ACS_URCORNER);
  mvaddch(y2, x2, ACS_LRCORNER);
}


x86 assembly (clang, -O0):
<rectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
sub    -0x10(%rbp),%rcx
xor    %edx,%edx
call   1030 <mvhline@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
sub    -0x10(%rbp),%rcx
xor    %edx,%edx
call   1030 <mvhline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
sub    -0x8(%rbp),%rcx
xor    %edx,%edx
call   1040 <mvvline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rcx
sub    -0x8(%rbp),%rcx
xor    %edx,%edx
call   1040 <mvvline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
call   1050 <mvaddch@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
call   1050 <mvaddch@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
call   1050 <mvaddch@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2deb(%rip),%rax
mov    (%rax),%edx
call   1050 <mvaddch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rectangle>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rcx,%rbx
sub    %rsi,%rbx
xor    %edx,%edx
mov    %rbx,%rcx
call   1030 <mvhline@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %edx,%edx
mov    %rbx,%rcx
call   1030 <mvhline@plt>
mov    %r15,%rbx
sub    %r12,%rbx
mov    %r12,%rdi
mov    %r13,%rsi
xor    %edx,%edx
mov    %rbx,%rcx
call   1040 <mvvline@plt>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %rbx,%rcx
call   1040 <mvvline@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <mvaddch@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <mvaddch@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <mvaddch@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <mvaddch@plt>

LLVM IR (-O0):
@ACS_ULCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LRCORNER = global i32 0
define void @rectangle(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%9 = load i64, i64* %5
%10 = load i64, i64* %6
%11 = load i64, i64* %8
%12 = load i64, i64* %6
%13 = sub nsw i64 %11, %12
%14 = call i32 @mvhline(i64 %9, i64 %10, i32 0, i64 %13)
%15 = load i64, i64* %7
%16 = load i64, i64* %6
%17 = load i64, i64* %8
%18 = load i64, i64* %6
%19 = sub nsw i64 %17, %18
%20 = call i32 @mvhline(i64 %15, i64 %16, i32 0, i64 %19)
%21 = load i64, i64* %5
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = load i64, i64* %5
%25 = sub nsw i64 %23, %24
%26 = call i32 @mvvline(i64 %21, i64 %22, i32 0, i64 %25)
%27 = load i64, i64* %5
%28 = load i64, i64* %8
%29 = load i64, i64* %7
%30 = load i64, i64* %5
%31 = sub nsw i64 %29, %30
%32 = call i32 @mvvline(i64 %27, i64 %28, i32 0, i64 %31)
%33 = load i64, i64* %5
%34 = load i64, i64* %6
%35 = load i32, i32* @ACS_ULCORNER
%36 = call i32 @mvaddch(i64 %33, i64 %34, i32 %35)
%37 = load i64, i64* %7
%38 = load i64, i64* %6
%39 = load i32, i32* @ACS_LLCORNER
%40 = call i32 @mvaddch(i64 %37, i64 %38, i32 %39)
%41 = load i64, i64* %5
%42 = load i64, i64* %8
%43 = load i32, i32* @ACS_URCORNER
%44 = call i32 @mvaddch(i64 %41, i64 %42, i32 %43)
%45 = load i64, i64* %7
%46 = load i64, i64* %8
%47 = load i32, i32* @ACS_LRCORNER
%48 = call i32 @mvaddch(i64 %45, i64 %46, i32 %47)
ret void
}

LLVM IR (-O2):
@ACS_ULCORNER = global i32 0
@ACS_LLCORNER = global i32 0
@ACS_URCORNER = global i32 0
@ACS_LRCORNER = global i32 0
define void @rectangle(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = sub nsw i64 %3, %1
%6 = tail call i32 @mvhline(i64 %0, i64 %1, i32 0, i64 %5)
%7 = tail call i32 @mvhline(i64 %2, i64 %1, i32 0, i64 %5)
%8 = sub nsw i64 %2, %0
%9 = tail call i32 @mvvline(i64 %0, i64 %1, i32 0, i64 %8)
%10 = tail call i32 @mvvline(i64 %0, i64 %3, i32 0, i64 %8)
%11 = load i32, i32* @ACS_ULCORNER
%12 = tail call i32 @mvaddch(i64 %0, i64 %1, i32 %11)
%13 = load i32, i32* @ACS_LLCORNER
%14 = tail call i32 @mvaddch(i64 %2, i64 %1, i32 %13)
%15 = load i32, i32* @ACS_URCORNER
%16 = tail call i32 @mvaddch(i64 %0, i64 %3, i32 %15)
%17 = load i32, i32* @ACS_LRCORNER
%18 = tail call i32 @mvaddch(i64 %2, i64 %3, i32 %17)
ret void
}