// File: /workspace/github_c_makefile_star2_O2/halcy[P]quasi_crystals_bot/Graphics/DrawingLines.c
// Function: GenericDrawLine
static inline void GenericDrawLine(Bitmap *bitmap,int x1,int y1,int x2,int y2,Pixel c,CompositionMode comp,
GenericDrawPixelFunction *pixelfunc,GenericDrawHorizontalLineFunction *hlinefunc,GenericDrawVerticalLineFunction *vlinefunc)
{
	if(x1==x2)
	{
		if(y1<y2) GenericDrawVerticalLine(bitmap,x1,y1,y2-y1+1,c,comp,vlinefunc);
		else GenericDrawVerticalLine(bitmap,x1,y2,y1-y2+1,c,comp,vlinefunc);
		return;
	}
	else if(y1==y2)
	{
		if(x1<x2) GenericDrawHorizontalLine(bitmap,x1,y1,x2-x1+1,c,comp,hlinefunc);
		else GenericDrawHorizontalLine(bitmap,x1,y2,x1-x2+1,c,comp,hlinefunc);
		return;
	}

	bool steep=abs(y2-y1)>abs(x2-x1);

	if(steep)
	{
		int t;
		t=x1; x1=y1; y1=t;
		t=x2; x2=y2; y2=t;
	}

	if(x1>x2)
	{
		int t;
		t=x1; x1=x2; x2=t;
		t=y1; y1=y2; y2=t;
	}

	int deltax=x2-x1;
	int deltay,ydir;
	if(y1<y2) { deltay=y2-y1; ydir=1; }
	else { deltay=y1-y2; ydir=-1; }

	int error=deltax>>1;
	int y=y1;

	if(steep)
	{
		for(int x=x1;x<=x2;x++)
		{
			GenericDrawPixel(bitmap,y,x,c,comp,pixelfunc);
			error-=deltay;
			if(error<0)
			{
				y+=ydir;
				error+=deltax;
			}
		}
	}
	else
	{
		for(int x=x1;x<=x2;x++)
		{
			GenericDrawPixel(bitmap,x,y,c,comp,pixelfunc);
			error-=deltay;
			if(error<0)
			{
				y+=ydir;
				error+=deltax;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq -0x28(%rsp), %rsp
movl %r9d, 0x4(%rsp)
movl %r8d, %ebp
movl %ecx, %r8d
movq %rdi, 0x8(%rsp)
movl %edx, %eax
movq 0x60(%rsp), %rdx
subl %esi, %r8d
movq %rdx, 0x10(%rsp)
jne 0x56ac
movl %ebp, %ecx
movq 0x78(%rsp), %r11
subl %eax, %ecx
jle 0x56d6
incl %ecx
movq 0x8(%rsp), %rdi
movl %eax, %edx
jmp 0x56e3
movl %ebp, %r9d
subl %eax, %r9d
jne 0x56ff
movl %ecx, %r8d
movq 0x70(%rsp), %r11
subl %esi, %r8d
jg 0x56c7
movl %esi, %r8d
subl %ecx, %r8d
incl %r8d
movq 0x8(%rsp), %rdi
movl %eax, %edx
movl %r8d, %ecx
jmp 0x56e3
subl %ebp, %eax
movq 0x8(%rsp), %rdi
movl %ebp, %edx
incl %eax
movl %eax, %ecx
movl 0x4(%rsp), %r8d
movq 0x10(%rsp), %r9
leaq 0x28(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%r11
movl %r9d, %edx
movl %r8d, %edi
negl %edx
cmovsl %r9d, %edx
negl %edi
cmovsl %r8d, %edi
cmpl %edi, %edx
jbe 0x571d
movl %ecx, %r12d
movl %esi, %r8d
jmp 0x5727
movl %ebp, %r12d
movl %eax, %r8d
movl %ecx, %ebp
movl %esi, %eax
cmpl %ebp, %eax
jle 0x5733
movl %r8d, %ecx
movl %eax, %r9d
jmp 0x573e
movl %r12d, %ecx
movl %ebp, %r9d
movl %r8d, %r12d
movl %eax, %ebp
movl %r9d, %r13d
xorl %eax, %eax
movl %r12d, %esi
movl %r9d, %r15d
subl %ebp, %r13d
subl %ecx, %esi
movl %r13d, 0x1c(%rsp)
movl %esi, %r14d
setl %al
movq 0x68(%rsp), %rcx
negl %r14d
leal -0x1(%rax,%rax), %ebx
movq %rcx, 0x20(%rsp)
cmovsl %esi, %r14d
sarl %r13d
cmpl %edi, %edx
jbe 0x57af
cmpl %r9d, %ebp
jg 0x57e9
movq 0x8(%rsp), %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq *0x20(%rsp)
subl %r14d, %r13d
movl %r15d, %r9d
incl %ebp
movl %r13d, %eax
sarl $0x1f, %eax
movl %eax, %ecx
andl %ebx, %eax
andl 0x1c(%rsp), %ecx
addl %eax, %r12d
addl %ecx, %r13d
jmp 0x5775
cmpl %r9d, %ebp
jg 0x57e9
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r12d, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq *0x20(%rsp)
subl %r14d, %r13d
movl %r15d, %r9d
incl %ebp
movl %r13d, %eax
sarl $0x1f, %eax
movl %eax, %ecx
andl %ebx, %eax
andl 0x1c(%rsp), %ecx
addl %eax, %r12d
addl %ecx, %r13d
jmp 0x57af
leaq 0x28(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq