#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*/ ACS_HLINE;
int /*<<< orphan*/ ACS_VLINE;
int /*<<< orphan*/ mvhline(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ mvvline(int, int, int /*<<< orphan*/, int);
void printLine(int row, int col, int direction, int len) {
  int i;
  switch (direction) {
  case 0:
    for (i = 0; i < len; i++)
      mvhline(row, col + i, ACS_HLINE, 1);
    break;
  case 1:
    for (i = 0; i < len; i++)
      mvvline(row + i, col, ACS_VLINE, 1);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<printLine>:
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    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1158 <printLine+0x38>
jmp    1147 <printLine+0x27>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     119a <printLine+0x7a>
jmp    11dc <printLine+0xbc>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1195 <printLine+0x75>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x14(%rbp),%esi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%ecx
call   1030 <mvhline@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <printLine+0x3f>
jmp    11e1 <printLine+0xc1>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d7 <printLine+0xb7>
mov    -0x4(%rbp),%edi
add    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e1b(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%ecx
call   1040 <mvvline@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <printLine+0x81>
jmp    11e1 <printLine+0xc1>
jmp    11e1 <printLine+0xc1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLine>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
test   %edx,%edx
je     116c <printLine+0x4c>
cmp    $0x1,%edx
jne    119b <printLine+0x7b>
test   %ebx,%ebx
jle    119b <printLine+0x7b>
mov    0x2e96(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edx
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x1,%ecx
call   1040 <mvvline@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1150 <printLine+0x30>
jmp    119b <printLine+0x7b>
test   %ebx,%ebx
jle    119b <printLine+0x7b>
mov    0x2e69(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r15),%edx
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x1,%ecx
call   1030 <mvhline@plt>
add    $0x1,%r14d
add    $0xffffffff,%ebx
jne    1180 <printLine+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ACS_HLINE = global i32 0
@ACS_VLINE = global i32 0
define void @printLine(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
switch i32 %10, label %43 [
i32 0, label %11
i32 1, label %27
]
11: ; preds = %4
store i32 0, i32* %9
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %9
%20 = add nsw i32 %18, %19
%21 = load i32, i32* @ACS_HLINE
%22 = call i32 @mvhline(i32 %17, i32 %20, i32 %21, i32 1)
br label %23
23: ; preds = %16
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %12
26: ; preds = %12
br label %44
27: ; preds = %4
store i32 0, i32* %9
br label %28
28: ; preds = %39, %27
%29 = load i32, i32* %9
%30 = load i32, i32* %8
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %5
%34 = load i32, i32* %9
%35 = add nsw i32 %33, %34
%36 = load i32, i32* %6
%37 = load i32, i32* @ACS_VLINE
%38 = call i32 @mvvline(i32 %35, i32 %36, i32 %37, i32 1)
br label %39
39: ; preds = %32
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %28
42: ; preds = %28
br label %44
43: ; preds = %4
br label %44
44: ; preds = %43, %42, %26
ret void
}

LLVM IR (-O2):
@ACS_HLINE = global i32 0
@ACS_VLINE = global i32 0
define void @printLine(i32 %0, i32 %1, i32 %2, i32 %3) {
switch i32 %2, label %23 [
i32 0, label %7
i32 1, label %5
]
5: ; preds = %4
%6 = icmp sgt i32 %3, 0
br i1 %6, label %16, label %23
7: ; preds = %4
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %23
9: ; preds = %7, %9
%10 = phi i32 [ %14, %9 ], [ 0, %7 ]
%11 = add nsw i32 %10, %1
%12 = load i32, i32* @ACS_HLINE
%13 = tail call i32 @mvhline(i32 %0, i32 %11, i32 %12, i32 1)
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, %3
br i1 %15, label %23, label %9
16: ; preds = %5, %16
%17 = phi i32 [ %21, %16 ], [ 0, %5 ]
%18 = add nsw i32 %17, %0
%19 = load i32, i32* @ACS_VLINE
%20 = tail call i32 @mvvline(i32 %18, i32 %1, i32 %19, i32 1)
%21 = add nuw nsw i32 %17, 1
%22 = icmp eq i32 %21, %3
br i1 %22, label %23, label %16
23: ; preds = %16, %9, %5, %7, %4
ret void
}