#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 */
struct tilecontext {
  int dummy;
};
struct graphics {
  int dummy;
};

/* Variables and functions */
int abs(int);
int ceil(double);
int /*<<< orphan*/ drawPixel(int, int, struct graphics *, double, double,
                             long long, struct tilecontext *);
void drawLine(int x0, int y0, int x1, int y1, struct graphics *g, double bright,
              double hue, long long meta, double thick,
              struct tilecontext *tc) {
  int dx = abs(x1 - x0), sx = (x0 < x1) ? 1 : -1;
  int dy = abs(y1 - y0), sy = (y0 < y1) ? 1 : -1;
  int err = ((dx > dy) ? dx : -dy) / 2, e2;
  while (1) {
    if (x0 == x1 && y0 == y1) {
      break;
    }
    drawPixel(x0, y0, g, bright, hue, meta, tc);
    int n;
    for (n = 1; n < ceil(thick / 2); n++) {
      if (dx > dy) {
        drawPixel(x0, y0 - n, g, bright, hue, meta, tc);
        drawPixel(x0, y0 + n, g, bright, hue, meta, tc);
      } else {
        drawPixel(x0 - n, y0, g, bright, hue, meta, tc);
        drawPixel(x0 + n, y0, g, bright, hue, meta, tc);
      }
    }
    e2 = err;
    if (e2 > -dx) {
      err -= dy;
      x0 += sx;
    }
    if (e2 < dy) {
      err += dx;
      y0 += sy;
    }
  }
}


x86 assembly (clang, -O0):
<drawLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x4(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%edi
sub    -0x8(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    11c2 <drawLine+0x92>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11ca <drawLine+0x9a>
xor    %eax,%eax
sub    -0x44(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11f5 <drawLine+0xc5>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11f5 <drawLine+0xc5>
jmp    1347 <drawLine+0x217>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <drawPixel@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdd0(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <ceil@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jge    12fa <drawLine+0x1ca>
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    129f <drawLine+0x16f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    -0x54(%rbp),%esi
mov    -0x18(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <drawPixel@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x54(%rbp),%esi
mov    -0x18(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <drawPixel@plt>
jmp    12e7 <drawLine+0x1b7>
mov    -0x4(%rbp),%edi
sub    -0x54(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <drawPixel@plt>
mov    -0x4(%rbp),%edi
add    -0x54(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <drawPixel@plt>
jmp    12ec <drawLine+0x1bc>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    121d <drawLine+0xed>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
xor    %ecx,%ecx
sub    -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jle    1324 <drawLine+0x1f4>
mov    -0x44(%rbp),%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1342 <drawLine+0x212>
mov    -0x3c(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <drawLine+0xa8>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%ebp
sub    %edi,%ebp
mov    %ebp,%eax
neg    %eax
cmovs  %ebp,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
mov    %ecx,0x1c(%rsp)
mov    %ecx,%ebp
sub    %esi,%ebp
setg   %r10b
mov    %ebp,%ecx
neg    %ecx
cmovs  %ebp,%ecx
mov    %ecx,0x8(%rsp)
movsd  %xmm2,0x20(%rsp)
movapd %xmm0,%xmm2
mov    %r8,%r11
xor    %ebp,%ebp
mov    %edx,0x60(%rsp)
cmp    %edi,%edx
setg   %cl
jne    117a <drawLine+0x5a>
cmp    %esi,0x1c(%rsp)
je     138c <drawLine+0x26c>
mov    0xa0(%rsp),%r8
mov    %cl,%bpl
mov    0x8(%rsp),%ebx
mov    %ebx,%ecx
neg    %ecx
mov    0xc(%rsp),%edx
cmp    %ebx,%edx
cmova  %edx,%ecx
lea    -0x1(%rbp,%rbp,1),%ebx
mov    %ebx,0x5c(%rsp)
mov    %r10b,%al
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x58(%rsp)
mov    %ecx,%ebp
shr    $0x1f,%ebp
add    %ecx,%ebp
sar    %ebp
movsd  0x20(%rsp),%xmm0
mulsd  0xe3f(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
neg    %edx
mov    %edx,0x54(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
mov    %r9,0x40(%rsp)
mov    %r11,0x38(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,0x64(%rsp)
mov    %rdi,0x10(%rsp)
mov    %rsi,0x48(%rsp)
mov    %r11,%rdx
movapd %xmm2,%xmm0
mov    %r9,%rcx
call   1030 <drawPixel@plt>
movsd  0x20(%rsp),%xmm0
call   1040 <ceil@plt>
cmp    $0x2,%eax
jl     1310 <drawLine+0x1f0>
mov    $0x1,%r14d
mov    $0xffffffff,%r15d
jmp    12a9 <drawLine+0x189>
nop
mov    0x10(%rsp),%rax
lea    (%rax,%r15,1),%edi
mov    0x48(%rsp),%rbp
mov    %ebp,%esi
mov    0x38(%rsp),%rbx
mov    %rbx,%rdx
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    0x40(%rsp),%r13
mov    %r13,%rcx
mov    0xa0(%rsp),%r12
mov    %r12,%r8
call   1030 <drawPixel@plt>
mov    0x10(%rsp),%rax
lea    (%rax,%r14,1),%edi
mov    %ebp,%esi
mov    %rbx,%rdx
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    %r13,%rcx
mov    %r12,%r8
call   1030 <drawPixel@plt>
add    $0x1,%r14d
movsd  0x20(%rsp),%xmm0
call   1040 <ceil@plt>
add    $0xffffffff,%r15d
cmp    %eax,%r14d
jge    1310 <drawLine+0x1f0>
mov    0x8(%rsp),%eax
cmp    %eax,0xc(%rsp)
jbe    1230 <drawLine+0x110>
mov    0x48(%rsp),%rbp
lea    (%r15,%rbp,1),%esi
mov    0x10(%rsp),%rdi
mov    0x38(%rsp),%rbx
mov    %rbx,%rdx
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    0x40(%rsp),%r13
mov    %r13,%rcx
mov    0xa0(%rsp),%r12
mov    %r12,%r8
call   1030 <drawPixel@plt>
lea    (%r14,%rbp,1),%esi
mov    0x10(%rsp),%rax
mov    %eax,%edi
jmp    1277 <drawLine+0x157>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x64(%rsp),%edi
cmp    0x54(%rsp),%edi
mov    $0x0,%ecx
mov    0x8(%rsp),%esi
cmovg  %esi,%ecx
mov    $0x0,%eax
cmovg  0x5c(%rsp),%eax
mov    %edi,%edx
sub    %ecx,%edx
add    0x10(%rsp),%eax
cmp    %esi,%edi
mov    $0x0,%ecx
cmovl  0x58(%rsp),%ecx
mov    $0x0,%ebp
cmovl  0xc(%rsp),%ebp
add    0x48(%rsp),%ecx
add    %edx,%ebp
mov    %eax,%edi
mov    %ecx,%esi
cmp    0x60(%rsp),%eax
movsd  0x30(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
mov    0xa0(%rsp),%r8
mov    0x40(%rsp),%r9
mov    0x38(%rsp),%r11
jne    11f0 <drawLine+0xd0>
mov    %eax,%edi
mov    %ecx,%esi
cmp    0x1c(%rsp),%ecx
jne    11f0 <drawLine+0xd0>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.graphics = type { i32 }
%struct.tilecontext = type { i32 }
define void @drawLine(i32 %0, i32 %1, i32 %2, i32 %3, %struct.graphics* %4, double %5, double %6, i64 %7, double %8, %struct.tilecontext* %9) {
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.graphics*
%16 = alloca double
%17 = alloca double
%18 = alloca i64
%19 = alloca double
%20 = alloca %struct.tilecontext*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i32 %0, i32* %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store %struct.graphics* %4, %struct.graphics** %15
store double %5, double* %16
store double %6, double* %17
store i64 %7, i64* %18
store double %8, double* %19
store %struct.tilecontext* %9, %struct.tilecontext** %20
%28 = load i32, i32* %13
%29 = load i32, i32* %11
%30 = sub nsw i32 %28, %29
%31 = call i32 @abs(i32 %30)
store i32 %31, i32* %21
%32 = load i32, i32* %11
%33 = load i32, i32* %13
%34 = icmp slt i32 %32, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 -1
store i32 %36, i32* %22
%37 = load i32, i32* %14
%38 = load i32, i32* %12
%39 = sub nsw i32 %37, %38
%40 = call i32 @abs(i32 %39)
store i32 %40, i32* %23
%41 = load i32, i32* %12
%42 = load i32, i32* %14
%43 = icmp slt i32 %41, %42
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 1, i32 -1
store i32 %45, i32* %24
%46 = load i32, i32* %21
%47 = load i32, i32* %23
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %10
%50 = load i32, i32* %21
br label %54
51: ; preds = %10
%52 = load i32, i32* %23
%53 = sub nsw i32 0, %52
br label %54
54: ; preds = %51, %49
%55 = phi i32 [ %50, %49 ], [ %53, %51 ]
%56 = sdiv i32 %55, 2
store i32 %56, i32* %25
br label %57
57: ; preds = %54, %155
%58 = load i32, i32* %11
%59 = load i32, i32* %13
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %66
61: ; preds = %57
%62 = load i32, i32* %12
%63 = load i32, i32* %14
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %66
65: ; preds = %61
br label %156
66: ; preds = %61, %57
%67 = load i32, i32* %11
%68 = load i32, i32* %12
%69 = load %struct.graphics*, %struct.graphics** %15
%70 = load double, double* %16
%71 = load double, double* %17
%72 = load i64, i64* %18
%73 = load %struct.tilecontext*, %struct.tilecontext** %20
%74 = call i32 @drawPixel(i32 %67, i32 %68, %struct.graphics* %69, double %70, double %71, i64 %72, %struct.tilecontext* %73)
store i32 1, i32* %27
br label %75
75: ; preds = %128, %66
%76 = load i32, i32* %27
%77 = load double, double* %19
%78 = fdiv double %77, 2.000000e+00
%79 = call i32 @ceil(double %78)
%80 = icmp slt i32 %76, %79
br i1 %80, label %81, label %131
81: ; preds = %75
%82 = load i32, i32* %21
%83 = load i32, i32* %23
%84 = icmp sgt i32 %82, %83
br i1 %84, label %85, label %106
85: ; preds = %81
%86 = load i32, i32* %11
%87 = load i32, i32* %12
%88 = load i32, i32* %27
%89 = sub nsw i32 %87, %88
%90 = load %struct.graphics*, %struct.graphics** %15
%91 = load double, double* %16
%92 = load double, double* %17
%93 = load i64, i64* %18
%94 = load %struct.tilecontext*, %struct.tilecontext** %20
%95 = call i32 @drawPixel(i32 %86, i32 %89, %struct.graphics* %90, double %91, double %92, i64 %93, %struct.tilecontext* %94)
%96 = load i32, i32* %11
%97 = load i32, i32* %12
%98 = load i32, i32* %27
%99 = add nsw i32 %97, %98
%100 = load %struct.graphics*, %struct.graphics** %15
%101 = load double, double* %16
%102 = load double, double* %17
%103 = load i64, i64* %18
%104 = load %struct.tilecontext*, %struct.tilecontext** %20
%105 = call i32 @drawPixel(i32 %96, i32 %99, %struct.graphics* %100, double %101, double %102, i64 %103, %struct.tilecontext* %104)
br label %127
106: ; preds = %81
%107 = load i32, i32* %11
%108 = load i32, i32* %27
%109 = sub nsw i32 %107, %108
%110 = load i32, i32* %12
%111 = load %struct.graphics*, %struct.graphics** %15
%112 = load double, double* %16
%113 = load double, double* %17
%114 = load i64, i64* %18
%115 = load %struct.tilecontext*, %struct.tilecontext** %20
%116 = call i32 @drawPixel(i32 %109, i32 %110, %struct.graphics* %111, double %112, double %113, i64 %114, %struct.tilecontext* %115)
%117 = load i32, i32* %11
%118 = load i32, i32* %27
%119 = add nsw i32 %117, %118
%120 = load i32, i32* %12
%121 = load %struct.graphics*, %struct.graphics** %15
%122 = load double, double* %16
%123 = load double, double* %17
%124 = load i64, i64* %18
%125 = load %struct.tilecontext*, %struct.tilecontext** %20
%126 = call i32 @drawPixel(i32 %119, i32 %120, %struct.graphics* %121, double %122, double %123, i64 %124, %struct.tilecontext* %125)
br label %127
127: ; preds = %106, %85
br label %128
128: ; preds = %127
%129 = load i32, i32* %27
%130 = add nsw i32 %129, 1
store i32 %130, i32* %27
br label %75
131: ; preds = %75
%132 = load i32, i32* %25
store i32 %132, i32* %26
%133 = load i32, i32* %26
%134 = load i32, i32* %21
%135 = sub nsw i32 0, %134
%136 = icmp sgt i32 %133, %135
br i1 %136, label %137, label %144
137: ; preds = %131
%138 = load i32, i32* %23
%139 = load i32, i32* %25
%140 = sub nsw i32 %139, %138
store i32 %140, i32* %25
%141 = load i32, i32* %22
%142 = load i32, i32* %11
%143 = add nsw i32 %142, %141
store i32 %143, i32* %11
br label %144
144: ; preds = %137, %131
%145 = load i32, i32* %26
%146 = load i32, i32* %23
%147 = icmp slt i32 %145, %146
br i1 %147, label %148, label %155
148: ; preds = %144
%149 = load i32, i32* %21
%150 = load i32, i32* %25
%151 = add nsw i32 %150, %149
store i32 %151, i32* %25
%152 = load i32, i32* %24
%153 = load i32, i32* %12
%154 = add nsw i32 %153, %152
store i32 %154, i32* %12
br label %155
155: ; preds = %148, %144
br label %57
156: ; preds = %65
ret void
}

LLVM IR (-O2):
%struct.graphics = type { i32 }
%struct.tilecontext = type { i32 }
define void @drawLine(i32 %0, i32 %1, i32 %2, i32 %3, %struct.graphics* %4, double %5, double %6, i64 %7, double %8, %struct.tilecontext* %9) {
%11 = sub nsw i32 %2, %0
%12 = tail call i32 @llvm.abs.i32(i32 %11, i1 true)
%13 = icmp sgt i32 %2, %0
%14 = select i1 %13, i32 1, i32 -1
%15 = sub nsw i32 %3, %1
%16 = tail call i32 @llvm.abs.i32(i32 %15, i1 true)
%17 = icmp sgt i32 %3, %1
%18 = select i1 %17, i32 1, i32 -1
%19 = icmp ugt i32 %12, %16
%20 = icmp eq i32 %2, %0
%21 = icmp eq i32 %3, %1
%22 = and i1 %20, %21
br i1 %22, label %67, label %23
23: ; preds = %10
%24 = sub nsw i32 0, %16
%25 = select i1 %19, i32 %12, i32 %24
%26 = sdiv i32 %25, 2
%27 = fmul double %8, 5.000000e-01
%28 = sub nsw i32 0, %12
br label %29
29: ; preds = %23, %53
%30 = phi i32 [ %0, %23 ], [ %58, %53 ]
%31 = phi i32 [ %26, %23 ], [ %63, %53 ]
%32 = phi i32 [ %1, %23 ], [ %61, %53 ]
%33 = tail call i32 @drawPixel(i32 %30, i32 %32, %struct.graphics* %4, double %5, double %6, i64 %7, %struct.tilecontext* %9)
%34 = tail call i32 @ceil(double %27)
%35 = icmp sgt i32 %34, 1
br i1 %35, label %36, label %53
36: ; preds = %29, %46
%37 = phi i32 [ %50, %46 ], [ 1, %29 ]
br i1 %19, label %38, label %42
38: ; preds = %36
%39 = sub nsw i32 %32, %37
%40 = tail call i32 @drawPixel(i32 %30, i32 %39, %struct.graphics* %4, double %5, double %6, i64 %7, %struct.tilecontext* %9)
%41 = add nsw i32 %37, %32
br label %46
42: ; preds = %36
%43 = sub nsw i32 %30, %37
%44 = tail call i32 @drawPixel(i32 %43, i32 %32, %struct.graphics* %4, double %5, double %6, i64 %7, %struct.tilecontext* %9)
%45 = add nsw i32 %37, %30
br label %46
46: ; preds = %38, %42
%47 = phi i32 [ %41, %38 ], [ %32, %42 ]
%48 = phi i32 [ %30, %38 ], [ %45, %42 ]
%49 = tail call i32 @drawPixel(i32 %48, i32 %47, %struct.graphics* %4, double %5, double %6, i64 %7, %struct.tilecontext* %9)
%50 = add nuw nsw i32 %37, 1
%51 = tail call i32 @ceil(double %27)
%52 = icmp slt i32 %50, %51
br i1 %52, label %36, label %53
53: ; preds = %46, %29
%54 = icmp sgt i32 %31, %28
%55 = select i1 %54, i32 %16, i32 0
%56 = sub i32 %31, %55
%57 = select i1 %54, i32 %14, i32 0
%58 = add nsw i32 %57, %30
%59 = icmp slt i32 %31, %16
%60 = select i1 %59, i32 %18, i32 0
%61 = add nsw i32 %60, %32
%62 = select i1 %59, i32 %12, i32 0
%63 = add nsw i32 %56, %62
%64 = icmp eq i32 %58, %2
%65 = icmp eq i32 %61, %3
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %67, label %29
67: ; preds = %53, %10
ret void
}