#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*/ drawpixel(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void drawline(int x1, int y1, int x2, int y2) {
  int f, tmp;
  if (x1 == x2) {
    if (y2 < y1)
      tmp = y1, y1 = y2, y2 = tmp;
    for (f = y1; f <= y2; f++)
      drawpixel(x1, f);
    return;
  }
  if (y1 == y2) {
    if (x2 < x1)
      tmp = x1, x1 = x2, x2 = tmp;
    for (f = x1; f <= x2; f++)
      drawpixel(f, y1);
    return;
  }
  fprintf(stderr, "drawline() only supports vert/horiz lines!\n");
  exit(1);
}


x86 assembly (clang, -O0):
<drawline>:
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
cmp    -0xc(%rbp),%eax
jne    119e <drawline+0x6e>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    116e <drawline+0x3e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1199 <drawline+0x69>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <drawpixel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <drawline+0x44>
jmp    1217 <drawline+0xe7>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11f8 <drawline+0xc8>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c8 <drawline+0x98>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11f3 <drawline+0xc3>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <drawpixel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <drawline+0x9e>
jmp    1217 <drawline+0xe7>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
cmp    %edx,%edi
jne    1173 <drawline+0x43>
cmp    %r14d,%ebp
mov    %r14d,%ebx
cmovl  %ebp,%ebx
cmovl  %r14d,%ebp
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <drawpixel@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1160 <drawline+0x30>
jmp    11a1 <drawline+0x71>
cmp    %ebp,%r14d
jne    11ac <drawline+0x7c>
mov    %edx,%ebx
cmp    %r15d,%edx
mov    %r15d,%ebp
cmovl  %edx,%ebp
cmovl  %r15d,%ebx
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <drawpixel@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1190 <drawline+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"drawline() only supports vert/horiz lines!\0A\00"
define void @drawline(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %5
%12 = load i32, i32* %7
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %36
14: ; preds = %4
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* %6
store i32 %19, i32* %10
%20 = load i32, i32* %8
store i32 %20, i32* %6
%21 = load i32, i32* %10
store i32 %21, i32* %8
br label %22
22: ; preds = %18, %14
%23 = load i32, i32* %6
store i32 %23, i32* %9
br label %24
24: ; preds = %32, %22
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %9
%31 = call i32 @drawpixel(i32 %29, i32 %30)
br label %32
32: ; preds = %28
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %24
35: ; preds = %24
br label %66
36: ; preds = %4
%37 = load i32, i32* %6
%38 = load i32, i32* %8
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %62
40: ; preds = %36
%41 = load i32, i32* %7
%42 = load i32, i32* %5
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i32, i32* %5
store i32 %45, i32* %10
%46 = load i32, i32* %7
store i32 %46, i32* %5
%47 = load i32, i32* %10
store i32 %47, i32* %7
br label %48
48: ; preds = %44, %40
%49 = load i32, i32* %5
store i32 %49, i32* %9
br label %50
50: ; preds = %58, %48
%51 = load i32, i32* %9
%52 = load i32, i32* %7
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load i32, i32* %9
%56 = load i32, i32* %6
%57 = call i32 @drawpixel(i32 %55, i32 %56)
br label %58
58: ; preds = %54
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %50
61: ; preds = %50
br label %66
62: ; preds = %36
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %61, %35
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"drawline() only supports vert/horiz lines!\0A\00"
define void @drawline(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %0, %2
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = icmp slt i32 %3, %1
%8 = select i1 %7, i32 %3, i32 %1
%9 = select i1 %7, i32 %1, i32 %3
br label %10
10: ; preds = %6, %10
%11 = phi i32 [ %8, %6 ], [ %13, %10 ]
%12 = tail call i32 @drawpixel(i32 %0, i32 %11)
%13 = add i32 %11, 1
%14 = icmp eq i32 %11, %9
br i1 %14, label %30, label %10
15: ; preds = %4
%16 = icmp eq i32 %1, %3
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = icmp slt i32 %2, %0
%19 = select i1 %18, i32 %2, i32 %0
%20 = select i1 %18, i32 %0, i32 %2
br label %21
21: ; preds = %17, %21
%22 = phi i32 [ %19, %17 ], [ %24, %21 ]
%23 = tail call i32 @drawpixel(i32 %22, i32 %1)
%24 = add i32 %22, 1
%25 = icmp eq i32 %22, %20
br i1 %25, label %30, label %21
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %21, %10
ret void
}