// File: /workspace/github_c_makefile_star2_O3/mincebert[P]maketzx/maketzx.c
// Function: GetLoadingParameters
void GetLoadingParameters(word loaded)
{
  if (slocktype)
     {
       dword savepos=filepos;
       ResetTempFile();
       if ((nxtloadpos>slockloadaddress-0x319) && (nxtloadpos<slockloadaddress))
	  {
	    if (loaded==2)
	       {
		 GetData(&tempfile);
		 xorbyte=((GetData(&tempfile))^xorbyte)+addbyte;
	       }
	  }

       if ((nxtloadpos>=loadertableadd || nxtloadpos+loaded>loadertableadd) && ((slockloadaddress>0xc000 && nxtloadpos>0xc000) || (slockloadaddress<0xc000 && nxtloadpos<0xc000)))
	  {
	    if (loaded>128) { strcpy(errstring,"Missing mid-sync"); Error(8);}
	    else {
		   byte offset=nxtloadpos-loadertableadd;
		   DecodeSpeedlockTable(loaded,offset);
		 }
	  }
       expectedlength=slockdata[tablepointer+2]+256*(slockdata[tablepointer+3]);
       if (expectedlength)
	  {
	    expectedlength++;
	    SpeedEndBlock=0;
	    nxtloadpos=slockdata[tablepointer]+256*(slockdata[tablepointer+1]);
	    rampage=slockdata[tablepointer+4];
	  }
       else SpeedEndBlock=1;
       tablepointer+=5;
       filepos=savepos;
       lseek(inpfile.handle,filepos,SEEK_SET);
       inpfile.bufpoint=0;
     }
  if (soft)
     {
       if (add256)
	  {
	    ResetTempFile();
	    PushFilePointers();
	    opcode=MirrorByte(GetData(&tempfile));
	    if (nxtloadpos==0x5b00 && opcode!=0x3b)
	       {
		 nxtloadpos=0; return;
	       }
	    opcode=MirrorByte(GetData(&tempfile));
	    ResetTempFile();
	    PopFilePointers();
//          RecoverFilePointers();
	    add256=0;
	  }
       DataRead(bit0.samples,bit1.samples,4);
       WriteTZXPureData(8,4);
       PushFilePointers();
       ResetTempFile();
       expectedlength=MirrorByte(GetData(&tempfile));
       expectedlength+=(256*(MirrorByte(GetData(&tempfile))));
       nxtloadpos=MirrorByte(GetData(&tempfile));
       nxtloadpos+=(256*(MirrorByte(GetData(&tempfile))));
       if (nxtloadpos) nxtloadpos+=((256*(opcode==0x24))-(256*(opcode==0x25)));
       PopFilePointers();
       if (expectedlength<=5 || (nxtloadpos<23324 && nxtloadpos+expectedlength>23325)) add256=1;
       else add256=0;
     }
  if (zeta)
     {
       dword savepos=filepos;
       ResetTempFile();
       rampage=slockdata[tablepointer];
       if (rampage)
	  {
	    SpeedEndBlock=0;
	    expectedlength=1+slockdata[tablepointer+1]+256*(slockdata[tablepointer+2]);
	    nxtloadpos=slockdata[tablepointer+3]+256*(slockdata[tablepointer+4]);
	  }
       else SpeedEndBlock=1;
       tablepointer+=5;
       filepos=savepos;
       lseek(inpfile.handle,filepos,SEEK_SET);
       inpfile.bufpoint=0;
     }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0x827b(%rip)      # 0xf1b4
je 0x708f
movl %edi, %r14d
movq 0x829f(%rip), %rbx      # 0xf1e8
callq 0x161e
movl 0x82bc(%rip), %eax      # 0xf210
movl 0x82de(%rip), %ecx      # 0xf238
leal -0x319(%rcx), %edx
cmpl %edx, %eax
jbe 0x6fa3
cmpl %ecx, %eax
setae %cl
cmpl $0x2, %r14d
setne %dl
orb %cl, %dl
jne 0x6fa3
leaq 0x1053d(%rip), %r15     # 0x174b8
movq %r15, %rdi
callq 0x1d8c
movq %r15, %rdi
callq 0x1d8c
xorb 0x816f(%rip), %al       # 0xf100
addb 0x816a(%rip), %al       # 0xf101
movb %al, 0x8163(%rip)       # 0xf100
movl 0x826d(%rip), %eax      # 0xf210
movl 0x8293(%rip), %edx      # 0xf23c
movl %eax, %ecx
subl %edx, %ecx
setb %sil
leal (%rax,%r14), %edi
cmpl %edx, %edi
setbe %dl
testb %dl, %sil
jne 0x7006
movl 0x8273(%rip), %edx      # 0xf238
movl $0xc001, %esi           # imm = 0xC001
cmpl %esi, %edx
setae %dil
cmpl %esi, %eax
setae %sil
testb %dil, %sil
jne 0x6fee
movl $0xc000, %esi           # imm = 0xC000
cmpl %esi, %edx
setae %dl
cmpl %esi, %eax
setae %al
orb %dl, %al
jne 0x7006
cmpl $0x81, %r14d
jae 0x7334
movzbl %cl, %esi
movl %r14d, %edi
callq 0x6cca
movl 0x8238(%rip), %eax      # 0xf244
leal 0x2(%rax), %edx
leaq 0x14f2a(%rip), %rcx     # 0x1bf40
movzbl (%rdx,%rcx), %esi
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
shll $0x8, %edx
orl %esi, %edx
movl %edx, 0x81e8(%rip)      # 0xf214
je 0x705c
incl %edx
movl %edx, 0x81de(%rip)      # 0xf214
movzbl (%rax,%rcx), %edx
leal 0x1(%rax), %esi
movzbl (%rsi,%rcx), %esi
shll $0x8, %esi
orl %edx, %esi
movl %esi, 0x81c4(%rip)      # 0xf210
leal 0x4(%rax), %edx
movb (%rdx,%rcx), %cl
movb %cl, 0x151e8(%rip)      # 0x1c240
xorl %ecx, %ecx
jmp 0x705e
movb $0x1, %cl
movb %cl, 0x14b88(%rip)      # 0x1bbec
addl $0x5, %eax
movl %eax, 0x81d7(%rip)      # 0xf244
movq %rbx, 0x8174(%rip)      # 0xf1e8
movzbl 0x8205(%rip), %edi      # 0xf280
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x82f1(%rip)      # 0xf380
cmpb $0x0, 0x811c(%rip)      # 0xf1b2
je 0x7290
cmpb $0x0, 0x818d(%rip)      # 0xf230
je 0x713f
callq 0x161e
callq 0x1659
leaq 0x103fe(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %dl
xorl %ecx, %ecx
movl %ecx, %esi
shrb %sil
movl %eax, %ecx
andb $-0x80, %cl
orb %sil, %cl
addb %al, %al
decb %dl
jne 0x70c3
movb %cl, 0x8155(%rip)       # 0xf231
cmpl $0x5b00, 0x812a(%rip)   # imm = 0x5B00
sete %al
cmpb $0x3b, %cl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7105
movl $0x0, 0x8110(%rip)      # 0xf210
jmp 0x732e
leaq 0x103ac(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x7115
movb %dl, 0x8103(%rip)       # 0xf231
callq 0x161e
callq 0x16fa
movb $0x0, 0x80f1(%rip)      # 0xf230
movsd 0x14641(%rip), %xmm0    # 0x1b788
movsd 0x14659(%rip), %xmm1    # 0x1b7a8
movl $0x4, %edi
callq 0x38de
movl $0x4, %esi
movl $0x8, %edi
callq 0x6388
callq 0x1659
callq 0x161e
leaq 0x1033f(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x7182
movzbl %dl, %eax
movl %eax, 0x8076(%rip)      # 0xf214
leaq 0x10313(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x71ae
movzbl %dl, %eax
shll $0x8, %eax
addl %eax, 0x8047(%rip)      # 0xf214
leaq 0x102e4(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x71dd
movzbl %dl, %eax
movl %eax, 0x8017(%rip)      # 0xf210
leaq 0x102b8(%rip), %rdi     # 0x174b8
callq 0x1d8c
movb $0x8, %cl
xorl %edx, %edx
movl %edx, %esi
shrb %sil
movl %eax, %edx
andb $-0x80, %dl
orb %sil, %dl
addb %al, %al
decb %cl
jne 0x7209
movzbl %dl, %eax
shll $0x8, %eax
addl 0x7fe8(%rip), %eax      # 0xf210
movl %eax, 0x7fe2(%rip)      # 0xf210
je 0x725d
movb 0x7ffb(%rip), %cl       # 0xf231
xorl %edx, %edx
cmpb $0x24, %cl
sete %dl
shll $0x8, %edx
xorl %esi, %esi
cmpb $0x25, %cl
setne %sil
shll $0x8, %esi
addl %eax, %edx
leal (%rsi,%rdx), %eax
addl $0xffffff00, %eax       # imm = 0xFFFFFF00
movl %eax, 0x7fb3(%rip)      # 0xf210
callq 0x16fa
movl 0x7fac(%rip), %eax      # 0xf214
movb $0x1, %cl
cmpl $0x6, %eax
jb 0x728a
movl 0x7f9b(%rip), %ecx      # 0xf210
cmpl $0x5b1c, %ecx           # imm = 0x5B1C
setb %dl
addl %ecx, %eax
cmpl $0x5b1e, %eax           # imm = 0x5B1E
setae %cl
andb %dl, %cl
movb %cl, 0x7fa0(%rip)       # 0xf230
cmpb $0x0, 0x7f1e(%rip)      # 0xf1b5
je 0x732e
movq 0x7f44(%rip), %rbx      # 0xf1e8
callq 0x161e
movl 0x7f95(%rip), %eax      # 0xf244
leaq 0x14c8a(%rip), %rcx     # 0x1bf40
movb (%rax,%rcx), %dl
movb %dl, 0x14f81(%rip)      # 0x1c240
testb %dl, %dl
je 0x72fb
leal 0x1(%rax), %edx
movzbl (%rdx,%rcx), %edx
leal 0x2(%rax), %esi
movzbl (%rsi,%rcx), %esi
shll $0x8, %esi
addl %esi, %edx
incl %edx
movl %edx, 0x7f36(%rip)      # 0xf214
leal 0x3(%rax), %edx
movzbl (%rdx,%rcx), %edx
leal 0x4(%rax), %esi
movzbl (%rsi,%rcx), %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl %ecx, 0x7f19(%rip)      # 0xf210
xorl %ecx, %ecx
jmp 0x72fd
movb $0x1, %cl
movb %cl, 0x148e9(%rip)      # 0x1bbec
addl $0x5, %eax
movl %eax, 0x7f38(%rip)      # 0xf244
movq %rbx, 0x7ed5(%rip)      # 0xf1e8
movzbl 0x7f66(%rip), %edi      # 0xf280
movq %rbx, %rsi
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x8052(%rip)      # 0xf380
popq %rbx
popq %r14
popq %r15
retq
movups 0x471a(%rip), %xmm0     # 0xba55
movaps %xmm0, 0x1439e(%rip)    # 0x1b6e0
movb $0x0, 0x143a7(%rip)     # 0x1b6f0
movl $0x8, %edi
callq 0x140c