#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*/ printf(char *, int, int, ...);
int /*<<< orphan*/ putchar(char);
void draw_box_XY(int x1, int y1, int x2, int y2, char Horizontal, char Vertical,
                 char Corner) {
  int cx, cy;
  printf("\033[%d;%dH%c", y1, x1, Corner);
  printf("\033[%d;%dH%c", y1, x2, Corner);
  printf("\033[%d;%dH%c", y2, x1, Corner);
  printf("\033[%d;%dH%c", y2, x2, Corner);
  printf("\033[%d;%dH", y1, x1 + 1);
  for (cx = x1 + 1; cx <= x2 - 1; cx++)
    putchar(Horizontal);
  printf("\033[%d;%dH", y2, x1 + 1);
  for (cx = x1 + 1; cx <= x2 - 1; cx++)
    putchar(Horizontal);
  for (cy = y1 + 1; cy <= y2 - 1; cy++) {
    printf("\033[%d;%dH", cy, x1);
    putchar(Vertical);
    printf("\033[%d;%dH", cy, x2);
    putchar(Vertical);
  }
}


x86 assembly (clang, -O0):
<draw_box_XY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8d,-0x2c(%rbp)
mov    %ecx,%eax
mov    -0x2c(%rbp),%ecx
mov    %eax,-0x28(%rbp)
mov    %edx,%eax
mov    -0x28(%rbp),%edx
mov    %eax,-0x24(%rbp)
mov    %esi,%eax
mov    -0x24(%rbp),%esi
mov    %eax,-0x20(%rbp)
mov    %edi,%r8d
mov    -0x20(%rbp),%edi
mov    %r9b,%al
mov    0x10(%rbp),%r9b
mov    %r8d,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
movsbl 0x10(%rbp),%ecx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsbl 0x10(%rbp),%ecx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
movsbl 0x10(%rbp),%ecx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
movsbl 0x10(%rbp),%ecx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     120c <draw_box_XY+0xec>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e4 <draw_box_XY+0xc4>
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1254 <draw_box_XY+0x134>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    122c <draw_box_XY+0x10c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     12b6 <draw_box_XY+0x196>
mov    -0x1c(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x12(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x12(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    125d <draw_box_XY+0x13d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_box_XY>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,0x8(%rsp)
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %edi,%r15d
movsbl 0x50(%rsp),%ebx
lea    0xeb1(%rip),%r12
mov    %r12,%rdi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%r15),%ebx
lea    0xe6d(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,%ebx
mov    %r15,0x10(%rsp)
jge    120f <draw_box_XY+0xef>
mov    %ebx,0x4(%rsp)
not    %r15d
lea    (%r15,%r13,1),%r12d
movsbl 0x8(%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r12d
jne    11d0 <draw_box_XY+0xb0>
lea    0xe27(%rip),%rdi
mov    %r14d,%esi
mov    0x4(%rsp),%r12d
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,%r12d
jge    1222 <draw_box_XY+0x102>
add    %r13d,%r15d
xchg   %ax,%ax
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r15d
jne    1200 <draw_box_XY+0xe0>
jmp    1222 <draw_box_XY+0x102>
lea    0xdf5(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r14),%eax
cmp    %ebp,%eax
mov    0x10(%rsp),%r15
jle    1274 <draw_box_XY+0x154>
add    $0x1,%ebp
lea    0xdd2(%rip),%r12
movsbl 0xc(%rsp),%ebx
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1240 <draw_box_XY+0x120>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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