// File: /workspace/github_c_makefile_star2_O1/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, 0x337ac8(%rip)    # 0x35c8b4
jne 0x24df3
callq 0x24c11
movl $0xffffffff, 0x337abb(%rip) # imm = 0xFFFFFFFF
xorl %eax, %eax
movw %ax, 0x337aba(%rip)     # 0x35c8c0
movw %ax, 0x337cb3(%rip)     # 0x35cac0
movb $0x2, 0x337cae(%rip)    # 0x35cac2
movl $0x0, 0x337ca6(%rip)    # 0x35cac4
movl $0x10000, 0x337ca0(%rip) # imm = 0x10000
movb $0x0, 0x337c9d(%rip)    # 0x35cacc
movl $0x1, %ecx
leaq 0x337c95(%rip), %rsi    # 0x35cad0
movl $0xffffff, %eax         # imm = 0xFFFFFF
xorl %edx, %edx
divl %ecx
movl %eax, (%rsi,%rcx,4)
incq %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x24e3b
leaq 0x338c76(%rip), %rdi    # 0x35dad0
xorl %r14d, %r14d
movl $0x28000, %edx          # imm = 0x28000
xorl %esi, %esi
callq 0x62f0
leaq 0x360c60(%rip), %rdi    # 0x385ad0
movl $0x5000, %edx           # imm = 0x5000
movl $0xc8, %esi
callq 0x62f0
leaq 0x365c4a(%rip), %rdi    # 0x38aad0
movl $0x9000, %edx           # imm = 0x9000
movl $0xff, %esi
callq 0x62f0
leaq 0x36ec34(%rip), %rdi    # 0x393ad0
movl $0x1000, %esi           # imm = 0x1000
movl $0x10000, %edx          # imm = 0x10000
callq 0x4abc9
movw %r14w, 0x372c1d(%rip)   # 0x397ad0
movw $0xffff, %bp            # imm = 0xFFFF
movw %bp, 0x372c14(%rip)     # 0x397ad2
leaq 0x372c1b(%rip), %rbx    # 0x397ae0
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x62f0
leaq 0x373405(%rip), %rdi    # 0x3982e0
movl $0x2400, %esi           # imm = 0x2400
xorl %edx, %edx
callq 0x4abc9
leaq 0x3853f2(%rip), %rdi    # 0x3aa2e0
movl $0x80, %esi
xorl %edx, %edx
callq 0x4abc9
leaq 0x3855df(%rip), %rdi    # 0x3aa4e0
movl $0x200, %r15d           # imm = 0x200
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x4abc9
leaq 0x385dc6(%rip), %rdi    # 0x3aace0
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x4abc9
movb $0x0, 0x3865b3(%rip)    # 0x3ab4e0
movw %bp, 0x3865ae(%rip)     # 0x3ab4e2
movw %bp, 0x3865a9(%rip)     # 0x3ab4e4
movw %r14w, 0x3865a3(%rip)   # 0x3ab4e6
movl $0x0, 0x38659b(%rip)    # 0x3ab4e8
movl %r15d, 0x386598(%rip)   # 0x3ab4ec
movl %r15d, 0x386595(%rip)   # 0x3ab4f0
movl $0x2, 0x38658f(%rip)    # 0x3ab4f4
movl $0x1, %edi
leaq 0x43218f(%rip), %rax    # 0x457100
leaq 0x42ff88(%rip), %rcx    # 0x454f00
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 0x24f98
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 0x25021
addl $0x40c, %r8d            # imm = 0x40C
movw %r8w, 0x2000(%rcx,%rdx,2)
incq %rdx
cmpq $0x1000, %rdx           # imm = 0x1000
jne 0x24f7c
leaq 0x425e28(%rip), %r15    # 0x44ae60
leaq 0x3a8d11(%rip), %r12    # 0x3cdd50
xorl %r13d, %r13d
movsd 0x50ece(%rip), %xmm1    # 0x75f18
movl $0x800, %ebp            # imm = 0x800
movabsq $0x20000000000, %r14    # imm = 0x20000000000
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x50eb3(%rip), %xmm0    # 0x75f20
callq 0x6390
movsd 0x50e9e(%rip), %xmm1    # 0x75f18
mulsd 0x50ea6(%rip), %xmm0    # 0x75f28
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 0x25059
leaq 0x40b48b(%rip), %r14    # 0x43053e
leaq 0x40aa86(%rip), %r15    # 0x42fb40
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
addsd 0x50e63(%rip), %xmm0    # 0x75f30
divsd 0x50e63(%rip), %xmm0    # 0x75f38
callq 0x6c80
mulsd 0x50e5e(%rip), %xmm0    # 0x75f40
mulsd 0x50e5e(%rip), %xmm0    # 0x75f48
divsd 0x50e26(%rip), %xmm0    # 0x75f18
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 0x250bd
leaq 0x411095(%rip), %r14    # 0x4361b0
xorl %r15d, %r15d
leal 0x8(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x50e1f(%rip), %xmm1    # 0x75f50
divsd %xmm0, %xmm1
movsd 0x50e1b(%rip), %xmm0    # 0x75f58
movsd %xmm1, 0x10(%rsp)
callq 0x6380
movsd 0x50e08(%rip), %xmm1    # 0x75f58
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 0x2515d
incq %r15
addq $0x100, %r14            # imm = 0x100
cmpq $0x10, %r15
jne 0x2511e
leaq 0x3a8baf(%rip), %rdi    # 0x3cdd50
movl $0x1000, %esi           # imm = 0x1000
callq 0x6e4ef
cmpl $0xee1e7aba, %eax       # imm = 0xEE1E7ABA
jne 0x2522b
leaq 0x40a987(%rip), %rdi    # 0x42fb40
movl $0x500, %esi            # imm = 0x500
callq 0x6e4ef
cmpl $0xee893d92, %eax       # imm = 0xEE893D92
jne 0x25234
leaq 0x51245(%rip), %rdi     # 0x76416
xorl %esi, %esi
callq 0x1ff50
movl %eax, %ebp
testl %eax, %eax
js 0x25264
movl %ebp, %edi
callq 0x204d2
movl %eax, %r14d
leaq 0x2563bd(%rip), %rsi    # 0x27b5b0
movl %ebp, %edi
movl $0x300, %edx            # imm = 0x300
callq 0x201c2
cmpl $0x300, %eax            # imm = 0x300
jne 0x25258
movl %r14d, %eax
cmpb $0x2, %al
je 0x25284
addq $-0x8280, %rax          # imm = 0xFFFF7D80
testb %al, %al
je 0x25539
leaq 0x51266(%rip), %rdi     # 0x76488
xorl %eax, %eax
callq 0x24cb4
jmp 0x25264
leaq 0x5117c(%rip), %rax     # 0x763ae
jmp 0x2523b
leaq 0x511a7(%rip), %rax     # 0x763e2
movq %rax, 0x1927de(%rip)    # 0x1b7a20
movl $0x1, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x511c3(%rip), %rdi     # 0x76422
callq 0x32200
leaq 0x51284(%rip), %rax     # 0x764ef
movq %rax, 0x1927ae(%rip)    # 0x1b7a20
movl $0x1, %ebx
testl %ebp, %ebp
js 0x25247
movl %ebp, %edi
callq 0x20671
jmp 0x25247
leaq 0x3ee59d(%rip), %rsi    # 0x413828
movl %ebp, %edi
movl $0x2, %edx
callq 0x201c2
cmpl $0x2, %eax
jne 0x2555a
movswq 0x3ee580(%rip), %rdi    # 0x413828
shlq $0x8, %rdi
callq 0x69a0
movq %rax, 0x372828(%rip)    # 0x397ae0
testq %rax, %rax
je 0x25566
movq %rax, %r14
movl $0x10000, %edi          # imm = 0x10000
callq 0x69a0
movq %rax, 0x19275b(%rip)    # 0x1b7a30
testq %rax, %rax
je 0x2556f
movq %r14, 0x3e9d23(%rip)    # 0x40f008
movl $0x0, 0x3e9d15(%rip)    # 0x40f004
movq %r14, %rdi
callq 0x6dcef
movq 0x192732(%rip), %rdi    # 0x1b7a30
callq 0x6dcc3
movslq 0x3e9cfa(%rip), %rax    # 0x40f004
movq (%rbx,%rax,8), %rsi
movswl 0x3ee513(%rip), %edx    # 0x413828
shll $0x8, %edx
movl %ebp, %edi
callq 0x201c2
movq 0x19270a(%rip), %rsi    # 0x1b7a30
movl %ebp, %edi
movl $0x10000, %edx          # imm = 0x10000
callq 0x201c2
movl %ebp, %edi
callq 0x20671
xorl %eax, %eax
movl $0x82, %ecx
movl $0x100, %edx            # imm = 0x100
leaq 0x255754(%rip), %rsi    # 0x27aaa0
leaq 0x25595d(%rip), %rdi    # 0x27acb0
leaq 0x255b66(%rip), %r8     # 0x27aec0
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 0x2535a
xorpd %xmm0, %xmm0
movupd %xmm0, 0x255dff(%rip)   # 0x27b1ad
movapd %xmm0, 0x255dea(%rip)   # 0x27b1a0
movapd %xmm0, 0x255dd2(%rip)   # 0x27b190
movapd %xmm0, 0x255dba(%rip)   # 0x27b180
movapd %xmm0, 0x255da2(%rip)   # 0x27b170
movapd %xmm0, 0x255d8a(%rip)   # 0x27b160
movapd %xmm0, 0x255d72(%rip)   # 0x27b150
movapd %xmm0, 0x255d5a(%rip)   # 0x27b140
leaq 0x255dd3(%rip), %rbx    # 0x27b1c0
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x62f0
leaq 0x2564aa(%rip), %rax    # 0x27b8ad
movl $0xff, %ecx
leaq 0x255d31(%rip), %rdx    # 0x27b140
leaq 0x7e38a(%rip), %rsi     # 0xa37a0
leaq 0x256493(%rip), %rdi    # 0x27b8b0
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 0x25465
movzbl (%r9,%rbx), %ebp
jmp 0x2546a
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 0x2541d
movl $0xffffffc0, %ecx       # imm = 0xFFFFFFC0
movq $-0x49, %rax
xorl %esi, %esi
leaq 0x255c39(%rip), %rdx    # 0x27b0d0
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 0x254b1
leal 0x8(%r9), %r11d
addq %r10, %rsi
addq $0x8, %r8
testl %r9d, %r9d
movl %r11d, %r9d
jle 0x254a0
leal 0x40(%rcx), %r8d
movslq %edi, %rsi
addq %r10, %rsi
addq $0x40, %rax
testl %ecx, %ecx
movl %r8d, %ecx
jle 0x25497
movl 0x255c10(%rip), %eax    # 0x27b104
movl 0x255c3e(%rip), %ecx    # 0x27b138
movl %ecx, 0x255c04(%rip)    # 0x27b104
movl %eax, 0x255c32(%rip)    # 0x27b138
callq 0x5c32c
leaq 0x61070e(%rip), %rax    # 0x635c20
cmpl $0x0, (%rax)
jne 0x2551c
callq 0x5d92b
leaq 0x622b0d(%rip), %rax    # 0x648030
cmpb $0x0, (%rax)
jne 0x2552d
callq 0x5e05e
callq 0x66604
xorl %ebx, %ebx
jmp 0x25247
shrq $0x8, %rax
movw %ax, 0x3ee2e4(%rip)     # 0x413828
movswl %ax, %esi
leaq 0x50f0d(%rip), %rdi     # 0x7645b
xorl %eax, %eax
callq 0x24cb4
jmp 0x25264
leaq 0x50ee1(%rip), %rdi     # 0x76442
jmp 0x2525f
leaq 0x50f39(%rip), %rax     # 0x764a6
jmp 0x25576
leaq 0x50f52(%rip), %rax     # 0x764c8
movq %rax, 0x1924a3(%rip)    # 0x1b7a20
movl %ebp, %edi
callq 0x20671
jmp 0x25242