// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: initengine
int initengine(void)
{
	int i, j;

#if !defined _WIN32 && defined DEBUGGINGAIDS
	struct sigaction sigact, oldact;
	memset(&sigact, 0, sizeof(sigact));
	sigact.sa_sigaction = sighandler;
	sigact.sa_flags = SA_SIGINFO;
	sigaction(SIGFPE, &sigact, &oldact);
#endif
	if (!preinitcalled) {
		i = preinitengine();
		if (i) return i;
	}

	xyaspect = -1;

	pskyoff[0] = 0; pskybits = 0;

	parallaxtype = 2; parallaxyoffs = 0L; parallaxyscale = 65536;
	showinvisibility = 0;

	for(i=1;i<1024;i++) lowrecip[i] = ((1<<24)-1)/i;
	for(i=0;i<MAXVOXELS;i++)
		for(j=0;j<MAXVOXMIPS;j++)
		{
			voxoff[i][j] = 0L;
			voxlock[i][j] = 200;
		}
	for(i=0;i<MAXTILES;i++)
		tiletovox[i] = -1;
	clearbuf(&voxscale[0],sizeof(voxscale)>>2,65536L);

	searchit = 0; searchstat = -1;

	for(i=0;i<MAXPALOOKUPS;i++) palookup[i] = NULL;

	clearbuf(&waloff[0],(int)MAXTILES,0L);

	clearbuf(&show2dsector[0],(int)((MAXSECTORS+3)>>5),0L);
	clearbuf(&show2dsprite[0],(int)((MAXSPRITES+3)>>5),0L);
	clearbuf(&show2dwall[0],(int)((MAXWALLS+3)>>5),0L);
	automapping = 0;

	pointhighlight = -1;
	linehighlight = -1;
	highlightcnt = 0;

	totalclock = 0;
	visibility = 512;
	parallaxvisibility = 512;

	captureformat = 2;  // PNG

	if (loadtables()) return 1;
	if (loadpalette()) return 1;

#if USE_POLYMOST
	polymost_initosdfuncs();
#endif
#if USE_POLYMOST && USE_OPENGL
	if (!hicfirstinit) hicinit();
	if (!mdinited) mdinit();
	PTCacheLoadIndex();
#endif

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpb $0x0, 0x33855b(%rip)    # 0x35d8b4
jne 0x25360
callq 0x2517e
movl $0xffffffff, 0x33854e(%rip) # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movw %cx, 0x33854d(%rip)     # 0x35d8c0
movw %cx, 0x338746(%rip)     # 0x35dac0
movb $0x2, 0x338741(%rip)    # 0x35dac2
movl $0x0, 0x338739(%rip)    # 0x35dac4
movl $0x10000, 0x338733(%rip) # imm = 0x10000
movb $0x0, 0x338730(%rip)    # 0x35dacc
movdqa 0x4ed3c(%rip), %xmm0    # 0x740e0
movdqa 0x4ed44(%rip), %xmm1    # 0x740f0
movdqa 0x51c8c(%rip), %xmm2    # 0x77040
pshufd $0xf5, %xmm2, %xmm3     # xmm3 = xmm2[1,1,3,3]
leaq 0x338710(%rip), %rsi    # 0x35dad0
movq %rcx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm0, %xmm4
pxor %xmm1, %xmm4
movdqa %xmm2, %xmm5
pcmpgtd %xmm4, %xmm5
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pcmpeqd %xmm3, %xmm4
pand %xmm5, %xmm4
movd %xmm4, %eax
testb $0x1, %al
je 0x253ff
leal 0x1(%rcx), %edi
movl $0xffffff, %eax         # imm = 0xFFFFFF
xorl %edx, %edx
divl %edi
movl %eax, 0x4(%rsi,%rcx,4)
pextrw $0x4, %xmm4, %eax
testb $0x1, %al
je 0x25418
leal 0x2(%rcx), %edi
movl $0xffffff, %eax         # imm = 0xFFFFFF
xorl %edx, %edx
divl %edi
movl %eax, 0x8(%rsi,%rcx,4)
addq $0x2, %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x253c0
leaq 0x3396a4(%rip), %rdi    # 0x35ead0
xorl %r14d, %r14d
movl $0x28000, %edx          # imm = 0x28000
xorl %esi, %esi
callq 0x62f0
leaq 0x36168e(%rip), %rdi    # 0x386ad0
movl $0x5000, %edx           # imm = 0x5000
movl $0xc8, %esi
callq 0x62f0
leaq 0x366678(%rip), %rdi    # 0x38bad0
movl $0x9000, %edx           # imm = 0x9000
movl $0xff, %esi
callq 0x62f0
leaq 0x36f662(%rip), %rdi    # 0x394ad0
movl $0x1000, %esi           # imm = 0x1000
movl $0x10000, %edx          # imm = 0x10000
callq 0x4d2d8
movw %r14w, 0x37364b(%rip)   # 0x398ad0
movw $0xffff, %bp            # imm = 0xFFFF
movw %bp, 0x373642(%rip)     # 0x398ad2
leaq 0x373649(%rip), %rbx    # 0x398ae0
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x62f0
leaq 0x373e33(%rip), %rdi    # 0x3992e0
movl $0x2400, %esi           # imm = 0x2400
xorl %edx, %edx
callq 0x4d2d8
leaq 0x385e20(%rip), %rdi    # 0x3ab2e0
movl $0x80, %esi
xorl %edx, %edx
callq 0x4d2d8
leaq 0x38600d(%rip), %rdi    # 0x3ab4e0
movl $0x200, %r15d           # imm = 0x200
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x4d2d8
leaq 0x3867f4(%rip), %rdi    # 0x3abce0
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x4d2d8
movb $0x0, 0x386fe1(%rip)    # 0x3ac4e0
movw %bp, 0x386fdc(%rip)     # 0x3ac4e2
movw %bp, 0x386fd7(%rip)     # 0x3ac4e4
movw %r14w, 0x386fd1(%rip)   # 0x3ac4e6
movl $0x0, 0x386fc9(%rip)    # 0x3ac4e8
movl %r15d, 0x386fc6(%rip)   # 0x3ac4ec
movl %r15d, 0x386fc3(%rip)   # 0x3ac4f0
movl $0x2, 0x386fbd(%rip)    # 0x3ac4f4
movl $0x1, %edi
leaq 0x432bbd(%rip), %rax    # 0x458100
leaq 0x4309b6(%rip), %rcx    # 0x455f00
xorl %edx, %edx
xorl %esi, %esi
movslq %edi, %r10
movl %edx, %r9d
shll $0x12, %r9d
orl $0x20000, %r9d          # imm = 0x20000
movl $0x20000000, %edi       # imm = 0x20000000
movl $0x40000000, %r8d       # imm = 0x40000000
leal (,%rdi,4), %r11d
cmpl %r8d, %r9d
movl %r8d, %ebp
cmovbl %r14d, %ebp
cmovbl %r14d, %r11d
subl %ebp, %r9d
subl %edi, %r8d
addl %r11d, %r8d
shrl %r8d
movl %edi, %r11d
shrl $0x2, %r11d
cmpl $0x3, %edi
movl %r11d, %edi
ja 0x2556a
leal (,%r10,4), %edi
xorl %r11d, %r11d
cmpq %r10, %rdx
setge %r11b
cmovll %r10d, %edi
addl %r11d, %esi
cmpl %r8d, %r9d
sbbl $-0x1, %r8d
andl $0xfffe, %r8d           # imm = 0xFFFE
movw %r8w, (%rax,%rdx,2)
imull $0xffffff02, %esi, %r8d # imm = 0xFFFFFF02
leal 0xa00(%r8), %r9d
movw %r9w, (%rcx,%rdx,2)
cmpq $0xff, %rdx
ja 0x255f3
addl $0x40c, %r8d            # imm = 0x40C
movw %r8w, 0x2000(%rcx,%rdx,2)
incq %rdx
cmpq $0x1000, %rdx           # imm = 0x1000
jne 0x2554e
leaq 0x426856(%rip), %r15    # 0x44be60
leaq 0x3a973f(%rip), %r12    # 0x3ced50
xorl %r13d, %r13d
movsd 0x51a94(%rip), %xmm1    # 0x770b0
movl $0x800, %ebp            # imm = 0x800
movabsq $0x20000000000, %r14    # imm = 0x20000000000
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x51a79(%rip), %xmm0    # 0x770b8
callq 0x6390
movsd 0x51a64(%rip), %xmm1    # 0x770b0
mulsd 0x51a6c(%rip), %xmm0    # 0x770c0
cvttsd2si %xmm0, %eax
movw %ax, (%r12)
movq %r13, %rcx
addq %rbp, %rcx
movq %r14, %rax
xorl %edx, %edx
divq %rcx
movl %eax, (%r15)
incq %r13
addq $0x4, %r15
addq $0x2, %r12
cmpq %rbp, %r13
jne 0x2562b
leaq 0x40beb9(%rip), %r14    # 0x43153e
leaq 0x40b4b4(%rip), %r15    # 0x430b40
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
addsd 0x51a29(%rip), %xmm0    # 0x770c8
divsd 0x51a29(%rip), %xmm0    # 0x770d0
callq 0x6c80
mulsd 0x51a24(%rip), %xmm0    # 0x770d8
mulsd 0x51a24(%rip), %xmm0    # 0x770e0
divsd 0x519ec(%rip), %xmm0    # 0x770b0
cvttsd2si %xmm0, %eax
movw %ax, (%r15)
negl %eax
movw %ax, (%r14)
incq %r12
addq $-0x2, %r14
addq $0x2, %r15
cmpq $0x280, %r12            # imm = 0x280
jne 0x2568f
leaq 0x411ac3(%rip), %r14    # 0x4371b0
xorl %r15d, %r15d
leal 0x8(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x519e5(%rip), %xmm1    # 0x770e8
divsd %xmm0, %xmm1
movsd 0x519e1(%rip), %xmm0    # 0x770f0
movsd %xmm1, 0x10(%rsp)
callq 0x6380
movsd 0x519ce(%rip), %xmm1    # 0x770f0
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x6380
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movb %al, (%r14,%r12)
incq %r12
cmpq $0x100, %r12            # imm = 0x100
jne 0x2572f
incq %r15
addq $0x100, %r14            # imm = 0x100
cmpq $0x10, %r15
jne 0x256f0
leaq 0x3a95dd(%rip), %rdi    # 0x3ced50
movl $0x1000, %esi           # imm = 0x1000
callq 0x70277
cmpl $0xee1e7aba, %eax       # imm = 0xEE1E7ABA
jne 0x257f9
leaq 0x40b3b5(%rip), %rdi    # 0x430b40
movl $0x500, %esi            # imm = 0x500
callq 0x70277
cmpl $0xee893d92, %eax       # imm = 0xEE893D92
jne 0x25802
leaq 0x51df3(%rip), %rdi     # 0x77596
xorl %esi, %esi
callq 0x2043c
testl %eax, %eax
js 0x2580b
movl %eax, %ebp
movl %eax, %edi
callq 0x209a1
movl %eax, %r14d
leaq 0x256def(%rip), %rsi    # 0x27c5b0
movl %ebp, %edi
movl $0x300, %edx            # imm = 0x300
callq 0x20684
cmpl $0x300, %eax            # imm = 0x300
jne 0x2582d
movl %r14d, %eax
cmpb $0x2, %al
je 0x25850
addq $-0x8280, %rax          # imm = 0xFFFF7D80
testb %al, %al
je 0x25b05
leaq 0x51e18(%rip), %rdi     # 0x77608
xorl %eax, %eax
callq 0x25221
jmp 0x25839
leaq 0x51d2e(%rip), %rax     # 0x7752e
jmp 0x25812
leaq 0x51d59(%rip), %rax     # 0x77562
jmp 0x25812
leaq 0x51e5d(%rip), %rax     # 0x7766f
movq %rax, 0x193207(%rip)    # 0x1b8a20
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x51d6e(%rip), %rdi     # 0x775a2
callq 0x32d18
leaq 0x51e2f(%rip), %rax     # 0x7766f
movq %rax, 0x1931d9(%rip)    # 0x1b8a20
movl %ebp, %edi
callq 0x20b40
jmp 0x25819
leaq 0x3eefd1(%rip), %rsi    # 0x414828
movl %ebp, %edi
movl $0x2, %edx
callq 0x20684
cmpl $0x2, %eax
jne 0x25b26
movswq 0x3eefb4(%rip), %rdi    # 0x414828
shlq $0x8, %rdi
callq 0x69a0
movq %rax, 0x37325c(%rip)    # 0x398ae0
testq %rax, %rax
je 0x25b32
movq %rax, %r14
movl $0x10000, %edi          # imm = 0x10000
callq 0x69a0
movq %rax, 0x19318f(%rip)    # 0x1b8a30
testq %rax, %rax
je 0x25b3e
movq %r14, 0x3ea757(%rip)    # 0x410008
movl $0x0, 0x3ea749(%rip)    # 0x410004
movq %r14, %rdi
callq 0x6fa7b
movq 0x193166(%rip), %rdi    # 0x1b8a30
callq 0x6fa4f
movslq 0x3ea72e(%rip), %rax    # 0x410004
movq (%rbx,%rax,8), %rsi
movswl 0x3eef47(%rip), %edx    # 0x414828
shll $0x8, %edx
movl %ebp, %edi
callq 0x20684
movq 0x19313e(%rip), %rsi    # 0x1b8a30
movl %ebp, %edi
movl $0x10000, %edx          # imm = 0x10000
callq 0x20684
movl %ebp, %edi
callq 0x20b40
xorl %eax, %eax
movl $0x82, %ecx
movl $0x100, %edx            # imm = 0x100
leaq 0x256188(%rip), %rsi    # 0x27baa0
leaq 0x256391(%rip), %rdi    # 0x27bcb0
leaq 0x25659a(%rip), %r8     # 0x27bec0
movl %eax, %r10d
shll $0x5, %r10d
subl %eax, %r10d
subl %eax, %r10d
movl %r10d, (%rdx,%rsi)
movl %r10d, -0x4(%rsi,%rcx,2)
imull $0x3b, %eax, %r9d
movl %r9d, (%rdx,%rdi)
movl %r9d, -0x4(%rdi,%rcx,2)
leal (%rax,%rax,4), %r9d
leal (%rax,%r9,2), %r9d
movl %r9d, (%rdx,%r8)
movl %r9d, -0x4(%r8,%rcx,2)
addq $-0x2, %rcx
subl %ecx, %eax
addl $0x81, %eax
addq $0x4, %rdx
testq %rcx, %rcx
jne 0x25926
pxor %xmm0, %xmm0
movdqu %xmm0, 0x256833(%rip)   # 0x27c1ad
movdqa %xmm0, 0x25681e(%rip)   # 0x27c1a0
movdqa %xmm0, 0x256806(%rip)   # 0x27c190
movdqa %xmm0, 0x2567ee(%rip)   # 0x27c180
movdqa %xmm0, 0x2567d6(%rip)   # 0x27c170
movdqa %xmm0, 0x2567be(%rip)   # 0x27c160
movdqa %xmm0, 0x2567a6(%rip)   # 0x27c150
movdqa %xmm0, 0x25678e(%rip)   # 0x27c140
leaq 0x256807(%rip), %rbx    # 0x27c1c0
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x62f0
leaq 0x256ede(%rip), %rax    # 0x27c8ad
movl $0xff, %ecx
leaq 0x256765(%rip), %rdx    # 0x27c140
leaq 0x7edbe(%rip), %rsi     # 0xa47a0
leaq 0x256ec7(%rip), %rdi    # 0x27c8b0
movzbl (%rax), %r8d
andl $-0x8, %r8d
movzbl 0x1(%rax), %r9d
andl $-0x8, %r9d
movzbl 0x2(%rax), %r10d
shrl $0x3, %r10d
leal (%r9,%r8,8), %r8d
leaq (%r8,%r10), %r9
addq $0x49, %r9
movl %r9d, %r8d
shrl $0x3, %r8d
movb (%r8,%rdx), %r10b
movl %r9d, %r11d
andl $0x7, %r11d
movb (%r11,%rsi), %r11b
testb %r10b, %r11b
je 0x25a31
movzbl (%r9,%rbx), %ebp
jmp 0x25a36
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, (%rdi,%rcx,4)
movb %cl, (%r9,%rbx)
orb %r10b, %r11b
movb %r11b, (%r8,%rdx)
addq $-0x3, %rax
addq $-0x1, %rcx
jb 0x259e9
movl $0xffffffc0, %ecx       # imm = 0xFFFFFFC0
movq $-0x49, %rax
xorl %esi, %esi
leaq 0x25666d(%rip), %rdx    # 0x27c0d0
movl $0xfffffff8, %r9d       # imm = 0xFFFFFFF8
movq %rax, %r8
movq %rsi, %rdi
movslq %edi, %rsi
leaq (,%rsi,4), %r11
xorl %r10d, %r10d
leal (%r8,%r10), %ebx
leaq (%r11,%r10,4), %r14
movl %ebx, (%rdx,%r14)
incq %r10
cmpl $0x3, %r10d
jne 0x25a7d
leal 0x8(%r9), %r11d
addq %r10, %rsi
addq $0x8, %r8
testl %r9d, %r9d
movl %r11d, %r9d
jle 0x25a6c
leal 0x40(%rcx), %r8d
movslq %edi, %rsi
addq %r10, %rsi
addq $0x40, %rax
testl %ecx, %ecx
movl %r8d, %ecx
jle 0x25a63
movl 0x256644(%rip), %eax    # 0x27c104
movl 0x256672(%rip), %ecx    # 0x27c138
movl %ecx, 0x256638(%rip)    # 0x27c104
movl %eax, 0x256666(%rip)    # 0x27c138
callq 0x5e48b
leaq 0x611132(%rip), %rax    # 0x636c10
cmpl $0x0, (%rax)
jne 0x25ae8
callq 0x5f9e3
leaq 0x623531(%rip), %rax    # 0x649020
cmpb $0x0, (%rax)
jne 0x25af9
callq 0x60126
callq 0x68340
xorl %eax, %eax
jmp 0x2581e
shrq $0x8, %rax
movw %ax, 0x3eed18(%rip)     # 0x414828
movswl %ax, %esi
leaq 0x51ac1(%rip), %rdi     # 0x775db
xorl %eax, %eax
callq 0x25221
jmp 0x25839
leaq 0x51a95(%rip), %rdi     # 0x775c2
jmp 0x25834
leaq 0x51aed(%rip), %rax     # 0x77626
jmp 0x25840
leaq 0x51b03(%rip), %rax     # 0x77648
jmp 0x25840