// File: /workspace/github_c_makefile_star2_O2/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 0x99a4
leaq 0x6821d(%rip), %rdi     # 0x81ea7
xorl %r13d, %r13d
xorl %esi, %esi
callq 0x302de
testl %eax, %eax
js 0x19cfd
movl %eax, %ebx
movl %eax, %edi
callq 0x306a5
movl %eax, %ebp
testl %eax, %eax
cmovlel %r13d, %ebp
leaq 0xc0940(%rip), %r14     # 0xda5f0
cmpl %ebp, %r13d
je 0x19cf6
movl %ebx, %edi
callq 0x306a5
movl %eax, %r12d
xorl %r15d, %r15d
cmpq $0x100, %r15            # imm = 0x100
je 0x19cdb
movl %ebx, %edi
callq 0x306a5
movb %al, (%r14,%r15)
incq %r15
jmp 0x19cc2
movl %r12d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x49385
incl %r13d
jmp 0x19cb0
movl %ebx, %edi
callq 0x30983
leaq 0xadc74(%rip), %rax     # 0xc7978
cmpb $0x0, 0x4(%rax)
je 0x19d88
leaq 0x68195(%rip), %rdi     # 0x81ea6
xorl %r13d, %r13d
xorl %esi, %esi
callq 0x302de
testl %eax, %eax
js 0x19d88
movl %eax, %ebx
movl %eax, %edi
callq 0x306a5
movl %eax, %ebp
testl %eax, %eax
cmovlel %r13d, %ebp
leaq 0xc08b9(%rip), %r14     # 0xda5f0
cmpl %ebp, %r13d
je 0x19d81
movl %ebx, %edi
callq 0x306a5
movl %eax, %r12d
xorl %r15d, %r15d
cmpq $0x100, %r15            # imm = 0x100
je 0x19d62
movl %ebx, %edi
callq 0x306a5
movb %al, (%r14,%r15)
incq %r15
jmp 0x19d49
addl $0xf, %r12d
movl %r12d, %edi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x49385
incl %r13d
jmp 0x19d37
movl %ebx, %edi
callq 0x30983
leaq 0xc0861(%rip), %rsi     # 0xda5f0
pushq $0x3c
popq %rcx
pushq $0x1
popq %r9
movl $0xff, %edi
movl %ecx, %edx
movl %ecx, %r8d
callq 0x49385
leaq 0x4ea994(%rip), %rax    # 0x504740
movabsq $0x3000200010000, %rcx  # imm = 0x3000200010000
movq %rcx, (%rax)
leaq 0x4eab80(%rip), %rax    # 0x504940
movw $0x2, (%rax)
leaq 0x4eab76(%rip), %rax    # 0x504942
movb $0x1, (%rax)
leaq 0x4eab6e(%rip), %rax    # 0x504944
movl $0x70, (%rax)
callq 0x19be5
callq 0x1322e
callq 0x15be0
xorl %eax, %eax
callq 0x17050
leaq 0xc1da9(%rip), %rax     # 0xdbba2
cmpw $0x0, (%rax)
jne 0x19e04
movw $0xf00, (%rax)          # imm = 0xF00
leaq 0x10b6e9(%rip), %rax    # 0x1254f4
andl $0x0, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq