// File: /workspace/github_c_makefile_star2_O3/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 0xa5e4
leaq 0x74aaa(%rip), %rdi     # 0x8ff13
xorl %esi, %esi
callq 0x34174
testl %eax, %eax
js 0x1b4d8
movl %eax, %ebx
movl %eax, %edi
callq 0x34580
testl %eax, %eax
jle 0x1b4d1
movl %eax, %ebp
xorl %r12d, %r12d
leaq 0xc9163(%rip), %r14     # 0xe45f0
movl %ebx, %edi
callq 0x34580
movl %eax, %r15d
xorl %r13d, %r13d
movl %ebx, %edi
callq 0x34580
movb %al, (%r14,%r13)
incq %r13
cmpq $0x100, %r13            # imm = 0x100
jne 0x1b49a
movl %r15d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x4e1d8
incl %r12d
cmpl %ebp, %r12d
jne 0x1b48d
movl %ebx, %edi
callq 0x34878
leaq 0xb6499(%rip), %rax     # 0xd1978
cmpb $0x0, 0x4(%rax)
je 0x1b55f
leaq 0x74a26(%rip), %rdi     # 0x8ff12
xorl %esi, %esi
callq 0x34174
testl %eax, %eax
js 0x1b55f
movl %eax, %ebx
movl %eax, %edi
callq 0x34580
testl %eax, %eax
jle 0x1b558
movl %eax, %ebp
xorl %r12d, %r12d
leaq 0xc90e0(%rip), %r14     # 0xe45f0
movl %ebx, %edi
callq 0x34580
movl %eax, %r15d
xorl %r13d, %r13d
movl %ebx, %edi
callq 0x34580
movb %al, (%r14,%r13)
incq %r13
cmpq $0x100, %r13            # imm = 0x100
jne 0x1b51d
addl $0xf, %r15d
movl %r15d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x4e1d8
incl %r12d
cmpl %ebp, %r12d
jne 0x1b510
movl %ebx, %edi
callq 0x34878
leaq 0xc908a(%rip), %rsi     # 0xe45f0
movl $0xff, %edi
movl $0x3c, %edx
movl $0x3c, %ecx
movl $0x3c, %r8d
movl $0x1, %r9d
callq 0x4e1d8
leaq 0x4f31b3(%rip), %rax    # 0x50e740
movabsq $0x3000200010000, %rcx  # imm = 0x3000200010000
movq %rcx, (%rax)
leaq 0x4f339f(%rip), %rax    # 0x50e940
movw $0x2, (%rax)
leaq 0x4f3395(%rip), %rax    # 0x50e942
movb $0x1, (%rax)
leaq 0x4f338d(%rip), %rax    # 0x50e944
movl $0x70, (%rax)
callq 0x1b306
callq 0x1464a
callq 0x17049
xorl %eax, %eax
callq 0x1852f
leaq 0xca5c8(%rip), %rax     # 0xe5ba2
cmpw $0x0, (%rax)
jne 0x1b5e5
movw $0xf00, (%rax)          # imm = 0xF00
leaq 0x113f08(%rip), %rax    # 0x12f4f4
movl $0x0, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq