// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
cmpl $0x0, 0x3625f5(%rip)    # 0x39a414
jne 0x37e3c
callq 0x37ae0
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x37e3a
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3808d
jmp 0x37e3c
movl $0xffffffff, 0x3625d2(%rip) # imm = 0xFFFFFFFF
movw $0x0, 0x3625d1(%rip)    # 0x39a420
movw $0x0, 0x3627c8(%rip)    # 0x39a620
movb $0x2, 0x3627c3(%rip)    # 0x39a622
movl $0x0, 0x3627bb(%rip)    # 0x39a624
movl $0x10000, 0x3627b5(%rip) # imm = 0x10000
movb $0x0, 0x3627b2(%rip)    # 0x39a62c
movl $0x1, -0x8(%rbp)
cmpl $0x400, -0x8(%rbp)      # imm = 0x400
jge 0x37eae
movl $0xffffff, %eax         # imm = 0xFFFFFF
cltd
idivl -0x8(%rbp)
movl %eax, %edx
movslq -0x8(%rbp), %rcx
leaq 0x362790(%rip), %rax    # 0x39a630
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x37e81
movl $0x0, -0x8(%rbp)
cmpl $0x1000, -0x8(%rbp)     # imm = 0x1000
jge 0x37f1b
movl $0x0, -0xc(%rbp)
cmpl $0x5, -0xc(%rbp)
jge 0x37f0e
movslq -0x8(%rbp), %rcx
leaq 0x36375a(%rip), %rax    # 0x39b630
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movslq -0x8(%rbp), %rcx
leaq 0x38b73c(%rip), %rax    # 0x3c3630
imulq $0x5, %rcx, %rcx
addq %rcx, %rax
movslq -0xc(%rbp), %rcx
movb $-0x38, (%rax,%rcx)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x37ec5
jmp 0x37f10
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x37eb5
movl $0x0, -0x8(%rbp)
cmpl $0x2400, -0x8(%rbp)     # imm = 0x2400
jge 0x37f48
movslq -0x8(%rbp), %rcx
leaq 0x3906fa(%rip), %rax    # 0x3c8630
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x37f22
leaq 0x3996e1(%rip), %rdi    # 0x3d1630
movl $0x1000, %esi           # imm = 0x1000
movl $0x10000, %edx          # imm = 0x10000
callq 0x6ed50
movw $0x0, 0x39d6c9(%rip)    # 0x3d5630
movw $0xffff, 0x39d6c2(%rip) # imm = 0xFFFF
movl $0x0, -0x8(%rbp)
cmpl $0x100, -0x8(%rbp)      # imm = 0x100
jge 0x37f9e
movslq -0x8(%rbp), %rcx
leaq 0x39d6b5(%rip), %rax    # 0x3d5640
movq $0x0, (%rax,%rcx,8)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x37f77
leaq 0x39de9b(%rip), %rdi    # 0x3d5e40
movl $0x2400, %esi           # imm = 0x2400
xorl %edx, %edx
callq 0x6ed50
leaq 0x3afe88(%rip), %rdi    # 0x3e7e40
movl $0x80, %esi
xorl %edx, %edx
callq 0x6ed50
leaq 0x3b0075(%rip), %rdi    # 0x3e8040
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x6ed50
leaq 0x3b0862(%rip), %rdi    # 0x3e8840
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x6ed50
movb $0x0, 0x3b104f(%rip)    # 0x3e9040
movw $0xffff, 0x3b1048(%rip) # imm = 0xFFFF
movw $0xffff, 0x3b1041(%rip) # imm = 0xFFFF
movw $0x0, 0x3b103a(%rip)    # 0x3e9046
movl $0x0, 0x3b1032(%rip)    # 0x3e9048
movl $0x200, 0x3b102c(%rip)  # imm = 0x200
movl $0x200, 0x3b1026(%rip)  # imm = 0x200
movl $0x2, 0x3b1020(%rip)    # 0x3e9054
callq 0x380a0
cmpl $0x0, %eax
je 0x38047
movl $0x1, -0x4(%rbp)
jmp 0x3808d
callq 0x38250
cmpl $0x0, %eax
je 0x3805a
movl $0x1, -0x4(%rbp)
jmp 0x3808d
callq 0x8b7c0
leaq 0x5f1b8a(%rip), %rax    # 0x629bf0
cmpl $0x0, (%rax)
jne 0x38070
callq 0x8e030
leaq 0x603f89(%rip), %rax    # 0x63c000
cmpb $0x0, (%rax)
jne 0x38081
callq 0x8ed00
callq 0x9bfd0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)