#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*/ _putch(int);
int /*<<< orphan*/ gotoxy(int, int);
int /*<<< orphan*/ textattr(int);
void drawframe(int x, int y, int width, int height, int color) {
  int i, j;
  textattr(color);
  gotoxy(x, y);
  _putch((0xDA));
  for (i = 0; i < width + 2; i++)
    _putch((0xC4));
  _putch((0xBF));
  for (i = 0; i < height; i++) {
    gotoxy(x, y + i + 1);
    _putch((0xB3));
    _putch(' ');
    for (j = 0; j < width; j++) {
      _putch(' ');
    }
    _putch(' ');
    _putch((0xB3));
  }
  gotoxy(x, y + height + 1);
  _putch((0xC0));
  for (i = 0; i < width + 2; i++)
    _putch((0xC4));
  _putch((0xD9));
}


x86 assembly (clang, -O0):
<drawframe>:
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    %r8d,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <textattr@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <gotoxy@plt>
mov    $0xda,%edi
call   1040 <_putch@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1195 <drawframe+0x65>
mov    $0xc4,%edi
call   1040 <_putch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <drawframe+0x3c>
mov    $0xbf,%edi
call   1040 <_putch@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1224 <drawframe+0xf4>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x18(%rbp),%esi
add    $0x1,%esi
call   1050 <gotoxy@plt>
mov    $0xb3,%edi
call   1040 <_putch@plt>
mov    $0x20,%edi
call   1040 <_putch@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1202 <drawframe+0xd2>
mov    $0x20,%edi
call   1040 <_putch@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11de <drawframe+0xae>
mov    $0x20,%edi
call   1040 <_putch@plt>
mov    $0xb3,%edi
call   1040 <_putch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a6 <drawframe+0x76>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x10(%rbp),%esi
add    $0x1,%esi
call   1050 <gotoxy@plt>
mov    $0xc0,%edi
call   1040 <_putch@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    126f <drawframe+0x13f>
mov    $0xc4,%edi
call   1040 <_putch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1246 <drawframe+0x116>
mov    $0xd9,%edi
call   1040 <_putch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawframe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r13d
mov    %r8d,%edi
call   1030 <textattr@plt>
mov    %r13d,%edi
mov    %r14d,%esi
call   1050 <gotoxy@plt>
mov    $0xda,%edi
call   1040 <_putch@plt>
lea    0x2(%rbx),%r12d
cmp    $0xffffffff,%ebx
jl     118f <drawframe+0x5f>
cmp    $0x2,%r12d
mov    $0x1,%ebp
cmovge %r12d,%ebp
nopl   0x0(%rax)
mov    $0xc4,%edi
call   1040 <_putch@plt>
add    $0xffffffff,%ebp
jne    1180 <drawframe+0x50>
mov    %r12d,0x4(%rsp)
mov    $0xbf,%edi
call   1040 <_putch@plt>
add    $0x1,%r14d
test   %r15d,%r15d
jle    1212 <drawframe+0xe2>
xor    %ebp,%ebp
jmp    11cc <drawframe+0x9c>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1040 <_putch@plt>
mov    $0xb3,%edi
call   1040 <_putch@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
je     1212 <drawframe+0xe2>
lea    (%r14,%rbp,1),%esi
mov    %r13d,%edi
call   1050 <gotoxy@plt>
mov    $0xb3,%edi
call   1040 <_putch@plt>
mov    $0x20,%edi
call   1040 <_putch@plt>
test   %ebx,%ebx
jle    11b0 <drawframe+0x80>
mov    %ebx,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1040 <_putch@plt>
add    $0xffffffff,%r12d
jne    1200 <drawframe+0xd0>
jmp    11b0 <drawframe+0x80>
add    %r15d,%r14d
mov    %r13d,%edi
mov    %r14d,%esi
call   1050 <gotoxy@plt>
mov    $0xc0,%edi
call   1040 <_putch@plt>
cmp    $0xffffffff,%ebx
jl     124f <drawframe+0x11f>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
xchg   %ax,%ax
mov    $0xc4,%edi
call   1040 <_putch@plt>
add    $0xffffffff,%ebx
jne    1240 <drawframe+0x110>
mov    $0xd9,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <_putch@plt>

LLVM IR (-O0):
define void @drawframe(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%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* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %10
%14 = call i32 @textattr(i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 @gotoxy(i32 %15, i32 %16)
%18 = call i32 @_putch(i32 218)
store i32 0, i32* %11
br label %19
19: ; preds = %26, %5
%20 = load i32, i32* %11
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 2
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = call i32 @_putch(i32 196)
br label %26
26: ; preds = %24
%27 = load i32, i32* %11
%28 = add nsw i32 %27, 1
store i32 %28, i32* %11
br label %19
29: ; preds = %19
%30 = call i32 @_putch(i32 191)
store i32 0, i32* %11
br label %31
31: ; preds = %56, %29
%32 = load i32, i32* %11
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %59
35: ; preds = %31
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %11
%39 = add nsw i32 %37, %38
%40 = add nsw i32 %39, 1
%41 = call i32 @gotoxy(i32 %36, i32 %40)
%42 = call i32 @_putch(i32 179)
%43 = call i32 @_putch(i32 32)
store i32 0, i32* %12
br label %44
44: ; preds = %50, %35
%45 = load i32, i32* %12
%46 = load i32, i32* %8
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = call i32 @_putch(i32 32)
br label %50
50: ; preds = %48
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
store i32 %52, i32* %12
br label %44
53: ; preds = %44
%54 = call i32 @_putch(i32 32)
%55 = call i32 @_putch(i32 179)
br label %56
56: ; preds = %53
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %31
59: ; preds = %31
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = load i32, i32* %9
%63 = add nsw i32 %61, %62
%64 = add nsw i32 %63, 1
%65 = call i32 @gotoxy(i32 %60, i32 %64)
%66 = call i32 @_putch(i32 192)
store i32 0, i32* %11
br label %67
67: ; preds = %74, %59
%68 = load i32, i32* %11
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 2
%71 = icmp slt i32 %68, %70
br i1 %71, label %72, label %77
72: ; preds = %67
%73 = call i32 @_putch(i32 196)
br label %74
74: ; preds = %72
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
store i32 %76, i32* %11
br label %67
77: ; preds = %67
%78 = call i32 @_putch(i32 217)
ret void
}

LLVM IR (-O2):
define void @drawframe(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @textattr(i32 %4)
%7 = tail call i32 @gotoxy(i32 %0, i32 %1)
%8 = tail call i32 @_putch(i32 218)
%9 = add i32 %2, 2
%10 = icmp sgt i32 %2, -2
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = call i32 @llvm.smax.i32(i32 %9, i32 1)
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ %16, %13 ], [ 0, %11 ]
%15 = tail call i32 @_putch(i32 196)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %12
br i1 %17, label %18, label %13
18: ; preds = %13, %5
%19 = tail call i32 @_putch(i32 191)
%20 = icmp sgt i32 %3, 0
%21 = add i32 %1, 1
br i1 %20, label %22, label %40
22: ; preds = %18
%23 = icmp sgt i32 %2, 0
br label %24
24: ; preds = %22, %35
%25 = phi i32 [ 0, %22 ], [ %38, %35 ]
%26 = add i32 %21, %25
%27 = tail call i32 @gotoxy(i32 %0, i32 %26)
%28 = tail call i32 @_putch(i32 179)
%29 = tail call i32 @_putch(i32 32)
br i1 %23, label %30, label %35
30: ; preds = %24, %30
%31 = phi i32 [ %33, %30 ], [ 0, %24 ]
%32 = tail call i32 @_putch(i32 32)
%33 = add nuw nsw i32 %31, 1
%34 = icmp eq i32 %33, %2
br i1 %34, label %35, label %30
35: ; preds = %30, %24
%36 = tail call i32 @_putch(i32 32)
%37 = tail call i32 @_putch(i32 179)
%38 = add nuw nsw i32 %25, 1
%39 = icmp eq i32 %38, %3
br i1 %39, label %40, label %24
40: ; preds = %35, %18
%41 = add i32 %21, %3
%42 = tail call i32 @gotoxy(i32 %0, i32 %41)
%43 = tail call i32 @_putch(i32 192)
br i1 %10, label %44, label %51
44: ; preds = %40
%45 = call i32 @llvm.smax.i32(i32 %9, i32 1)
br label %46
46: ; preds = %44, %46
%47 = phi i32 [ %49, %46 ], [ 0, %44 ]
%48 = tail call i32 @_putch(i32 196)
%49 = add nuw nsw i32 %47, 1
%50 = icmp eq i32 %49, %45
br i1 %50, label %51, label %46
51: ; preds = %46, %40
%52 = tail call i32 @_putch(i32 217)
ret void
}