#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*/ Term_putch(int, int, int, char);
int /*<<< orphan*/ c_put_str(int, char *, int, int);
void draw_box(int y, int x, int h, int w) {
  int i, j;
  for (i = x + 1; i < x + w; i++)
    for (j = y + 1; j < y + h; j++)
      Term_putch(i, j, 14, ' ');
  for (i = x; i < x + w; i++) {
    c_put_str(14, "-", y, i);
    c_put_str(14, "-", y + h, i);
  }
  for (i = y; i < y + h; i++) {
    c_put_str(14, "|", i, x);
    c_put_str(14, "|", i, x + w);
  }
  Term_putch(x, y, 14, '/');
  Term_putch(x + w, y, 14, '\\');
  Term_putch(x, y + h, 14, '\\');
  Term_putch(x + w, y + h, 14, '/');
}


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    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    119e <draw_box+0x7e>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    118b <draw_box+0x6b>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0xe,%edx
mov    $0x20,%ecx
call   1030 <Term_putch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <draw_box+0x37>
jmp    1190 <draw_box+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <draw_box+0x1d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11f4 <draw_box+0xd4>
mov    -0x4(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xe,%edi
lea    0xe39(%rip),%rsi
call   1040 <c_put_str@plt>
mov    -0x4(%rbp),%edx
add    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xe,%edi
lea    0xe1f(%rip),%rsi
call   1040 <c_put_str@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <draw_box+0x84>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    124a <draw_box+0x12a>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0xe,%edi
lea    0xde5(%rip),%rsi
call   1040 <c_put_str@plt>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    -0x10(%rbp),%ecx
mov    $0xe,%edi
lea    0xdcb(%rip),%rsi
call   1040 <c_put_str@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fa <draw_box+0xda>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0xe,%edx
mov    $0x2f,%ecx
call   1030 <Term_putch@plt>
mov    -0x8(%rbp),%edi
add    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0xe,%edx
mov    $0x5c,%ecx
call   1030 <Term_putch@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
add    -0xc(%rbp),%esi
mov    $0xe,%edx
mov    $0x5c,%ecx
call   1030 <Term_putch@plt>
mov    -0x8(%rbp),%edi
add    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
add    -0xc(%rbp),%esi
mov    $0xe,%edx
mov    $0x2f,%ecx
call   1030 <Term_putch@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    %edx,%r12d
mov    %rdi,(%rsp)
mov    %rsi,0x8(%rsp)
lea    (%rcx,%rsi,1),%r13d
mov    %rcx,0x10(%rsp)
cmp    $0x2,%ecx
jl     119d <draw_box+0x7d>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%ebp
mov    (%rsp),%rax
lea    (%r12,%rax,1),%r15d
lea    0x1(%rax),%r14d
jmp    1168 <draw_box+0x48>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %r13d,%ebp
jge    119d <draw_box+0x7d>
mov    %r14d,%ebx
cmp    $0x2,%r12d
jl     1160 <draw_box+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0xe,%edx
mov    $0x20,%ecx
call   1030 <Term_putch@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
jl     1180 <draw_box+0x60>
jmp    1160 <draw_box+0x40>
mov    (%rsp),%rbp
lea    (%r12,%rbp,1),%r15d
cmpl   $0x0,0x10(%rsp)
jle    11ee <draw_box+0xce>
lea    0xe4d(%rip),%rbx
mov    0x8(%rsp),%rax
mov    %eax,%r14d
nopl   0x0(%rax,%rax,1)
mov    $0xe,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <c_put_str@plt>
mov    $0xe,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <c_put_str@plt>
add    $0x1,%r14d
cmp    %r13d,%r14d
jl     11c0 <draw_box+0xa0>
test   %r12d,%r12d
mov    0x8(%rsp),%r14
jle    123c <draw_box+0x11c>
lea    0xe03(%rip),%rbx
mov    (%rsp),%rax
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xe,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <c_put_str@plt>
mov    $0xe,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
call   1040 <c_put_str@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
jl     1210 <draw_box+0xf0>
mov    %r14d,%edi
mov    (%rsp),%rbx
mov    %ebx,%esi
mov    $0xe,%edx
mov    $0x2f,%ecx
call   1030 <Term_putch@plt>
mov    %r13d,%edi
mov    %ebx,%esi
mov    $0xe,%edx
mov    $0x5c,%ecx
call   1030 <Term_putch@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    $0xe,%edx
mov    $0x5c,%ecx
call   1030 <Term_putch@plt>
mov    %r13d,%edi
mov    %r15d,%esi
mov    $0xe,%edx
mov    $0x2f,%ecx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <Term_putch@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [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
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 1
store i32 %12, i32* %9
br label %13
13: ; preds = %36, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = add nsw i32 %15, %16
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %39
19: ; preds = %13
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %10
br label %22
22: ; preds = %32, %19
%23 = load i32, i32* %10
%24 = load i32, i32* %5
%25 = load i32, i32* %7
%26 = add nsw i32 %24, %25
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = call i32 @Term_putch(i32 %29, i32 %30, i32 14, i8 signext 32)
br label %32
32: ; preds = %28
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 1
store i32 %34, i32* %10
br label %22
35: ; preds = %22
br label %36
36: ; preds = %35
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %13
39: ; preds = %13
%40 = load i32, i32* %6
store i32 %40, i32* %9
br label %41
41: ; preds = %56, %39
%42 = load i32, i32* %9
%43 = load i32, i32* %6
%44 = load i32, i32* %8
%45 = add nsw i32 %43, %44
%46 = icmp slt i32 %42, %45
br i1 %46, label %47, label %59
47: ; preds = %41
%48 = load i32, i32* %5
%49 = load i32, i32* %9
%50 = call i32 @c_put_str(i32 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %49)
%51 = load i32, i32* %5
%52 = load i32, i32* %7
%53 = add nsw i32 %51, %52
%54 = load i32, i32* %9
%55 = call i32 @c_put_str(i32 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %53, i32 %54)
br label %56
56: ; preds = %47
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %41
59: ; preds = %41
%60 = load i32, i32* %5
store i32 %60, i32* %9
br label %61
61: ; preds = %76, %59
%62 = load i32, i32* %9
%63 = load i32, i32* %5
%64 = load i32, i32* %7
%65 = add nsw i32 %63, %64
%66 = icmp slt i32 %62, %65
br i1 %66, label %67, label %79
67: ; preds = %61
%68 = load i32, i32* %9
%69 = load i32, i32* %6
%70 = call i32 @c_put_str(i32 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %68, i32 %69)
%71 = load i32, i32* %9
%72 = load i32, i32* %6
%73 = load i32, i32* %8
%74 = add nsw i32 %72, %73
%75 = call i32 @c_put_str(i32 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %71, i32 %74)
br label %76
76: ; preds = %67
%77 = load i32, i32* %9
%78 = add nsw i32 %77, 1
store i32 %78, i32* %9
br label %61
79: ; preds = %61
%80 = load i32, i32* %6
%81 = load i32, i32* %5
%82 = call i32 @Term_putch(i32 %80, i32 %81, i32 14, i8 signext 47)
%83 = load i32, i32* %6
%84 = load i32, i32* %8
%85 = add nsw i32 %83, %84
%86 = load i32, i32* %5
%87 = call i32 @Term_putch(i32 %85, i32 %86, i32 14, i8 signext 92)
%88 = load i32, i32* %6
%89 = load i32, i32* %5
%90 = load i32, i32* %7
%91 = add nsw i32 %89, %90
%92 = call i32 @Term_putch(i32 %88, i32 %91, i32 14, i8 signext 92)
%93 = load i32, i32* %6
%94 = load i32, i32* %8
%95 = add nsw i32 %93, %94
%96 = load i32, i32* %5
%97 = load i32, i32* %7
%98 = add nsw i32 %96, %97
%99 = call i32 @Term_putch(i32 %95, i32 %98, i32 14, i8 signext 47)
ret void
}

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