#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*/ draw_pixel(int, int, char, char, char, int);
void draw_line(int x1, int y1, int x2, int y2, char r, char g, char b,
               int screen) {
  int x, y;
  if (x1 == x2) {
    if (y1 < y2)
      for (y = y1; y < y2; y++)
        draw_pixel(x1, y, r, g, b, screen);
    else
      for (y = y2; y < y1; y++)
        draw_pixel(x1, y, r, g, b, screen);
  } else {
    if (x1 < x2)
      for (x = x1; x < x2; x++)
        draw_pixel(x, y1, r, g, b, screen);
    else
      for (x = x2; x < x1; x++)
        draw_pixel(x, y1, r, g, b, screen);
  }
}


x86 assembly (clang, -O0):
<draw_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8d,-0x2c(%rbp)
mov    %ecx,%eax
mov    -0x2c(%rbp),%ecx
mov    %eax,-0x28(%rbp)
mov    %edx,%eax
mov    -0x28(%rbp),%edx
mov    %eax,-0x24(%rbp)
mov    %esi,%eax
mov    -0x24(%rbp),%esi
mov    %eax,-0x20(%rbp)
mov    %edi,%r8d
mov    -0x20(%rbp),%edi
mov    %r9b,%al
mov    0x18(%rbp),%r9d
mov    0x10(%rbp),%r9b
mov    %r8d,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1203 <draw_line+0xf3>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b7 <draw_line+0xa7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b2 <draw_line+0xa2>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x11(%rbp),%dl
mov    -0x12(%rbp),%cl
mov    0x10(%rbp),%al
mov    0x18(%rbp),%r9d
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1030 <draw_pixel@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1176 <draw_line+0x66>
jmp    11fe <draw_line+0xee>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f9 <draw_line+0xe9>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x11(%rbp),%dl
mov    -0x12(%rbp),%cl
mov    0x10(%rbp),%al
mov    0x18(%rbp),%r9d
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1030 <draw_pixel@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bd <draw_line+0xad>
jmp    11fe <draw_line+0xee>
jmp    12a2 <draw_line+0x192>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1256 <draw_line+0x146>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1251 <draw_line+0x141>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x11(%rbp),%dl
mov    -0x12(%rbp),%cl
mov    0x10(%rbp),%al
mov    0x18(%rbp),%r9d
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1030 <draw_pixel@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1215 <draw_line+0x105>
jmp    129d <draw_line+0x18d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1298 <draw_line+0x188>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x11(%rbp),%dl
mov    -0x12(%rbp),%cl
mov    0x10(%rbp),%al
mov    0x18(%rbp),%r9d
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1030 <draw_pixel@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125c <draw_line+0x14c>
jmp    129d <draw_line+0x18d>
jmp    12a2 <draw_line+0x192>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x48(%rsp),%eax
mov    0x40(%rsp),%cl
cmp    %edx,%edi
jne    1166 <draw_line+0x56>
cmp    %r15d,%ebx
jge    11a6 <draw_line+0x96>
movsbl %r8b,%r12d
movsbl %r9b,%r13d
movsbl %cl,%r14d
nop
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
mov    %eax,%r9d
call   1030 <draw_pixel@plt>
mov    0x48(%rsp),%eax
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1140 <draw_line+0x30>
jmp    1223 <draw_line+0x113>
mov    %edx,%r12d
jge    11e5 <draw_line+0xd5>
movsbl %r8b,%r15d
movsbl %r9b,%r13d
movsbl %cl,%r14d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
mov    %eax,%r9d
call   1030 <draw_pixel@plt>
mov    0x48(%rsp),%eax
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1180 <draw_line+0x70>
jmp    1223 <draw_line+0x113>
jle    1223 <draw_line+0x113>
movsbl %r8b,%r12d
movsbl %r9b,%r13d
movsbl %cl,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
mov    %eax,%r9d
call   1030 <draw_pixel@plt>
mov    0x48(%rsp),%eax
add    $0x1,%r15d
cmp    %r15d,%ebx
jne    11c0 <draw_line+0xb0>
jmp    1223 <draw_line+0x113>
jle    1223 <draw_line+0x113>
movsbl %r8b,%r14d
movsbl %r9b,%r13d
movsbl %cl,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r13d,%ecx
mov    %r15d,%r8d
mov    %eax,%r9d
call   1030 <draw_pixel@plt>
mov    0x48(%rsp),%eax
add    $0x1,%r12d
cmp    %r12d,%ebp
jne    1200 <draw_line+0xf0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @draw_line(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i8
%15 = alloca i8
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i8 %4, i8* %13
store i8 %5, i8* %14
store i8 %6, i8* %15
store i32 %7, i32* %16
%19 = load i32, i32* %9
%20 = load i32, i32* %11
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %63
22: ; preds = %8
%23 = load i32, i32* %10
%24 = load i32, i32* %12
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load i32, i32* %10
store i32 %27, i32* %18
br label %28
28: ; preds = %40, %26
%29 = load i32, i32* %18
%30 = load i32, i32* %12
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = load i32, i32* %9
%34 = load i32, i32* %18
%35 = load i8, i8* %13
%36 = load i8, i8* %14
%37 = load i8, i8* %15
%38 = load i32, i32* %16
%39 = call i32 @draw_pixel(i32 %33, i32 %34, i8 signext %35, i8 signext %36, i8 signext %37, i32 %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %18
%42 = add nsw i32 %41, 1
store i32 %42, i32* %18
br label %28
43: ; preds = %28
br label %62
44: ; preds = %22
%45 = load i32, i32* %12
store i32 %45, i32* %18
br label %46
46: ; preds = %58, %44
%47 = load i32, i32* %18
%48 = load i32, i32* %10
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %61
50: ; preds = %46
%51 = load i32, i32* %9
%52 = load i32, i32* %18
%53 = load i8, i8* %13
%54 = load i8, i8* %14
%55 = load i8, i8* %15
%56 = load i32, i32* %16
%57 = call i32 @draw_pixel(i32 %51, i32 %52, i8 signext %53, i8 signext %54, i8 signext %55, i32 %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %18
%60 = add nsw i32 %59, 1
store i32 %60, i32* %18
br label %46
61: ; preds = %46
br label %62
62: ; preds = %61, %43
br label %104
63: ; preds = %8
%64 = load i32, i32* %9
%65 = load i32, i32* %11
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %85
67: ; preds = %63
%68 = load i32, i32* %9
store i32 %68, i32* %17
br label %69
69: ; preds = %81, %67
%70 = load i32, i32* %17
%71 = load i32, i32* %11
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %84
73: ; preds = %69
%74 = load i32, i32* %17
%75 = load i32, i32* %10
%76 = load i8, i8* %13
%77 = load i8, i8* %14
%78 = load i8, i8* %15
%79 = load i32, i32* %16
%80 = call i32 @draw_pixel(i32 %74, i32 %75, i8 signext %76, i8 signext %77, i8 signext %78, i32 %79)
br label %81
81: ; preds = %73
%82 = load i32, i32* %17
%83 = add nsw i32 %82, 1
store i32 %83, i32* %17
br label %69
84: ; preds = %69
br label %103
85: ; preds = %63
%86 = load i32, i32* %11
store i32 %86, i32* %17
br label %87
87: ; preds = %99, %85
%88 = load i32, i32* %17
%89 = load i32, i32* %9
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %102
91: ; preds = %87
%92 = load i32, i32* %17
%93 = load i32, i32* %10
%94 = load i8, i8* %13
%95 = load i8, i8* %14
%96 = load i8, i8* %15
%97 = load i32, i32* %16
%98 = call i32 @draw_pixel(i32 %92, i32 %93, i8 signext %94, i8 signext %95, i8 signext %96, i32 %97)
br label %99
99: ; preds = %91
%100 = load i32, i32* %17
%101 = add nsw i32 %100, 1
store i32 %101, i32* %17
br label %87
102: ; preds = %87
br label %103
103: ; preds = %102, %84
br label %104
104: ; preds = %103, %62
ret void
}

LLVM IR (-O2):
define void @draw_line(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7) {
%9 = icmp eq i32 %0, %2
br i1 %9, label %10, label %24
10: ; preds = %8
%11 = icmp slt i32 %1, %3
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = icmp slt i32 %3, %1
br i1 %13, label %19, label %38
14: ; preds = %10, %14
%15 = phi i32 [ %17, %14 ], [ %1, %10 ]
%16 = tail call i32 @draw_pixel(i32 %0, i32 %15, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7)
%17 = add i32 %15, 1
%18 = icmp eq i32 %17, %3
br i1 %18, label %38, label %14
19: ; preds = %12, %19
%20 = phi i32 [ %22, %19 ], [ %3, %12 ]
%21 = tail call i32 @draw_pixel(i32 %0, i32 %20, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7)
%22 = add i32 %20, 1
%23 = icmp eq i32 %22, %1
br i1 %23, label %38, label %19
24: ; preds = %8
%25 = icmp slt i32 %0, %2
br i1 %25, label %28, label %26
26: ; preds = %24
%27 = icmp slt i32 %2, %0
br i1 %27, label %33, label %38
28: ; preds = %24, %28
%29 = phi i32 [ %31, %28 ], [ %0, %24 ]
%30 = tail call i32 @draw_pixel(i32 %29, i32 %1, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7)
%31 = add i32 %29, 1
%32 = icmp eq i32 %31, %2
br i1 %32, label %38, label %28
33: ; preds = %26, %33
%34 = phi i32 [ %36, %33 ], [ %2, %26 ]
%35 = tail call i32 @draw_pixel(i32 %34, i32 %1, i8 signext %4, i8 signext %5, i8 signext %6, i32 %7)
%36 = add i32 %34, 1
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %33
38: ; preds = %33, %28, %19, %14, %26, %12
ret void
}