// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/src/tekprep.c
// Function: tekpreinit
int
tekpreinit(void)
{
     int  i,j,k,l;
     int fh;

     cdpreinit();

     if( (fh=kopen4load("lookup.dat",0)) >= 0 ) {
          l=kgetc(fh);
          for (j=0 ; j < l ; j++) {
               k=kgetc(fh);
               for (i=0 ; i < 256 ; i++) {
                    tempbuf[i]=kgetc(fh);
               }
               makepalookup(k,tempbuf,0,0,0,1);
          }
          kclose(fh);
     }
     if( (option[4] != 0) && ((fh=kopen4load("nlookup.dat",0)) >= 0) ) {
          l=kgetc(fh);
          for (j=0 ; j < l ; j++) {
               k=kgetc(fh);
               for (i=0 ; i < 256 ; i++) {
                    tempbuf[i]=kgetc(fh);
               }
               makepalookup(k+15,tempbuf,0,0,0,1);
          }
          kclose(fh);
     }

     makepalookup(255,tempbuf,60,60,60,1);

     pskyoff[0]=0;  // 2 tiles
     pskyoff[1]=1;
     pskyoff[2]=2;
     pskyoff[3]=3;
     pskybits=2;    // tile 4 times, every 90 deg.
     parallaxtype=1;
     parallaxyoffs=112;
     initptrlists();
     initpaletteshifts();
     initmenu();
     initmoreoptions();
     if( screensize == 0 ) {
          screensize=MAXXDIM;
     }
     activemenu=0;

     return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0xa5d4
leaq 0x71ba0(%rip), %rdi     # 0x8ce33
xorl %esi, %esi
callq 0x32dbc
testl %eax, %eax
js 0x1b302
movl %eax, %ebx
movl %eax, %edi
callq 0x331ea
testl %eax, %eax
jle 0x1b2fb
movl %eax, %ebp
xorl %r12d, %r12d
leaq 0xc6339(%rip), %r14     # 0xe15f0
movl %ebx, %edi
callq 0x331ea
movl %eax, %r15d
xorl %r13d, %r13d
movl %ebx, %edi
callq 0x331ea
movb %al, (%r14,%r13)
incq %r13
cmpq $0x100, %r13            # imm = 0x100
jne 0x1b2c4
movl %r15d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x4c1f7
incl %r12d
cmpl %ebp, %r12d
jne 0x1b2b7
movl %ebx, %edi
callq 0x334dd
leaq 0xb366f(%rip), %rax     # 0xce978
cmpb $0x0, 0x4(%rax)
je 0x1b389
leaq 0x71b1c(%rip), %rdi     # 0x8ce32
xorl %esi, %esi
callq 0x32dbc
testl %eax, %eax
js 0x1b389
movl %eax, %ebx
movl %eax, %edi
callq 0x331ea
testl %eax, %eax
jle 0x1b382
movl %eax, %ebp
xorl %r12d, %r12d
leaq 0xc62b6(%rip), %r14     # 0xe15f0
movl %ebx, %edi
callq 0x331ea
movl %eax, %r15d
xorl %r13d, %r13d
movl %ebx, %edi
callq 0x331ea
movb %al, (%r14,%r13)
incq %r13
cmpq $0x100, %r13            # imm = 0x100
jne 0x1b347
addl $0xf, %r15d
movl %r15d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x4c1f7
incl %r12d
cmpl %ebp, %r12d
jne 0x1b33a
movl %ebx, %edi
callq 0x334dd
leaq 0xc6260(%rip), %rsi     # 0xe15f0
movl $0xff, %edi
movl $0x3c, %edx
movl $0x3c, %ecx
movl $0x3c, %r8d
movl $0x1, %r9d
callq 0x4c1f7
leaq 0x4f0369(%rip), %rax    # 0x50b720
movabsq $0x3000200010000, %rcx  # imm = 0x3000200010000
movq %rcx, (%rax)
leaq 0x4f0555(%rip), %rax    # 0x50b920
movw $0x2, (%rax)
leaq 0x4f054b(%rip), %rax    # 0x50b922
movb $0x1, (%rax)
leaq 0x4f0543(%rip), %rax    # 0x50b924
movl $0x70, (%rax)
callq 0x1b1f4
callq 0x145ca
callq 0x16f70
xorl %eax, %eax
callq 0x18458
leaq 0xc779e(%rip), %rax     # 0xe2ba2
cmpw $0x0, (%rax)
jne 0x1b40f
movw $0xf00, (%rax)          # imm = 0xF00
leaq 0x1110de(%rip), %rax    # 0x12c4f4
movl $0x0, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq