// File: /workspace/github_c_makefile_star2_O3/mincebert[P]maketzx/maketzx.c
// Function: WriteTZXTurboBlock
void WriteTZXTurboBlock(dword lpilot,byte lastbyte,dword datalen)
{
  dword count;
  word pilotpulses=2*lpilot/pilot.samples;
  PushFilePointers();
  turboblock[1]=Lo(pilot.tstates); turboblock[2]=Hi(pilot.tstates);
  turboblock[3]=Lo(syncx.tstates); turboblock[4]=Hi(syncx.tstates);
  turboblock[5]=Lo(syncx.tstates); turboblock[6]=Hi(syncx.tstates);
  turboblock[7]=Lo(bit0.tstates); turboblock[8]=Hi(bit0.tstates);
  turboblock[9]=Lo(bit1.tstates); turboblock[10]=Hi(bit1.tstates);
  turboblock[11]=Lo(pilotpulses); turboblock[12]=Hi(pilotpulses);
  turboblock[13]=lastbyte;
  turboblock[14]=Lo(mspause); turboblock[15]=Hi(mspause);
  turboblock[16]=Lo(datalen); turboblock[17]=Hi(datalen); turboblock[18]=Ehi(datalen);
  for (count=0; count<sizeof(turboblock); count++) PutData(&outfile,turboblock[count],1);
  ResetTempFile();
  for (count=0; count<datalen; count++) PutData(&outfile,GetData(&tempfile),1);
  PopFilePointers();
  lseek(inpfile.handle,filepos,SEEK_SET);
  inpfile.bufpoint=0;
  ResetTempFile();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
addq %rdi, %rdi
movq %rdi, %xmm0
punpckldq 0x5d49(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x5d51(%rip), %xmm0     # 0xb420
movl %esi, %ebp
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x16063(%rip), %xmm1    # 0x1b748
cvttsd2si %xmm1, %r14
callq 0x1659
movzwl 0x1605a(%rip), %eax     # 0x1b750
movw %ax, 0x9a64(%rip)       # 0xf161
movl 0x1606d(%rip), %eax     # 0x1b770
movb %al, 0x9a5a(%rip)       # 0xf163
movl %eax, %ecx
shrl $0x8, %ecx
movb %cl, 0x9a50(%rip)       # 0xf164
movb %al, 0x9a4b(%rip)       # 0xf165
movb %cl, 0x9a46(%rip)       # 0xf166
movzwl 0x16069(%rip), %eax     # 0x1b790
movw %ax, 0x9a39(%rip)       # 0xf167
movl 0x1607c(%rip), %eax     # 0x1b7b0
movb %al, 0x9a2f(%rip)       # 0xf169
movb %ah, 0x9a2a(%rip)       # 0xf16a
movq %r14, %rax
movb %al, 0x9a22(%rip)       # 0xf16b
movb %ah, 0x9a1d(%rip)       # 0xf16c
movb %bpl, 0x9a17(%rip)      # 0xf16d
movsd 0x9ac2(%rip), %xmm0     # 0xf220
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x5b96(%rip), %xmm0     # 0xb308
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rcx, %rax
movb %al, 0x99eb(%rip)       # 0xf16e
movb %ah, 0x99e6(%rip)       # 0xf16f
movb %bl, 0x99e1(%rip)       # 0xf170
movb %bh, 0x99dc(%rip)       # 0xf171
movl %ebx, %eax
shrl $0x10, %eax
movb %al, 0x99d2(%rip)       # 0xf172
xorl %r15d, %r15d
leaq 0x99b6(%rip), %r12      # 0xf160
leaq 0xdbe7(%rip), %r14      # 0x13398
movzbl (%r15,%r12), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x1e01
incq %r15
cmpq $0x13, %r15
jne 0x57b1
callq 0x161e
testq %rbx, %rbx
je 0x5801
leaq 0x11cdb(%rip), %r14     # 0x174b8
leaq 0xdbb4(%rip), %r15      # 0x13398
movq %r14, %rdi
callq 0x1d8c
movzbl %al, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x1e01
decq %rbx
jne 0x57e4
callq 0x16fa
movzbl 0x9a73(%rip), %edi      # 0xf280
movq 0x99d4(%rip), %rsi      # 0xf1e8
xorl %edx, %edx
callq 0x10d0
movl $0x0, 0x9b5b(%rip)      # 0xf380
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x161e