#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*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *);
void draw_borders(WINDOW *win) {
  int x, y, i;
  getmaxyx(win, y, x);
  mvwprintw(win, 0, 0, "+");
  mvwprintw(win, y - 1, 0, "+");
  mvwprintw(win, 0, x - 1, "+");
  mvwprintw(win, y - 1, x - 1, "+");
  for (i = 1; i < (y - 1); ++i) {
    mvwprintw(win, i, 0, "|");
    mvwprintw(win, i, x - 1, "|");
  }
  for (i = 1; i < (x - 1); ++i) {
    mvwprintw(win, 0, i, "-");
    mvwprintw(win, y - 1, i, "-");
  }
}


x86 assembly (clang, -O0):
<draw_borders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <getmaxyx@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
lea    0xeb8(%rip),%rcx
mov    %edx,%esi
call   1040 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
xor    %edx,%edx
lea    0xe9e(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
lea    0xe86(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xe6a(%rip),%rcx
call   1040 <mvwprintw@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ef <draw_borders+0xcf>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
lea    0xe3f(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xe26(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a2 <draw_borders+0x82>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1243 <draw_borders+0x123>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
lea    0xded(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
lea    0xdd4(%rip),%rcx
call   1040 <mvwprintw@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f6 <draw_borders+0xd6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_borders>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getmaxyx@plt>
lea    0xecd(%rip),%r14
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r14,%rcx
call   1040 <mvwprintw@plt>
mov    %rbx,%rdi
xor    %edx,%edx
mov    %r14,%rcx
call   1040 <mvwprintw@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rcx
call   1040 <mvwprintw@plt>
mov    %rbx,%rdi
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mvwprintw@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [2 x i8] c"-\00"
define void @draw_borders(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = call i32 @getmaxyx(i32* %6, i32 %7, i32 %8)
%10 = load i32*, i32** %2
%11 = call i32 @mvwprintw(i32* %10, i32 0, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 @mvwprintw(i32* %12, i32 %14, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load i32*, i32** %2
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 1
%19 = call i32 @mvwprintw(i32* %16, i32 0, i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i32*, i32** %2
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = call i32 @mvwprintw(i32* %20, i32 %22, i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %26
26: ; preds = %40, %1
%27 = load i32, i32* %5
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %43
31: ; preds = %26
%32 = load i32*, i32** %2
%33 = load i32, i32* %5
%34 = call i32 @mvwprintw(i32* %32, i32 %33, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32*, i32** %2
%36 = load i32, i32* %5
%37 = load i32, i32* %3
%38 = sub nsw i32 %37, 1
%39 = call i32 @mvwprintw(i32* %35, i32 %36, i32 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %31
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %26
43: ; preds = %26
store i32 1, i32* %5
br label %44
44: ; preds = %58, %43
%45 = load i32, i32* %5
%46 = load i32, i32* %3
%47 = sub nsw i32 %46, 1
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %61
49: ; preds = %44
%50 = load i32*, i32** %2
%51 = load i32, i32* %5
%52 = call i32 @mvwprintw(i32* %50, i32 0, i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32*, i32** %2
%54 = load i32, i32* %4
%55 = sub nsw i32 %54, 1
%56 = load i32, i32* %5
%57 = call i32 @mvwprintw(i32* %53, i32 %55, i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %49
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %44
61: ; preds = %44
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
define void @draw_borders(i32* %0) {
%2 = tail call i32 @getmaxyx(i32* %0, i32 undef, i32 undef)
%3 = tail call i32 @mvwprintw(i32* %0, i32 0, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @mvwprintw(i32* %0, i32 undef, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @mvwprintw(i32* %0, i32 0, i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @mvwprintw(i32* %0, i32 undef, i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}