#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 A_BOLD;
int COLOR_PAIR(int /*<<< orphan*/);
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ attrset(int);
int /*<<< orphan*/ mvaddch(int, int, char);
void draw_box(int width) {
  int x;
  int half = width / 2;
  attrset(COLOR_PAIR(COLOR_WHITE) | A_BOLD);
  for (x = -5; x < width + 5; x++) {
    mvaddch(23 / 2 - 2, (80 / 2) - half + x, '+');
    mvaddch(23 / 2 - 1, (80 / 2) - half + x, '+');
    mvaddch(23 / 2 + 0, (80 / 2) - half + x, '+');
    mvaddch(23 / 2 + 1, (80 / 2) - half + x, '+');
    mvaddch(23 / 2 + 2, (80 / 2) - half + x, '+');
  }
  for (x = -3; x < width + 3; x++) {
    mvaddch(23 / 2 - 1, (80 / 2) - half + x, ' ');
    mvaddch(23 / 2 + 0, (80 / 2) - half + x, ' ');
    mvaddch(23 / 2 + 1, (80 / 2) - half + x, ' ');
  }
}


x86 assembly (clang, -O0):
<draw_box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1030 <COLOR_PAIR@plt>
mov    %eax,%edi
mov    0x2e78(%rip),%rax
or     (%rax),%edi
call   1040 <attrset@plt>
movl   $0xfffffffb,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x5,%ecx
cmp    %ecx,%eax
jge    120f <draw_box+0xdf>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0x9,%edi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xa,%edi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xb,%edi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xc,%edi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xd,%edi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <draw_box+0x3e>
movl   $0xfffffffd,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jge    1283 <draw_box+0x153>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xa,%edi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xb,%edi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    $0x28,%esi
sub    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
mov    $0xc,%edi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1216 <draw_box+0xe6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_box>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
call   1030 <COLOR_PAIR@plt>
mov    0x2e89(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%edi
call   1040 <attrset@plt>
cmp    $0xfffffff7,%r15d
jl     124b <draw_box+0x11b>
mov    %r15d,%r14d
shr    $0x1f,%r14d
add    %r15d,%r14d
sar    %r14d
lea    0x4(%r15),%eax
cmp    $0xfffffffc,%eax
mov    $0xfffffffb,%ebx
cmovge %eax,%ebx
add    $0x6,%ebx
mov    $0x23,%ebp
sub    %r14d,%ebp
nopl   0x0(%rax)
mov    $0x9,%edi
mov    %ebp,%esi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0xa,%edi
mov    %ebp,%esi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0xb,%edi
mov    %ebp,%esi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0xc,%edi
mov    %ebp,%esi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
mov    $0xd,%edi
mov    %ebp,%esi
mov    $0x2b,%edx
call   1050 <mvaddch@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1190 <draw_box+0x60>
cmp    $0xfffffffb,%r15d
jl     124b <draw_box+0x11b>
add    $0x2,%r15d
cmp    $0xfffffffe,%r15d
mov    $0xfffffffd,%ebp
cmovge %r15d,%ebp
add    $0x4,%ebp
mov    $0x25,%ebx
sub    %r14d,%ebx
nop
mov    $0xa,%edi
mov    %ebx,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    $0xb,%edi
mov    %ebx,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    $0xc,%edi
mov    %ebx,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1210 <draw_box+0xe0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLOR_WHITE = global i32 0
@A_BOLD = global i32 0
define void @draw_box(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sdiv i32 %5, 2
store i32 %6, i32* %4
%7 = load i32, i32* @COLOR_WHITE
%8 = call i32 @COLOR_PAIR(i32 %7)
%9 = load i32, i32* @A_BOLD
%10 = or i32 %8, %9
%11 = call i32 @attrset(i32 %10)
store i32 -5, i32* %3
br label %12
12: ; preds = %43, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 5
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %46
17: ; preds = %12
%18 = load i32, i32* %4
%19 = sub nsw i32 40, %18
%20 = load i32, i32* %3
%21 = add nsw i32 %19, %20
%22 = call i32 @mvaddch(i32 9, i32 %21, i8 signext 43)
%23 = load i32, i32* %4
%24 = sub nsw i32 40, %23
%25 = load i32, i32* %3
%26 = add nsw i32 %24, %25
%27 = call i32 @mvaddch(i32 10, i32 %26, i8 signext 43)
%28 = load i32, i32* %4
%29 = sub nsw i32 40, %28
%30 = load i32, i32* %3
%31 = add nsw i32 %29, %30
%32 = call i32 @mvaddch(i32 11, i32 %31, i8 signext 43)
%33 = load i32, i32* %4
%34 = sub nsw i32 40, %33
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
%37 = call i32 @mvaddch(i32 12, i32 %36, i8 signext 43)
%38 = load i32, i32* %4
%39 = sub nsw i32 40, %38
%40 = load i32, i32* %3
%41 = add nsw i32 %39, %40
%42 = call i32 @mvaddch(i32 13, i32 %41, i8 signext 43)
br label %43
43: ; preds = %17
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %12
46: ; preds = %12
store i32 -3, i32* %3
br label %47
47: ; preds = %68, %46
%48 = load i32, i32* %3
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 3
%51 = icmp slt i32 %48, %50
br i1 %51, label %52, label %71
52: ; preds = %47
%53 = load i32, i32* %4
%54 = sub nsw i32 40, %53
%55 = load i32, i32* %3
%56 = add nsw i32 %54, %55
%57 = call i32 @mvaddch(i32 10, i32 %56, i8 signext 32)
%58 = load i32, i32* %4
%59 = sub nsw i32 40, %58
%60 = load i32, i32* %3
%61 = add nsw i32 %59, %60
%62 = call i32 @mvaddch(i32 11, i32 %61, i8 signext 32)
%63 = load i32, i32* %4
%64 = sub nsw i32 40, %63
%65 = load i32, i32* %3
%66 = add nsw i32 %64, %65
%67 = call i32 @mvaddch(i32 12, i32 %66, i8 signext 32)
br label %68
68: ; preds = %52
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %47
71: ; preds = %47
ret void
}

LLVM IR (-O2):
@COLOR_WHITE = global i32 0
@A_BOLD = global i32 0
define void @draw_box(i32 %0) {
%2 = sdiv i32 %0, 2
%3 = load i32, i32* @COLOR_WHITE
%4 = tail call i32 @COLOR_PAIR(i32 %3)
%5 = load i32, i32* @A_BOLD
%6 = or i32 %5, %4
%7 = tail call i32 @attrset(i32 %6)
%8 = icmp sgt i32 %0, -10
br i1 %8, label %9, label %37
9: ; preds = %1
%10 = sub nsw i32 40, %2
%11 = add i32 %0, 4
%12 = call i32 @llvm.smax.i32(i32 %11, i32 -5)
br label %19
13: ; preds = %19
%14 = icmp sgt i32 %0, -6
br i1 %14, label %15, label %37
15: ; preds = %13
%16 = sub nsw i32 40, %2
%17 = add i32 %0, 2
%18 = call i32 @llvm.smax.i32(i32 %17, i32 -3)
br label %29
19: ; preds = %9, %19
%20 = phi i32 [ -5, %9 ], [ %27, %19 ]
%21 = add nsw i32 %20, %10
%22 = tail call i32 @mvaddch(i32 9, i32 %21, i8 signext 43)
%23 = tail call i32 @mvaddch(i32 10, i32 %21, i8 signext 43)
%24 = tail call i32 @mvaddch(i32 11, i32 %21, i8 signext 43)
%25 = tail call i32 @mvaddch(i32 12, i32 %21, i8 signext 43)
%26 = tail call i32 @mvaddch(i32 13, i32 %21, i8 signext 43)
%27 = add i32 %20, 1
%28 = icmp eq i32 %20, %12
br i1 %28, label %13, label %19
29: ; preds = %15, %29
%30 = phi i32 [ -3, %15 ], [ %35, %29 ]
%31 = add nsw i32 %30, %16
%32 = tail call i32 @mvaddch(i32 10, i32 %31, i8 signext 32)
%33 = tail call i32 @mvaddch(i32 11, i32 %31, i8 signext 32)
%34 = tail call i32 @mvaddch(i32 12, i32 %31, i8 signext 32)
%35 = add i32 %30, 1
%36 = icmp eq i32 %30, %18
br i1 %36, label %37, label %29
37: ; preds = %29, %1, %13
ret void
}