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

/* Variables and functions */
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ printw(char *);
int draw_border(int x, int y) {
  int i;
  mvaddch(0, 0, '+');
  mvaddch(y - 1, 0, '+');
  mvaddch(0, x - 1, '+');
  mvaddch(y - 1, x - 1, '+');
  for (i = 1; i < (x - 1); i++)
    if (i % 2) {
      mvaddch(0, i, '-');
      mvaddch(y - 1, i, '-');
    } else {
      mvaddch(0, i, '=');
      mvaddch(y - 1, i, '=');
    };
  for (i = 1; i < (y - 1); i++) {
    mvaddch(i, 0, '|');
    mvaddch(i, (x - 1), '|');
  };
  move(y - 1, (x - 18) / 2);
  printw("Press 'Q' to exit");
  move(y - 1, x - 1);
  return (0);
}


x86 assembly (clang, -O0):
<draw_border>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %esi,%esi
mov    $0x2b,%edx
mov    %esi,%edi
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
xor    %esi,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120e <draw_border+0xde>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d9 <draw_border+0xa9>
mov    -0xc(%rbp),%esi
xor    %edi,%edi
mov    $0x2d,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
mov    $0x2d,%edx
call   1040 <mvaddch@plt>
jmp    11fb <draw_border+0xcb>
mov    -0xc(%rbp),%esi
xor    %edi,%edi
mov    $0x3d,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
mov    $0x3d,%edx
call   1040 <mvaddch@plt>
jmp    1200 <draw_border+0xd0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <draw_border+0x5d>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1256 <draw_border+0x126>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
mov    $0x7c,%edx
call   1040 <mvaddch@plt>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    $0x7c,%edx
call   1040 <mvaddch@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1215 <draw_border+0xe5>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x4(%rbp),%eax
sub    $0x12,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1050 <move@plt>
lea    0xd88(%rip),%rdi
call   1030 <printw@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
call   1050 <move@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_border>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
mov    %rbx,(%rsp)
lea    -0x1(%rbx),%r13d
mov    %r13d,%edi
xor    %esi,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
lea    -0x1(%r14),%r12d
xor    %edi,%edi
mov    %r12d,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    $0x2b,%edx
call   1040 <mvaddch@plt>
cmp    $0x3,%r14d
jl     11d9 <draw_border+0xa9>
mov    $0x2,%r15d
sub    %r14d,%r15d
mov    $0x1,%ebp
nopl   0x0(%rax)
xor    %ebx,%ebx
test   $0x1,%bpl
sete   %bl
shl    $0x4,%ebx
or     $0x2d,%ebx
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <mvaddch@plt>
mov    %r13d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <mvaddch@plt>
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11a0 <draw_border+0x70>
mov    (%rsp),%rax
cmp    $0x3,%eax
jl     121f <draw_border+0xef>
mov    $0x2,%ebx
sub    %eax,%ebx
mov    $0x1,%ebp
xchg   %ax,%ax
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x7c,%edx
call   1040 <mvaddch@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    $0x7c,%edx
call   1040 <mvaddch@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11f0 <draw_border+0xc0>
mov    %r14d,%eax
add    $0xffffffee,%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%esi
add    $0xffffffee,%esi
sar    %esi
mov    %r13d,%edi
call   1050 <move@plt>
lea    0xdc0(%rip),%rdi
call   1030 <printw@plt>
mov    %r13d,%edi
mov    %r12d,%esi
call   1050 <move@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Press 'Q' to exit\00"
define i32 @draw_border(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @mvaddch(i32 0, i32 0, i8 signext 43)
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = call i32 @mvaddch(i32 %8, i32 0, i8 signext 43)
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = call i32 @mvaddch(i32 0, i32 %11, i8 signext 43)
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = call i32 @mvaddch(i32 %14, i32 %16, i8 signext 43)
store i32 1, i32* %5
br label %18
18: ; preds = %42, %2
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %45
23: ; preds = %18
%24 = load i32, i32* %5
%25 = srem i32 %24, 2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* %5
%29 = call i32 @mvaddch(i32 0, i32 %28, i8 signext 45)
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %5
%33 = call i32 @mvaddch(i32 %31, i32 %32, i8 signext 45)
br label %41
34: ; preds = %23
%35 = load i32, i32* %5
%36 = call i32 @mvaddch(i32 0, i32 %35, i8 signext 61)
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = load i32, i32* %5
%40 = call i32 @mvaddch(i32 %38, i32 %39, i8 signext 61)
br label %41
41: ; preds = %34, %27
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %18
45: ; preds = %18
store i32 1, i32* %5
br label %46
46: ; preds = %58, %45
%47 = load i32, i32* %5
%48 = load i32, i32* %4
%49 = sub nsw i32 %48, 1
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %61
51: ; preds = %46
%52 = load i32, i32* %5
%53 = call i32 @mvaddch(i32 %52, i32 0, i8 signext 124)
%54 = load i32, i32* %5
%55 = load i32, i32* %3
%56 = sub nsw i32 %55, 1
%57 = call i32 @mvaddch(i32 %54, i32 %56, i8 signext 124)
br label %58
58: ; preds = %51
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %46
61: ; preds = %46
%62 = load i32, i32* %4
%63 = sub nsw i32 %62, 1
%64 = load i32, i32* %3
%65 = sub nsw i32 %64, 18
%66 = sdiv i32 %65, 2
%67 = call i32 @move(i32 %63, i32 %66)
%68 = call i32 @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%69 = load i32, i32* %4
%70 = sub nsw i32 %69, 1
%71 = load i32, i32* %3
%72 = sub nsw i32 %71, 1
%73 = call i32 @move(i32 %70, i32 %72)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Press 'Q' to exit\00"
define i32 @draw_border(i32 %0, i32 %1) {
%3 = tail call i32 @mvaddch(i32 0, i32 0, i8 signext 43)
%4 = add nsw i32 %1, -1
%5 = tail call i32 @mvaddch(i32 %4, i32 0, i8 signext 43)
%6 = add nsw i32 %0, -1
%7 = tail call i32 @mvaddch(i32 0, i32 %6, i8 signext 43)
%8 = tail call i32 @mvaddch(i32 %4, i32 %6, i8 signext 43)
%9 = icmp sgt i32 %0, 2
br i1 %9, label %12, label %10
10: ; preds = %12, %2
%11 = icmp sgt i32 %1, 2
br i1 %11, label %21, label %27
12: ; preds = %2, %12
%13 = phi i32 [ %19, %12 ], [ 1, %2 ]
%14 = and i32 %13, 1
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 61, i8 45
%17 = tail call i32 @mvaddch(i32 0, i32 %13, i8 signext %16)
%18 = tail call i32 @mvaddch(i32 %4, i32 %13, i8 signext %16)
%19 = add nuw nsw i32 %13, 1
%20 = icmp eq i32 %19, %6
br i1 %20, label %10, label %12
21: ; preds = %10, %21
%22 = phi i32 [ %25, %21 ], [ 1, %10 ]
%23 = tail call i32 @mvaddch(i32 %22, i32 0, i8 signext 124)
%24 = tail call i32 @mvaddch(i32 %22, i32 %6, i8 signext 124)
%25 = add nuw nsw i32 %22, 1
%26 = icmp eq i32 %25, %4
br i1 %26, label %27, label %21
27: ; preds = %21, %10
%28 = add nsw i32 %0, -18
%29 = sdiv i32 %28, 2
%30 = tail call i32 @move(i32 %4, i32 %29)
%31 = tail call i32 @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @move(i32 %4, i32 %6)
ret i32 0
}