#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*/ line(int, int, int, int, int);
int /*<<< orphan*/ line_flush();
int /*<<< orphan*/ line_initialize();
void do_line(double *xarray, double *yarray, int num_verticies, int category) {
  int node;
  num_verticies--;
  line_initialize();
  for (node = 0; node < num_verticies; node++) {
    line(category, (int)(xarray[node]), (int)(yarray[node] + .5),
         (int)(xarray[node + 1]), (int)(yarray[node + 1] + .5));
  }
  line_flush();
}


x86 assembly (clang, -O0):
<do_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <line_initialize@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d9 <do_line+0xa9>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xe77(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%ecx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
movslq %r8d,%r8
movsd  0xe45(%rip),%xmm0
addsd  (%rax,%r8,8),%xmm0
cvttsd2si %xmm0,%r8d
call   1050 <line@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115d <do_line+0x2d>
mov    $0x0,%al
call   1030 <line_flush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <line_initialize@plt>
cmp    $0x2,%r15d
jl     11a5 <do_line+0x75>
add    $0xffffffff,%r15d
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
cvttsd2si (%rbx,%rax,8),%esi
movsd  (%r12,%rax,8),%xmm0
movsd  0xe8d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
lea    0x1(%rax),%rbp
cvttsd2si 0x8(%rbx,%rax,8),%ecx
movsd  0x8(%r12,%rax,8),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
mov    %r14d,%edi
call   1050 <line@plt>
mov    %rbp,%rax
cmp    %rbp,%r15
jne    1160 <do_line+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <line_flush@plt>

LLVM IR (-O0):
define void @do_line(double* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = call i32 (...) @line_initialize()
store i32 0, i32* %9
br label %13
13: ; preds = %48, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %51
17: ; preds = %13
%18 = load i32, i32* %8
%19 = load double*, double** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = fptosi double %23 to i32
%25 = load double*, double** %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fadd double %29, 5.000000e-01
%31 = fptosi double %30 to i32
%32 = load double*, double** %5
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %32, i64 %35
%37 = load double, double* %36
%38 = fptosi double %37 to i32
%39 = load double*, double** %6
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
%44 = load double, double* %43
%45 = fadd double %44, 5.000000e-01
%46 = fptosi double %45 to i32
%47 = call i32 @line(i32 %18, i32 %24, i32 %31, i32 %38, i32 %46)
br label %48
48: ; preds = %17
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %13
51: ; preds = %13
%52 = call i32 (...) @line_flush()
ret void
}

LLVM IR (-O2):
define void @do_line(double* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (...) @line_initialize()
%6 = icmp sgt i32 %2, 1
br i1 %6, label %7, label %29
7: ; preds = %4
%8 = add nsw i32 %2, -1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %19, %10 ]
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = fptosi double %13 to i32
%15 = getelementptr inbounds double, double* %1, i64 %11
%16 = load double, double* %15
%17 = fadd double %16, 5.000000e-01
%18 = fptosi double %17 to i32
%19 = add nuw nsw i64 %11, 1
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fptosi double %21 to i32
%23 = getelementptr inbounds double, double* %1, i64 %19
%24 = load double, double* %23
%25 = fadd double %24, 5.000000e-01
%26 = fptosi double %25 to i32
%27 = tail call i32 @line(i32 %3, i32 %14, i32 %18, i32 %22, i32 %26)
%28 = icmp eq i64 %19, %9
br i1 %28, label %29, label %10
29: ; preds = %10, %4
%30 = tail call i32 (...) @line_flush()
ret void
}