#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(float, float, int);
void draw_line(float x1, float y1, float x2, float y2, int color) {
  float m = 0, c = 0, x = x1, y = y1, dy, dx;
  x = x1;
  y = y1;
  if (x1 != x2) {
    m = (y2 - y1) / (x2 - x1);
    c = y1 - (m * x1);
  } else
    m = 20;
  if ((m * m) >= 1)
    for (;;) {
      if (x1 != x2)
        x = (y - c) / m;
      draw_pixel(x, y, color);
      if (y2 > y1)
        y++;
      else
        y--;
      dy = y - y2;
      if (dy == 0)
        break;
      else
        continue;
    }
  else
    for (x = x1;;) {
      y = (m * x) + c;
      draw_pixel(x, y, color);
      if (x2 > x1)
        x++;
      else
        x--;
      dx = x - x2;
      if (dx == 0)
        break;
      else
        continue;
    }
}


x86 assembly (clang, -O0):
<draw_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1181 <draw_line+0x71>
jp     1181 <draw_line+0x71>
jmp    11cc <draw_line+0xbc>
movss  -0x10(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
subss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11d9 <draw_line+0xc9>
movss  0xe2c(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  0xe19(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     12a6 <draw_line+0x196>
jmp    11f9 <draw_line+0xe9>
movss  -0x4(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1213 <draw_line+0x103>
jp     1213 <draw_line+0x103>
jmp    1227 <draw_line+0x117>
movss  -0x24(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mov    -0x14(%rbp),%edi
call   1030 <draw_pixel@plt>
movss  -0x10(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    125f <draw_line+0x14f>
movss  0xdb4(%rip),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1271 <draw_line+0x161>
movss  0xda1(%rip),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    129c <draw_line+0x18c>
jp     129c <draw_line+0x18c>
jmp    12a1 <draw_line+0x191>
jmp    11f9 <draw_line+0xe9>
jmp    134b <draw_line+0x23b>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mov    -0x14(%rbp),%edi
call   1030 <draw_pixel@plt>
movss  -0xc(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1304 <draw_line+0x1f4>
movss  0xd0f(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1316 <draw_line+0x206>
movss  0xcfc(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1341 <draw_line+0x231>
jp     1341 <draw_line+0x231>
jmp    1346 <draw_line+0x236>
jmp    12b0 <draw_line+0x1a0>
jmp    134b <draw_line+0x23b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_line>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movaps %xmm1,%xmm6
ucomiss %xmm2,%xmm0
jne    1121 <draw_line+0x11>
jnp    1148 <draw_line+0x38>
movaps %xmm3,%xmm5
subss  %xmm6,%xmm5
movaps %xmm2,%xmm1
subss  %xmm0,%xmm1
divss  %xmm1,%xmm5
movaps %xmm5,%xmm1
mulss  %xmm0,%xmm1
movaps %xmm6,%xmm4
subss  %xmm1,%xmm4
movss  %xmm4,(%rsp)
jmp    1158 <draw_line+0x48>
movss  0xeb0(%rip),%xmm5
xorps  %xmm1,%xmm1
movss  %xmm1,(%rsp)
movaps %xmm5,%xmm1
mulss  %xmm5,%xmm1
ucomiss 0xe9e(%rip),%xmm1
movss  %xmm2,0x14(%rsp)
movss  %xmm5,0x10(%rsp)
jae    11d5 <draw_line+0xc5>
xor    %eax,%eax
ucomiss %xmm0,%xmm2
seta   %al
lea    0xe89(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
movss  %xmm1,0x4(%rsp)
xchg   %ax,%ax
movss  %xmm0,0x8(%rsp)
movaps %xmm5,%xmm1
mulss  %xmm0,%xmm1
addss  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <draw_pixel@plt>
movss  0x10(%rsp),%xmm5
movss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
movaps %xmm0,%xmm1
subss  0x14(%rsp),%xmm1
ucomiss 0xe3d(%rip),%xmm1
jne    1190 <draw_line+0x80>
jp     1190 <draw_line+0x80>
add    $0x20,%rsp
pop    %rbx
ret
xor    %eax,%eax
ucomiss %xmm6,%xmm3
seta   %al
lea    0xe28(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
movss  %xmm3,0x1c(%rsp)
jmp    1260 <draw_line+0x150>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0xc(%rsp),%xmm0
movaps %xmm6,%xmm1
mov    %ebx,%edi
movss  %xmm6,0x4(%rsp)
call   1030 <draw_pixel@plt>
movss  0x4(%rsp),%xmm6
movss  0x10(%rsp),%xmm5
addss  0x18(%rsp),%xmm6
movaps %xmm6,%xmm0
movss  0x1c(%rsp),%xmm3
subss  %xmm3,%xmm0
ucomiss 0xdbc(%rip),%xmm0
movss  0x14(%rsp),%xmm2
movss  0x8(%rsp),%xmm0
jne    1260 <draw_line+0x150>
jnp    11cf <draw_line+0xbf>
ucomiss %xmm2,%xmm0
jne    1267 <draw_line+0x157>
jnp    1210 <draw_line+0x100>
movaps %xmm6,%xmm0
subss  (%rsp),%xmm0
divss  %xmm5,%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1210 <draw_line+0x100>

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

LLVM IR (-O2):
define void @draw_line(float %0, float %1, float %2, float %3, i32 %4) {
%6 = fcmp une float %0, %2
br i1 %6, label %7, label %13
7: ; preds = %5
%8 = fsub float %3, %1
%9 = fsub float %2, %0
%10 = fdiv float %8, %9
%11 = fneg float %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float %0, float %1)
br label %13
13: ; preds = %5, %7
%14 = phi float [ %12, %7 ], [ 0.000000e+00, %5 ]
%15 = phi float [ %10, %7 ], [ 2.000000e+01, %5 ]
%16 = fmul float %15, %15
%17 = fcmp ult float %16, 1.000000e+00
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = fcmp ogt float %3, %1
%20 = select i1 %19, float 1.000000e+00, float -1.000000e+00
br label %24
21: ; preds = %13
%22 = fcmp ogt float %2, %0
%23 = select i1 %22, float 1.000000e+00, float -1.000000e+00
br label %36
24: ; preds = %18, %30
%25 = phi float [ %31, %30 ], [ %0, %18 ]
%26 = phi float [ %33, %30 ], [ %1, %18 ]
br i1 %6, label %27, label %30
27: ; preds = %24
%28 = fsub float %26, %14
%29 = fdiv float %28, %15
br label %30
30: ; preds = %27, %24
%31 = phi float [ %29, %27 ], [ %25, %24 ]
%32 = tail call i32 @draw_pixel(float %31, float %26, i32 %4)
%33 = fadd float %20, %26
%34 = fsub float %33, %3
%35 = fcmp oeq float %34, 0.000000e+00
br i1 %35, label %43, label %24
36: ; preds = %21, %36
%37 = phi float [ %40, %36 ], [ %0, %21 ]
%38 = tail call float @llvm.fmuladd.f32(float %15, float %37, float %14)
%39 = tail call i32 @draw_pixel(float %37, float %38, i32 %4)
%40 = fadd float %23, %37
%41 = fsub float %40, %2
%42 = fcmp oeq float %41, 0.000000e+00
br i1 %42, label %43, label %36
43: ; preds = %30, %36
ret void
}