#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*/ gln_linegraphics_plot_clip(int, int, int, int);
void gln_linegraphics_draw_line_if(int x1, int y1, int x2, int y2, int colour1,
                                   int colour2) {
  int x, y, dx, dy, incx, incy, balance;
  if (colour1 == colour2)
    return;
  if (x2 >= x1) {
    dx = x2 - x1;
    incx = 1;
  } else {
    dx = x1 - x2;
    incx = -1;
  }
  if (y2 >= y1) {
    dy = y2 - y1;
    incy = 1;
  } else {
    dy = y1 - y2;
    incy = -1;
  }
  x = x1;
  y = y1;
  if (dx >= dy) {
    dy <<= 1;
    balance = dy - dx;
    dx <<= 1;
    while (x != x2) {
      gln_linegraphics_plot_clip(x, y, colour1, colour2);
      if (balance >= 0) {
        y += incy;
        balance -= dx;
      }
      balance += dy;
      x += incx;
    }
    gln_linegraphics_plot_clip(x, y, colour1, colour2);
  } else {
    dx <<= 1;
    balance = dx - dy;
    dy <<= 1;
    while (y != y2) {
      gln_linegraphics_plot_clip(x, y, colour1, colour2);
      if (balance >= 0) {
        x += incx;
        balance -= dy;
      }
      balance += dx;
      y += incy;
    }
    gln_linegraphics_plot_clip(x, y, colour1, colour2);
  }
}


x86 assembly (clang, -O0):
<gln_linegraphics_draw_line_if>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    113d <gln_linegraphics_draw_line_if+0x2d>
jmp    12b8 <gln_linegraphics_draw_line_if+0x1a8>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     115e <gln_linegraphics_draw_line_if+0x4e>
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    116e <gln_linegraphics_draw_line_if+0x5e>
mov    -0x4(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     118f <gln_linegraphics_draw_line_if+0x7f>
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    119f <gln_linegraphics_draw_line_if+0x8f>
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0xffffffff,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     123a <gln_linegraphics_draw_line_if+0x12a>
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1224 <gln_linegraphics_draw_line_if+0x114>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
cmpl   $0x0,-0x34(%rbp)
jl     120d <gln_linegraphics_draw_line_if+0xfd>
mov    -0x30(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11d2 <gln_linegraphics_draw_line_if+0xc2>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
jmp    12b8 <gln_linegraphics_draw_line_if+0x1a8>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     12a7 <gln_linegraphics_draw_line_if+0x197>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
cmpl   $0x0,-0x34(%rbp)
jl     1290 <gln_linegraphics_draw_line_if+0x180>
mov    -0x2c(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1255 <gln_linegraphics_draw_line_if+0x145>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gln_linegraphics_draw_line_if>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    %r9d,%r8d
jne    1132 <gln_linegraphics_draw_line_if+0x22>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %ecx,%eax
sub    %esi,%eax
neg    %eax
xor    %ecx,%ecx
mov    %r13d,%esi
sub    %ebx,%esi
setge  %cl
cmovl  %eax,%esi
mov    %edx,%eax
sub    %edi,%eax
neg    %eax
xor    %edx,%edx
mov    %r14d,%r15d
sub    %edi,%r15d
cmovl  %eax,%r15d
setge  %dl
lea    -0x1(%rdx,%rdx,1),%eax
mov    %eax,0x10(%rsp)
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
cmp    %esi,%r15d
mov    %r8d,0x14(%rsp)
jge    118a <gln_linegraphics_draw_line_if+0x7a>
cmp    %r13d,%ebx
jne    1197 <gln_linegraphics_draw_line_if+0x87>
mov    %r9d,%r14d
jmp    11ec <gln_linegraphics_draw_line_if+0xdc>
cmp    %r14d,%ebp
jne    11f9 <gln_linegraphics_draw_line_if+0xe9>
mov    %r9d,%r13d
jmp    1252 <gln_linegraphics_draw_line_if+0x142>
add    %r15d,%r15d
lea    (%rsi,%rsi,1),%eax
neg    %eax
mov    %eax,0x8(%rsp)
mov    %r15d,%r12d
sub    %esi,%r12d
mov    %r9d,%r14d
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r8d,%edx
mov    %r14d,%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
mov    0x14(%rsp),%r8d
test   %r12d,%r12d
mov    $0x0,%eax
cmovns 0x10(%rsp),%eax
mov    $0x0,%ecx
cmovns 0x8(%rsp),%ecx
add    %eax,%ebp
add    %r15d,%r12d
add    %ecx,%r12d
add    0xc(%rsp),%ebx
cmp    %ebx,%r13d
jne    11b0 <gln_linegraphics_draw_line_if+0xa0>
mov    %ebp,%edi
mov    %r13d,%esi
mov    %r8d,%edx
mov    %r14d,%ecx
jmp    125d <gln_linegraphics_draw_line_if+0x14d>
add    %esi,%esi
lea    (%r15,%r15,1),%eax
neg    %eax
mov    %eax,0x8(%rsp)
mov    %esi,%r12d
sub    %r15d,%r12d
mov    %r9d,%r13d
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rsi,%r15
mov    %ebx,%esi
mov    %r8d,%edx
mov    %r13d,%ecx
call   1030 <gln_linegraphics_plot_clip@plt>
mov    %r15,%rsi
mov    0x14(%rsp),%r8d
test   %r12d,%r12d
mov    $0x0,%eax
cmovns 0xc(%rsp),%eax
mov    $0x0,%ecx
cmovns 0x8(%rsp),%ecx
add    %eax,%ebx
add    %esi,%r12d
add    %ecx,%r12d
add    0x10(%rsp),%ebp
cmp    %ebp,%r14d
jne    1210 <gln_linegraphics_draw_line_if+0x100>
mov    %r14d,%edi
mov    %ebx,%esi
mov    %r8d,%edx
mov    %r13d,%ecx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <gln_linegraphics_plot_clip@plt>

LLVM IR (-O0):
define void @gln_linegraphics_draw_line_if(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %6
br label %134
24: ; preds = %6
%25 = load i32, i32* %9
%26 = load i32, i32* %7
%27 = icmp sge i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %9
%30 = load i32, i32* %7
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %15
store i32 1, i32* %17
br label %36
32: ; preds = %24
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = sub nsw i32 %33, %34
store i32 %35, i32* %15
store i32 -1, i32* %17
br label %36
36: ; preds = %32, %28
%37 = load i32, i32* %10
%38 = load i32, i32* %8
%39 = icmp sge i32 %37, %38
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i32, i32* %10
%42 = load i32, i32* %8
%43 = sub nsw i32 %41, %42
store i32 %43, i32* %16
store i32 1, i32* %18
br label %48
44: ; preds = %36
%45 = load i32, i32* %8
%46 = load i32, i32* %10
%47 = sub nsw i32 %45, %46
store i32 %47, i32* %16
store i32 -1, i32* %18
br label %48
48: ; preds = %44, %40
%49 = load i32, i32* %7
store i32 %49, i32* %13
%50 = load i32, i32* %8
store i32 %50, i32* %14
%51 = load i32, i32* %15
%52 = load i32, i32* %16
%53 = icmp sge i32 %51, %52
br i1 %53, label %54, label %94
54: ; preds = %48
%55 = load i32, i32* %16
%56 = shl i32 %55, 1
store i32 %56, i32* %16
%57 = load i32, i32* %16
%58 = load i32, i32* %15
%59 = sub nsw i32 %57, %58
store i32 %59, i32* %19
%60 = load i32, i32* %15
%61 = shl i32 %60, 1
store i32 %61, i32* %15
br label %62
62: ; preds = %81, %54
%63 = load i32, i32* %13
%64 = load i32, i32* %9
%65 = icmp ne i32 %63, %64
br i1 %65, label %66, label %88
66: ; preds = %62
%67 = load i32, i32* %13
%68 = load i32, i32* %14
%69 = load i32, i32* %11
%70 = load i32, i32* %12
%71 = call i32 @gln_linegraphics_plot_clip(i32 %67, i32 %68, i32 %69, i32 %70)
%72 = load i32, i32* %19
%73 = icmp sge i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %66
%75 = load i32, i32* %18
%76 = load i32, i32* %14
%77 = add nsw i32 %76, %75
store i32 %77, i32* %14
%78 = load i32, i32* %15
%79 = load i32, i32* %19
%80 = sub nsw i32 %79, %78
store i32 %80, i32* %19
br label %81
81: ; preds = %74, %66
%82 = load i32, i32* %16
%83 = load i32, i32* %19
%84 = add nsw i32 %83, %82
store i32 %84, i32* %19
%85 = load i32, i32* %17
%86 = load i32, i32* %13
%87 = add nsw i32 %86, %85
store i32 %87, i32* %13
br label %62
88: ; preds = %62
%89 = load i32, i32* %13
%90 = load i32, i32* %14
%91 = load i32, i32* %11
%92 = load i32, i32* %12
%93 = call i32 @gln_linegraphics_plot_clip(i32 %89, i32 %90, i32 %91, i32 %92)
br label %134
94: ; preds = %48
%95 = load i32, i32* %15
%96 = shl i32 %95, 1
store i32 %96, i32* %15
%97 = load i32, i32* %15
%98 = load i32, i32* %16
%99 = sub nsw i32 %97, %98
store i32 %99, i32* %19
%100 = load i32, i32* %16
%101 = shl i32 %100, 1
store i32 %101, i32* %16
br label %102
102: ; preds = %121, %94
%103 = load i32, i32* %14
%104 = load i32, i32* %10
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %128
106: ; preds = %102
%107 = load i32, i32* %13
%108 = load i32, i32* %14
%109 = load i32, i32* %11
%110 = load i32, i32* %12
%111 = call i32 @gln_linegraphics_plot_clip(i32 %107, i32 %108, i32 %109, i32 %110)
%112 = load i32, i32* %19
%113 = icmp sge i32 %112, 0
br i1 %113, label %114, label %121
114: ; preds = %106
%115 = load i32, i32* %17
%116 = load i32, i32* %13
%117 = add nsw i32 %116, %115
store i32 %117, i32* %13
%118 = load i32, i32* %16
%119 = load i32, i32* %19
%120 = sub nsw i32 %119, %118
store i32 %120, i32* %19
br label %121
121: ; preds = %114, %106
%122 = load i32, i32* %15
%123 = load i32, i32* %19
%124 = add nsw i32 %123, %122
store i32 %124, i32* %19
%125 = load i32, i32* %18
%126 = load i32, i32* %14
%127 = add nsw i32 %126, %125
store i32 %127, i32* %14
br label %102
128: ; preds = %102
%129 = load i32, i32* %13
%130 = load i32, i32* %14
%131 = load i32, i32* %11
%132 = load i32, i32* %12
%133 = call i32 @gln_linegraphics_plot_clip(i32 %129, i32 %130, i32 %131, i32 %132)
br label %134
134: ; preds = %23, %128, %88
ret void
}

LLVM IR (-O2):
define void @gln_linegraphics_draw_line_if(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %4, %5
br i1 %7, label %64, label %8
8: ; preds = %6
%9 = icmp slt i32 %2, %0
%10 = sub nsw i32 %2, %0
%11 = sub nsw i32 %0, %2
%12 = select i1 %9, i32 %11, i32 %10
%13 = select i1 %9, i32 -1, i32 1
%14 = icmp slt i32 %3, %1
%15 = sub nsw i32 %3, %1
%16 = sub nsw i32 %1, %3
%17 = select i1 %14, i32 %16, i32 %15
%18 = select i1 %14, i32 -1, i32 1
%19 = icmp slt i32 %12, %17
br i1 %19, label %42, label %20
20: ; preds = %8
%21 = shl i32 %17, 1
%22 = mul i32 %12, -2
%23 = icmp eq i32 %0, %2
br i1 %23, label %39, label %24
24: ; preds = %20
%25 = sub nsw i32 %21, %12
br label %26
26: ; preds = %24, %26
%27 = phi i32 [ %36, %26 ], [ %25, %24 ]
%28 = phi i32 [ %33, %26 ], [ %1, %24 ]
%29 = phi i32 [ %37, %26 ], [ %0, %24 ]
%30 = tail call i32 @gln_linegraphics_plot_clip(i32 %29, i32 %28, i32 %4, i32 %5)
%31 = icmp sgt i32 %27, -1
%32 = select i1 %31, i32 %18, i32 0
%33 = add nsw i32 %32, %28
%34 = select i1 %31, i32 %22, i32 0
%35 = add i32 %27, %21
%36 = add i32 %35, %34
%37 = add nsw i32 %29, %13
%38 = icmp eq i32 %37, %2
br i1 %38, label %39, label %26
39: ; preds = %26, %20
%40 = phi i32 [ %1, %20 ], [ %33, %26 ]
%41 = tail call i32 @gln_linegraphics_plot_clip(i32 %2, i32 %40, i32 %4, i32 %5)
br label %64
42: ; preds = %8
%43 = shl i32 %12, 1
%44 = mul i32 %17, -2
%45 = icmp eq i32 %1, %3
br i1 %45, label %61, label %46
46: ; preds = %42
%47 = sub nsw i32 %43, %17
br label %48
48: ; preds = %46, %48
%49 = phi i32 [ %58, %48 ], [ %47, %46 ]
%50 = phi i32 [ %59, %48 ], [ %1, %46 ]
%51 = phi i32 [ %55, %48 ], [ %0, %46 ]
%52 = tail call i32 @gln_linegraphics_plot_clip(i32 %51, i32 %50, i32 %4, i32 %5)
%53 = icmp sgt i32 %49, -1
%54 = select i1 %53, i32 %13, i32 0
%55 = add nsw i32 %54, %51
%56 = select i1 %53, i32 %44, i32 0
%57 = add i32 %49, %43
%58 = add i32 %57, %56
%59 = add nsw i32 %50, %18
%60 = icmp eq i32 %59, %3
br i1 %60, label %61, label %48
61: ; preds = %48, %42
%62 = phi i32 [ %0, %42 ], [ %55, %48 ]
%63 = tail call i32 @gln_linegraphics_plot_clip(i32 %62, i32 %3, i32 %4, i32 %5)
br label %64
64: ; preds = %39, %61, %6
ret void
}