#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*/ plot_pixel(int, int, int);
void plot_hline(int start_x, int start_y, int length) {
  int x;
  int init_x;
  int end_x;
  if (length > 0) {
    init_x = start_x;
    end_x = start_x + length;
  } else {
    init_x = start_x + length;
    end_x = start_x;
  }
  for (x = init_x; x < end_x; x++)
    plot_pixel(x, start_y, 1);
  return;
}


x86 assembly (clang, -O0):
<plot_hline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    113f <plot_hline+0x2f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    114e <plot_hline+0x3e>
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117e <plot_hline+0x6e>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1030 <plot_pixel@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <plot_hline+0x44>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot_hline>:
push   %rbp
push   %r14
push   %rbx
lea    (%rdx,%rdi,1),%ebp
test   %edx,%edx
mov    %ebp,%ebx
cmovg  %edi,%ebx
cmovle %edi,%ebp
cmp    %ebp,%ebx
jge    1146 <plot_hline+0x36>
mov    %esi,%r14d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x1,%edx
call   1030 <plot_pixel@plt>
add    $0x1,%ebx
cmp    %ebp,%ebx
jl     1130 <plot_hline+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @plot_hline(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i32, i32* %4
store i32 %13, i32* %8
%14 = load i32, i32* %4
%15 = load i32, i32* %6
%16 = add nsw i32 %14, %15
store i32 %16, i32* %9
br label %22
17: ; preds = %3
%18 = load i32, i32* %4
%19 = load i32, i32* %6
%20 = add nsw i32 %18, %19
store i32 %20, i32* %8
%21 = load i32, i32* %4
store i32 %21, i32* %9
br label %22
22: ; preds = %17, %12
%23 = load i32, i32* %8
store i32 %23, i32* %7
br label %24
24: ; preds = %32, %22
%25 = load i32, i32* %7
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32, i32* %7
%30 = load i32, i32* %5
%31 = call i32 @plot_pixel(i32 %29, i32 %30, i32 1)
br label %32
32: ; preds = %28
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %24
35: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @plot_hline(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
%5 = add nsw i32 %2, %0
%6 = select i1 %4, i32 %0, i32 %5
%7 = select i1 %4, i32 %5, i32 %0
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %3, %9
%10 = phi i32 [ %12, %9 ], [ %6, %3 ]
%11 = tail call i32 @plot_pixel(i32 %10, i32 %1, i32 1)
%12 = add nsw i32 %10, 1
%13 = icmp slt i32 %12, %7
br i1 %13, label %9, label %14
14: ; preds = %9, %3
ret void
}