#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 get_screen_columns();
int /*<<< orphan*/ gotoxy(int, int);
int /*<<< orphan*/ putchar(int);
void lineh(int x, int y, int length, int character) {
  int count;
  if ((x + length - 1) <= get_screen_columns()) {
    gotoxy(x, y);
    for (count = 0; count < length; count++)
      putchar(character);
  }
}


x86 assembly (clang, -O0):
<lineh>:
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),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <get_screen_columns@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     119d <lineh+0x6d>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <gotoxy@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1198 <lineh+0x68>
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <lineh+0x46>
jmp    119d <lineh+0x6d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lineh>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
lea    (%r15,%rbx,1),%r12d
add    $0xffffffff,%r12d
xor    %eax,%eax
call   1050 <get_screen_columns@plt>
cmp    %eax,%r12d
jg     117c <lineh+0x4c>
mov    %r15d,%edi
mov    %r14d,%esi
call   1040 <gotoxy@plt>
test   %ebx,%ebx
jle    117c <lineh+0x4c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1170 <lineh+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lineh(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* %5
%11 = load i32, i32* %7
%12 = add nsw i32 %10, %11
%13 = sub nsw i32 %12, 1
%14 = call i32 (...) @get_screen_columns()
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %31
16: ; preds = %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @gotoxy(i32 %17, i32 %18)
store i32 0, i32* %9
br label %20
20: ; preds = %27, %16
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %8
%26 = call i32 @putchar(i32 %25)
br label %27
27: ; preds = %24
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %20
30: ; preds = %20
br label %31
31: ; preds = %30, %4
ret void
}

LLVM IR (-O2):
define void @lineh(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add i32 %0, -1
%6 = add i32 %5, %2
%7 = tail call i32 (...) @get_screen_columns()
%8 = icmp sgt i32 %6, %7
br i1 %8, label %17, label %9
9: ; preds = %4
%10 = tail call i32 @gotoxy(i32 %0, i32 %1)
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %17
12: ; preds = %9, %12
%13 = phi i32 [ %15, %12 ], [ 0, %9 ]
%14 = tail call i32 @putchar(i32 %3)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, %2
br i1 %16, label %17, label %12
17: ; preds = %12, %9, %4
ret void
}