// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: drawline256
void drawline256(int x1, int y1, int x2, int y2, unsigned char col)
{
	int dx, dy, i, j, inc, daend, plc;
	intptr_t p;

	col = palookup[0][col];

	dx = x2-x1; dy = y2-y1;
	if (dx >= 0)
	{
		if ((x1 >= wx2) || (x2 < wx1)) return;
		if (x1 < wx1) y1 += scale(wx1-x1,dy,dx), x1 = wx1;
		if (x2 > wx2) y2 += scale(wx2-x2,dy,dx), x2 = wx2;
	}
	else
	{
		if ((x2 >= wx2) || (x1 < wx1)) return;
		if (x2 < wx1) y2 += scale(wx1-x2,dy,dx), x2 = wx1;
		if (x1 > wx2) y1 += scale(wx2-x1,dy,dx), x1 = wx2;
	}
	if (dy >= 0)
	{
		if ((y1 >= wy2) || (y2 < wy1)) return;
		if (y1 < wy1) x1 += scale(wy1-y1,dx,dy), y1 = wy1;
		if (y2 > wy2) x2 += scale(wy2-y2,dx,dy), y2 = wy2;
	}
	else
	{
		if ((y2 >= wy2) || (y1 < wy1)) return;
		if (y2 < wy1) x2 += scale(wy1-y2,dx,dy), y2 = wy1;
		if (y1 > wy2) x1 += scale(wy2-y1,dx,dy), y1 = wy2;
	}

#if USE_POLYMOST && USE_OPENGL
	if (!polymost_drawline256(x1,y1,x2,y2,col)) return;
#endif

	if (klabs(dx) >= klabs(dy))
	{
		if (dx == 0) return;
		if (dx < 0)
		{
			i = x1; x1 = x2; x2 = i;
			i = y1; y1 = y2; y2 = i;
			x1+=4096; x2+=4096;
		}

		inc = divscale12(dy,dx);
		plc = y1+mulscale12((2047-x1)&4095,inc);
		i = ((x1+2048)>>12); daend = ((x2+2048)>>12);

		for(;i<daend;i++)
		{
			j = (plc>>12);
			if ((j >= startumost[i]) && (j < startdmost[i]))
				drawpixel((void*)(frameplace+ylookup[j]+i),col);
			plc += inc;
		}
	}
	else
	{
		if (dy < 0)
		{
			i = x1; x1 = x2; x2 = i;
			i = y1; y1 = y2; y2 = i;
			y1+=4096; y2+=4096;
		}

		inc = divscale12(dx,dy);
		plc = x1+mulscale12((2047-y1)&4095,inc);
		i = ((y1+2048)>>12); daend = ((y2+2048)>>12);

		p = ylookup[i]+frameplace;
		for(;i<daend;i++)
		{
			j = (plc>>12);
			if ((i >= startumost[j]) && (i < startdmost[j]))
				drawpixel((void*)(j+p),col);
			plc += inc; p += ylookup[1];
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %r8b, %al
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq 0x37c0bf(%rip), %rax    # 0x3d5640
movzbl -0x11(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x11(%rbp)
movl -0xc(%rbp), %eax
subl -0x4(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x10(%rbp), %eax
subl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x5961c
movl -0x4(%rbp), %eax
cmpl 0x417838(%rip), %eax    # 0x470de4
jge 0x595b9
movl -0xc(%rbp), %eax
cmpl 0x417825(%rip), %eax    # 0x470ddc
jge 0x595be
jmp 0x59a0a
movl -0x4(%rbp), %eax
cmpl 0x417815(%rip), %eax    # 0x470ddc
jge 0x595ec
movl 0x41780d(%rip), %edi    # 0x470ddc
subl -0x4(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x37720
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movl 0x4177f3(%rip), %eax    # 0x470ddc
movl %eax, -0x4(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x4177ef(%rip), %eax    # 0x470de4
jle 0x5961a
movl 0x4177e7(%rip), %edi    # 0x470de4
subl -0xc(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x37720
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl 0x4177cd(%rip), %eax    # 0x470de4
movl %eax, -0xc(%rbp)
jmp 0x59695
movl -0xc(%rbp), %eax
cmpl 0x4177bf(%rip), %eax    # 0x470de4
jge 0x59632
movl -0x4(%rbp), %eax
cmpl 0x4177ac(%rip), %eax    # 0x470ddc
jge 0x59637
jmp 0x59a0a
movl -0xc(%rbp), %eax
cmpl 0x41779c(%rip), %eax    # 0x470ddc
jge 0x59665
movl 0x417794(%rip), %edi    # 0x470ddc
subl -0xc(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x37720
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl 0x41777a(%rip), %eax    # 0x470ddc
movl %eax, -0xc(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x417776(%rip), %eax    # 0x470de4
jle 0x59693
movl 0x41776e(%rip), %edi    # 0x470de4
subl -0x4(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x37720
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movl 0x417754(%rip), %eax    # 0x470de4
movl %eax, -0x4(%rbp)
jmp 0x59695
cmpl $0x0, -0x1c(%rbp)
jl 0x59714
movl -0x8(%rbp), %eax
cmpl 0x417744(%rip), %eax    # 0x470de8
jge 0x596b1
movl -0x10(%rbp), %eax
cmpl 0x417731(%rip), %eax    # 0x470de0
jge 0x596b6
jmp 0x59a0a
movl -0x8(%rbp), %eax
cmpl 0x417721(%rip), %eax    # 0x470de0
jge 0x596e4
movl 0x417719(%rip), %edi    # 0x470de0
subl -0x8(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x37720
addl -0x4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl 0x4176ff(%rip), %eax    # 0x470de0
movl %eax, -0x8(%rbp)
movl -0x10(%rbp), %eax
cmpl 0x4176fb(%rip), %eax    # 0x470de8
jle 0x59712
movl 0x4176f3(%rip), %edi    # 0x470de8
subl -0x10(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x37720
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl 0x4176d9(%rip), %eax    # 0x470de8
movl %eax, -0x10(%rbp)
jmp 0x5978d
movl -0x10(%rbp), %eax
cmpl 0x4176cb(%rip), %eax    # 0x470de8
jge 0x5972a
movl -0x8(%rbp), %eax
cmpl 0x4176b8(%rip), %eax    # 0x470de0
jge 0x5972f
jmp 0x59a0a
movl -0x10(%rbp), %eax
cmpl 0x4176a8(%rip), %eax    # 0x470de0
jge 0x5975d
movl 0x4176a0(%rip), %edi    # 0x470de0
subl -0x10(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x37720
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl 0x417686(%rip), %eax    # 0x470de0
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x417682(%rip), %eax    # 0x470de8
jle 0x5978b
movl 0x41767a(%rip), %edi    # 0x470de8
subl -0x8(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x37720
addl -0x4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl 0x417660(%rip), %eax    # 0x470de8
movl %eax, -0x8(%rbp)
jmp 0x5978d
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movzbl -0x11(%rbp), %r8d
callq 0x8b280
cmpl $0x0, %eax
jne 0x597ad
jmp 0x59a0a
movl -0x18(%rbp), %edi
callq 0x37610
movl %eax, -0x3c(%rbp)
movl -0x1c(%rbp), %edi
callq 0x37610
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jl 0x598ea
cmpl $0x0, -0x18(%rbp)
jne 0x597d8
jmp 0x59a0a
cmpl $0x0, -0x18(%rbp)
jge 0x59818
movl -0x4(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x4(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x4(%rbp)
movl -0xc(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0xc(%rbp)
movl -0x1c(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x59a10
movl %eax, -0x28(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x7ff, %edi            # imm = 0x7FF
subl -0x4(%rbp), %edi
andl $0xfff, %edi            # imm = 0xFFF
movl -0x28(%rbp), %esi
callq 0x450b0
movl %eax, %ecx
movl -0x40(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x4(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
sarl $0xc, %eax
movl %eax, -0x20(%rbp)
movl -0xc(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
sarl $0xc, %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x598e5
movl -0x30(%rbp), %eax
sarl $0xc, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movslq -0x20(%rbp), %rdx
leaq 0x3b3249(%rip), %rcx    # 0x40cad0
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jl 0x598d1
movl -0x24(%rbp), %eax
movslq -0x20(%rbp), %rdx
leaq 0x3b48c3(%rip), %rcx    # 0x40e160
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jge 0x598d1
leaq 0x161364(%rip), %rax    # 0x1bac10
movq (%rax), %rdi
movslq -0x24(%rbp), %rcx
leaq 0x3f81c6(%rip), %rax    # 0x451a80
movslq (%rax,%rcx,4), %rax
addq %rax, %rdi
movslq -0x20(%rbp), %rax
addq %rax, %rdi
movsbl -0x11(%rbp), %esi
callq 0x58130
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x59868
jmp 0x59a0a
cmpl $0x0, -0x1c(%rbp)
jge 0x5992a
movl -0x4(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x8(%rbp)
movl -0x10(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x10(%rbp)
movl -0x18(%rbp), %edi
movl -0x1c(%rbp), %esi
callq 0x59a10
movl %eax, -0x28(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x7ff, %edi            # imm = 0x7FF
subl -0x8(%rbp), %edi
andl $0xfff, %edi            # imm = 0xFFF
movl -0x28(%rbp), %esi
callq 0x450b0
movl %eax, %ecx
movl -0x44(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x8(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
sarl $0xc, %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
sarl $0xc, %eax
movl %eax, -0x2c(%rbp)
movslq -0x20(%rbp), %rcx
leaq 0x3f80fb(%rip), %rax    # 0x451a80
movslq (%rax,%rcx,4), %rax
leaq 0x161280(%rip), %rcx    # 0x1bac10
addq (%rcx), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x59a08
movl -0x30(%rbp), %eax
sarl $0xc, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
movslq -0x24(%rbp), %rdx
leaq 0x3b311a(%rip), %rcx    # 0x40cad0
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jl 0x599e5
movl -0x20(%rbp), %eax
movslq -0x24(%rbp), %rdx
leaq 0x3b4794(%rip), %rcx    # 0x40e160
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jge 0x599e5
movslq -0x24(%rbp), %rdi
addq -0x38(%rbp), %rdi
movsbl -0x11(%rbp), %esi
callq 0x58130
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movslq 0x3f808f(%rip), %rax    # 0x451a84
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x59997
jmp 0x59a0a
addq $0x50, %rsp
popq %rbp
retq