// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %r8d, %r12d
testw %r12w, %r12w
jle 0x198d3
movl %esi, %ebx
movl %edi, %ebp
movl 0x15fb63(%rip), %edx    # 0x1791c8
leaq 0x8a130(%rip), %r8      # 0xa379c
movslq (%r8), %rax
leal (%rax,%rbx), %esi
movslq %esi, %rsi
movslq %ecx, %r14
imulq %r14, %rsi
shrq $0xe, %rsi
movl %edx, %ecx
subl %esi, %ecx
xorl %esi, %esi
testl %ecx, %ecx
cmovgl %ecx, %esi
movl %ebx, %edi
subl %eax, %edi
movslq %edi, %rdi
imulq %r14, %rdi
shrq $0xe, %rdi
subl %edi, %edx
movl 0x1136c6(%rip), %edi    # 0x12cd68
leal -0x1(%rdi), %r9d
cmpl %edi, %edx
cmovll %edx, %r9d
cmpl %edi, %esi
jge 0x19833
testl %r9d, %r9d
js 0x19833
cmpl %r9d, %ecx
jg 0x19833
movl %r12d, 0xc(%rsp)
movl 0x15faf2(%rip), %r10d   # 0x1791c4
leal (%rax,%rbp), %ecx
movslq %ecx, %rcx
imulq %r14, %rcx
shrq $0xe, %rcx
subl %ecx, %r10d
movq %rax, %r11
negq %r11
movl (%r8), %edx
xorl %r13d, %r13d
cmpl %r11d, %edx
movq %rbp, 0x18(%rsp)
jge 0x19701
movl %r10d, %edi
jmp 0x197ec
movl $0x800, %r15d           # imm = 0x800
movl 0xc(%rsp), %ecx
shrl %cl, %r15d
movslq %ebp, %rbp
movl 0x15faad(%rip), %edi    # 0x1791c4
movq %rbp, %rcx
subq %r11, %rcx
imulq %r14, %rcx
shrq $0xe, %rcx
subl %ecx, %edi
leaq 0x3ed8be(%rip), %r12    # 0x406fec
cmpl (%r12), %edi
jge 0x197e9
addq %rax, %rbp
subq %r15, %rbp
imulq %r14, %rbp
movq %r14, %rcx
imulq %r15, %rcx
movq %rcx, 0x10(%rsp)
movq %r15, %rcx
subq %rax, %rcx
movq %r14, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movl %edi, %r13d
movq %rcx, %r11
testl %edi, %edi
js 0x197b5
cmpl %r10d, %r13d
je 0x197b5
movl %r13d, %edi
movl %r13d, %edx
movl %r9d, %ecx
movl $0x8, %r8d
movl %esi, %r12d
movl %r9d, %r14d
movl %r10d, %r15d
movq %r11, 0x30(%rsp)
callq 0x18db3
movq 0x30(%rsp), %r11
movl %r15d, %r10d
movq 0x20(%rsp), %r15
movl %r14d, %r9d
movq 0x28(%rsp), %r14
movl %r12d, %esi
leaq 0x3ed83e(%rip), %r12    # 0x406fec
leaq 0x89fe7(%rip), %r8      # 0xa379c
movslq (%r8), %rdx
cmpq %rdx, %r11
jg 0x197e6
movl 0x15fa01(%rip), %edi    # 0x1791c4
movq %rbp, %rax
shrq $0xe, %rax
subl %eax, %edi
movq %r11, %rcx
addq %r15, %rcx
subq 0x10(%rsp), %rbp
movl %r13d, %r10d
cmpl (%r12), %edi
jl 0x1975e
jmp 0x197ec
movl %r13d, %edi
movl %r10d, %r13d
leaq 0x3ed7f9(%rip), %rax    # 0x406fec
movl (%rax), %eax
cmpl %eax, %edi
cmovgel %r13d, %edi
cmpl %edx, %r11d
cmovll %r13d, %edi
testl %edi, %edi
setns %cl
cmpl %eax, %edi
setl %al
andb %cl, %al
cmpb $0x1, %al
movl 0xc(%rsp), %r12d
movq 0x18(%rsp), %rbp
jne 0x19833
movl %edi, %edx
movl %r9d, %ecx
movl $0x8, %r8d
callq 0x18db3
leaq 0x89f69(%rip), %r8      # 0xa379c
movl (%r8), %eax
movl %eax, %r15d
negl %r15d
cmpl %r15d, %eax
jl 0x198d3
leal (%rax,%rbp), %ecx
movslq %ecx, %rcx
imulq %r14, %rcx
shrq $0xe, %rcx
movq %rcx, 0x10(%rsp)
subl %eax, %ebp
movslq %ebp, %r13
imulq %r14, %r13
shrq $0xe, %r13
movl $0x800, %ebp            # imm = 0x800
movl %r12d, %ecx
shrl %cl, %ebp
addl %eax, %ebx
imull %r14d, %ebx
imull %ebp, %r14d
movl $0x80000000, %eax       # imm = 0x80000000
movl %ebx, %r12d
sarl $0xe, %r12d
cmpl %eax, %r12d
je 0x198c8
movl 0x15f938(%rip), %edx    # 0x1791c8
movl %edx, %ecx
subl %r12d, %ecx
jl 0x198c8
subl 0x1134cb(%rip), %edx    # 0x12cd68
cmpl %edx, %r12d
jle 0x198c8
movl 0x15f91c(%rip), %edx    # 0x1791c4
movl %edx, %edi
subl 0x10(%rsp), %edi
subl %r13d, %edx
movl %ecx, %esi
movl $0x8, %r8d
callq 0x18db3
leaq 0x89ed7(%rip), %r8      # 0xa379c
movl %r12d, %eax
addl %ebp, %r15d
subl %r14d, %ebx
cmpl (%r8), %r15d
jle 0x1987e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq