// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_moto_En(int)
void parse_moto_En(int num_chans)
{
int i;
S32 sawtooth;
s16 accu;

   if(num_chans == 6)      log_packet_id("6-chan traim info");
   else if(num_chans == 8) log_packet_id("8-chan traim info");
   else                    log_packet_id("unkn-chans traim info");

   if((num_chans == 6) && have_moto_En) return;

   if(num_chans != moto_chans) {
      moto_chans = num_chans;
      config_msg_ofs();
   }

   tsip_byte();  // output rate
   traim_mode = tsip_byte();
   have_traim = 1;
   traim_threshold = tsip_word();
   pps_enabled = pps_mode = tsip_byte();  // 0=off, 1=always on,  2=on when tracking, 3=on when traim met
   have_pps_enable = 6;
   have_pps_mode = 6;

   tsip_byte();  // pps rate   // !!!!! have_pps_rate
   tsip_byte();
   tsip_byte();

   tsip_byte();  // next pps time
   tsip_byte();
   tsip_word();
   tsip_byte();
   tsip_byte();
   tsip_byte();

   tsip_byte();  // pps status (=0off, 1=enabled)
   tsip_byte();  // 0=sync to UTC  1=sync to GPS
   traim_status = tsip_byte();
   tsip_byte();

   accu = tsip_word();     // time accuracy
   sawtooth = tsip_byte(); // sawtooth
   if(sawtooth & 0x80) sawtooth |= (~(S32)0xFF);
   have_sawtooth = 1;

   dac_voltage = (float) sawtooth;
   pps_offset = (double) accu;
   have_pps_offset = 5;
   have_rcvr_pps = 5;
//adadad   if(jitter_adev == 0) do_pps_adev(pps_offset);

   for(i=0; i<num_chans; i++) {
      tsip_byte();  // prn
      tsip_dword(); // time fraction
   }
//sprintf(debug_text2, "En: thresh:%d tmode:%d tstat:%d  pps:%d  saw:%d  rate:%d   ", 
//traim_threshold,traim_mode,traim_status,pps_mode,sawtooth,pps_rate);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
cmpl $0x6, %edi
je 0x9b879
cmpl $0x8, %ebx
jne 0x9b897
leaq 0x89577(%rip), %rdi     # 0x124dee
jmp 0x9b89e
leaq 0x8955c(%rip), %rdi     # 0x124ddc
callq 0x58dc2
leaq 0x271988(%rip), %rax    # 0x30d214
cmpl $0x0, (%rax)
jne 0x9bb00
jmp 0x9b8a3
leaq 0x89562(%rip), %rdi     # 0x124e00
callq 0x58dc2
leaq 0x17f77a(%rip), %rax    # 0x21b024
cmpl %ebx, (%rax)
je 0x9b8b5
movl %ebx, (%rax)
callq 0x4771f
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b8cb
leaq 0x1a36a8(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b8e1
leaq 0x1a3692(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x17f7d5(%rip), %rcx    # 0x21b0c0
movl %eax, (%rcx)
leaq 0x271ad4(%rip), %rax    # 0x30d3c8
movl $0x1, (%rax)
callq 0x588d2
movzwl %ax, %eax
leaq 0x17f7bb(%rip), %rcx    # 0x21b0c4
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b921
leaq 0x1a3652(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x2723fa(%rip), %rcx    # 0x30dd22
movb %al, (%rcx)
leaq 0x2723ef(%rip), %rcx    # 0x30dd20
movb %al, (%rcx)
leaq 0x2719a2(%rip), %rax    # 0x30d2dc
movl $0x6, %ecx
movl %ecx, (%rax)
leaq 0x2719a4(%rip), %rax    # 0x30d2ec
movl %ecx, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b960
leaq 0x1a3613(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b976
leaq 0x1a35fd(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b98c
leaq 0x1a35e7(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b9a2
leaq 0x1a35d1(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b9b8
leaq 0x1a35bb(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588d2
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b9d3
leaq 0x1a35a0(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b9e9
leaq 0x1a358a(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9b9ff
leaq 0x1a3574(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9ba15
leaq 0x1a355e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9ba2b
leaq 0x1a3548(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9ba41
leaq 0x1a3532(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x17f67d(%rip), %rcx    # 0x21b0c8
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9ba63
leaq 0x1a3510(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588d2
movl %eax, %r14d
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9ba81
leaq 0x1a34f2(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
movsbl %al, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl %eax, %ecx
cvtsi2ss %ecx, %xmm0
leaq 0x27192a(%rip), %rax    # 0x30d3c4
movl $0x1, (%rax)
cvtss2sd %xmm0, %xmm0
leaq 0x270f55(%rip), %rax    # 0x30ca00
movsd %xmm0, (%rax)
movswl %r14w, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x270cf7(%rip), %rax    # 0x30c7b8
movsd %xmm0, (%rax)
leaq 0x27176c(%rip), %rax    # 0x30d238
movl $0x5, %ecx
movl %ecx, (%rax)
leaq 0x27176a(%rip), %rax    # 0x30d244
movl %ecx, (%rax)
testl %ebx, %ebx
jle 0x9bb00
leaq 0x1a3489(%rip), %r14    # 0x23ef70
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9baf7
orb $0x8, (%r14)
callq 0x58964
decl %ebx
jne 0x9bae7
popq %rbx
popq %r14
popq %rbp
retq