// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/build.c
// Function: draw2dgrid
void draw2dgrid(int posxe, int posye, short ange, int zoome, short gride)
{
	int i, xp1, yp1, xp2=0, yp2, tempy;

	(void)ange;

	if (gride > 0)
	{
		yp1 = midydim16-mulscale14(posye+editorgridextent,zoome);
		if (yp1 < 0) yp1 = 0;
		yp2 = midydim16-mulscale14(posye-editorgridextent,zoome);
		if (yp2 >= ydim16) yp2 = ydim16-1;

		if ((yp1 < ydim16) && (yp2 >= 0) && (yp2 >= yp1))
		{
			xp1 = halfxdim16-mulscale14(posxe+editorgridextent,zoome);

			for(i=-editorgridextent;i<=editorgridextent;i+=(2048>>gride))
			{
				xp2 = xp1;
				xp1 = halfxdim16-mulscale14(posxe-i,zoome);

				if (xp1 >= xdim) break;
				if (xp1 >= 0)
				{
					if (xp1 != xp2)
					{
						drawline16(xp1,yp1,xp1,yp2,8);
					}
				}
			}
			if ((i >= editorgridextent) && (xp1 < xdim))
				xp2 = xp1;
			if ((xp2 >= 0) && (xp2 < xdim))
			{
				drawline16(xp2,yp1,xp2,yp2,8);
			}
		}

		xp1 = mulscale14(posxe+editorgridextent,zoome);
		xp2 = mulscale14(posxe-editorgridextent,zoome);
		tempy = 0x80000000l;
		for(i=-editorgridextent;i<=editorgridextent;i+=(2048>>gride))
		{
			yp1 = (((posye-i)*zoome)>>14);
			if (yp1 != tempy)
			{
				if ((yp1 > midydim16-ydim16) && (yp1 <= midydim16))
				{
					drawline16(halfxdim16-xp1,midydim16-yp1,halfxdim16-xp2,midydim16-yp1,8);
					tempy = yp1;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r14d
testw %r14w, %r14w
jle 0x1990d
movl %esi, %ebx
movl %edi, %r12d
movl 0x160aee(%rip), %edx    # 0x17a1c8
leaq 0x8b0bb(%rip), %rax     # 0xa479c
movl (%rax), %eax
leal (%rax,%rbx), %esi
movslq %esi, %rsi
movslq %ecx, %rbp
imulq %rbp, %rsi
shrq $0xe, %rsi
movl %edx, %ecx
subl %esi, %ecx
xorl %edi, %edi
testl %ecx, %ecx
cmovgl %ecx, %edi
movl %ebx, %esi
subl %eax, %esi
movslq %esi, %rsi
imulq %rbp, %rsi
shrq $0xe, %rsi
subl %esi, %edx
movl 0x114652(%rip), %esi    # 0x12dd68
leal -0x1(%rsi), %r8d
cmpl %esi, %edx
cmovll %edx, %r8d
movl %edi, 0x4(%rsp)
cmpl %esi, %edi
jge 0x1986d
testl %r8d, %r8d
js 0x1986d
cmpl %r8d, %ecx
jg 0x1986d
movl %r14d, (%rsp)
movslq %eax, %r14
movl 0x160a79(%rip), %esi    # 0x17a1c4
leal (%rax,%r12), %ecx
movslq %ecx, %rcx
imulq %rbp, %rcx
shrq $0xe, %rcx
movl %esi, %r13d
subl %ecx, %r13d
movq %r14, %r15
negq %r15
leaq 0x3ee87f(%rip), %rcx    # 0x407fec
movl (%rcx), %edx
testl %eax, %eax
movq %r12, 0x18(%rsp)
js 0x19820
movl $0x800, %r9d            # imm = 0x800
movl (%rsp), %ecx
shrl %cl, %r9d
movslq %r12d, %rcx
addq %rcx, %r14
imulq %rbp, %r14
movq %rbp, %r10
imulq %r9, %r10
movq %rbp, 0x20(%rsp)
movl %r8d, 0x14(%rsp)
movl %r13d, %edi
movq %r14, %rcx
shrq $0xe, %rcx
movl %esi, %r13d
subl %ecx, %r13d
cmpl %edx, %r13d
jge 0x19822
testl %r13d, %r13d
js 0x19810
cmpl %edi, %r13d
je 0x19810
movl %edi, 0x8(%rsp)
movl %r13d, %edi
movl 0x4(%rsp), %esi
movl %r13d, %edx
movl %r8d, %ecx
movl $0x8, %r8d
movq %r9, %r12
movq %r10, %rbp
callq 0x18ded
movq %rbp, %r10
movq %r12, %r9
movl 0x8(%rsp), %edi
movl 0x14(%rsp), %r8d
movq 0x20(%rsp), %rbp
movl 0x1609c6(%rip), %esi    # 0x17a1c4
leaq 0x3ee7e7(%rip), %rax    # 0x407fec
movl (%rax), %edx
leaq 0x8af8e(%rip), %rax     # 0xa479c
movl (%rax), %eax
addq %r9, %r15
movslq %eax, %rcx
subq %r10, %r14
cmpq %rcx, %r15
jle 0x197a3
jmp 0x19822
xorl %edi, %edi
cmpl %edx, %r13d
cmovgel %edi, %r13d
cmpl %eax, %r15d
cmovll %edi, %r13d
testl %r13d, %r13d
setns %cl
cmpl %edx, %r13d
setl %dl
andb %cl, %dl
cmpb $0x1, %dl
movl (%rsp), %r14d
movq 0x18(%rsp), %r12
jne 0x1986d
movl %r13d, %edi
movl 0x4(%rsp), %esi
movl %r13d, %edx
movl %r8d, %ecx
movl $0x8, %r8d
callq 0x18ded
leaq 0x8af31(%rip), %rax     # 0xa479c
movl (%rax), %eax
testl %eax, %eax
js 0x1990d
leal (%rax,%r12), %ecx
movslq %ecx, %rcx
imulq %rbp, %rcx
shrq $0xe, %rcx
movq %rcx, 0x8(%rsp)
subl %eax, %r12d
movslq %r12d, %r15
imulq %rbp, %r15
shrq $0xe, %r15
movl %eax, %r12d
negl %r12d
movl $0x800, %r13d           # imm = 0x800
movl %r14d, %ecx
shrl %cl, %r13d
addl %eax, %ebx
imull %ebp, %ebx
imull %r13d, %ebp
movl $0x80000000, %edx       # imm = 0x80000000
movl %ebx, %r14d
sarl $0xe, %r14d
cmpl %edx, %r14d
je 0x19903
movl 0x1608ff(%rip), %esi    # 0x17a1c8
movl %esi, %ecx
subl %r14d, %ecx
jl 0x19903
subl 0x114492(%rip), %esi    # 0x12dd68
cmpl %esi, %r14d
jle 0x19903
movl 0x1608e3(%rip), %edx    # 0x17a1c4
movl %edx, %edi
subl 0x8(%rsp), %edi
subl %r15d, %edx
movl %ecx, %esi
movl $0x8, %r8d
callq 0x18ded
leaq 0x8ae9e(%rip), %rax     # 0xa479c
movl (%rax), %eax
movl %r14d, %edx
addl %r13d, %r12d
subl %ebp, %ebx
cmpl %eax, %r12d
jle 0x198b7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq