#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*/ mvprintw(int, int, char *);
int /*<<< orphan*/ printw(char *);
void draw_box(int row, int col, int height, int width) {
  mvprintw(row, col, "+");
  for (int i = 0; i < width; i++) {
    printw("-");
  }
  printw("+");
  for (int j = 1; j < height + 1; j++) {
    mvprintw(row + j, col, "|");
    for (int i = 0; i < width; i++) {
      printw(" ");
    }
    printw("|");
  }
  mvprintw(row + height + 1, col, "+");
  for (int i = 0; i < width; i++) {
    printw("-");
  }
  printw("+");
}


x86 assembly (clang, -O0):
<draw_box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xebf(%rip),%rdx
call   1040 <mvprintw@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1173 <draw_box+0x53>
lea    0xea2(%rip),%rdi
call   1030 <printw@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <draw_box+0x2d>
lea    0xe86(%rip),%rdi
call   1030 <printw@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11f3 <draw_box+0xd3>
mov    -0x4(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xe5d(%rip),%rdx
call   1040 <mvprintw@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d9 <draw_box+0xb9>
lea    0xe40(%rip),%rdi
call   1030 <printw@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b3 <draw_box+0x93>
lea    0xe24(%rip),%rdi
call   1030 <printw@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <draw_box+0x66>
mov    -0x4(%rbp),%edi
add    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
lea    0xdfa(%rip),%rdx
call   1040 <mvprintw@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1238 <draw_box+0x118>
lea    0xddd(%rip),%rdi
call   1030 <printw@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1212 <draw_box+0xf2>
lea    0xdc1(%rip),%rdi
call   1030 <printw@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_box>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,0x10(%rsp)
mov    %edi,%r12d
lea    0xec0(%rip),%rdx
mov    %esi,0xc(%rsp)
call   1040 <mvprintw@plt>
test   %r15d,%r15d
jle    116d <draw_box+0x4d>
lea    0xead(%rip),%rbp
mov    %r15d,%ebx
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <printw@plt>
add    $0xffffffff,%ebx
jne    1160 <draw_box+0x40>
lea    0xe8c(%rip),%rdi
call   1030 <printw@plt>
cmpl   $0x0,0x10(%rsp)
jle    11df <draw_box+0xbf>
mov    $0x1,%r14d
lea    0xe77(%rip),%r13
lea    0xe72(%rip),%rbp
jmp    11b6 <draw_box+0x96>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <printw@plt>
lea    0x1(%r14),%eax
cmp    0x10(%rsp),%r14d
mov    %eax,%r14d
je     11df <draw_box+0xbf>
lea    (%r14,%r12,1),%edi
mov    0xc(%rsp),%esi
mov    %r13,%rdx
call   1040 <mvprintw@plt>
mov    %r15d,%ebx
test   %r15d,%r15d
jle    11a0 <draw_box+0x80>
xchg   %ax,%ax
mov    %rbp,%rdi
call   1030 <printw@plt>
add    $0xffffffff,%ebx
jne    11d0 <draw_box+0xb0>
jmp    11a0 <draw_box+0x80>
mov    0x10(%rsp),%rax
lea    (%r12,%rax,1),%edi
add    $0x1,%edi
lea    0xe0e(%rip),%rdx
mov    0xc(%rsp),%esi
call   1040 <mvprintw@plt>
test   %r15d,%r15d
jle    121e <draw_box+0xfe>
lea    0xdfb(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <printw@plt>
add    $0xffffffff,%r15d
jne    1210 <draw_box+0xf0>
lea    0xddb(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printw@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"|\00"
@.str.3 = [2 x i8] c" \00"
define void @draw_box(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @mvprintw(i32 %0, i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %3, 0
br i1 %6, label %10, label %7
7: ; preds = %10, %4
%8 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp slt i32 %2, 1
br i1 %9, label %15, label %19
10: ; preds = %4, %10
%11 = phi i32 [ %13, %10 ], [ 0, %4 ]
%12 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %7, label %10
15: ; preds = %23, %7
%16 = add i32 %0, 1
%17 = add i32 %16, %2
%18 = tail call i32 @mvprintw(i32 %17, i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br i1 %6, label %34, label %32
19: ; preds = %7, %23
%20 = phi i32 [ %25, %23 ], [ 1, %7 ]
%21 = add nsw i32 %20, %0
%22 = tail call i32 @mvprintw(i32 %21, i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br i1 %6, label %27, label %23
23: ; preds = %27, %19
%24 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = add nuw i32 %20, 1
%26 = icmp eq i32 %20, %2
br i1 %26, label %15, label %19
27: ; preds = %19, %27
%28 = phi i32 [ %30, %27 ], [ 0, %19 ]
%29 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, %3
br i1 %31, label %23, label %27
32: ; preds = %34, %15
%33 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
34: ; preds = %15, %34
%35 = phi i32 [ %37, %34 ], [ 0, %15 ]
%36 = tail call i32 @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %3
br i1 %38, label %32, label %34
}