// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_venus_nav()
void parse_venus_nav()
{
double jd;
u08 fix_mode;

   log_packet_id("venus_nav");
   if(saw_venus_raw & 0x02) return;  //rnx2

   fix_mode = tsip_byte();  // fix mode
   if(minor_alarms & MINOR_SURVEY) rcvr_mode = RCVR_MODE_SURVEY;
   else if(venus_hold_mode)        rcvr_mode = RCVR_MODE_HOLD;
   else if(fix_mode == 0)          rcvr_mode = RCVR_MODE_ACQUIRE;
   else if(fix_mode == 1)          rcvr_mode = RCVR_MODE_2D;
   else if(fix_mode == 2)          rcvr_mode = RCVR_MODE_3D;
   else if(fix_mode == 3)          rcvr_mode = RCVR_MODE_3D;
   else                            rcvr_mode = RCVR_MODE_UNKNOWN;

   tsip_byte();  // sat count
   gps_week = tsip_word();  // week
   faked_tow = 0;
   pri_tow = this_tow = tow = survey_tow = tsip_dword(); // tow

   lat = ((double) (S32) tsip_dword()) * 1.0E-7 * PI / 180.0; // lat
   lon = ((double) (S32) tsip_dword()) * 1.0E-7 * PI / 180.0; // lon
   alt = ((double) (S32) tsip_dword()) / 100.0; // lon
   tsip_dword(); // msl alt

   gdop = ((float) (s16) tsip_word()) / 100.0F;  // GDOP
   pdop = ((float) (s16) tsip_word()) / 100.0F;  // PDOP
   hdop = ((float) (s16) tsip_word()) / 100.0F;  // HDOP
   vdop = ((float) (s16) tsip_word()) / 100.0F;  // VDOP
   tdop = ((float) (s16) tsip_word()) / 100.0F;  // TDOP
   have_dops |= (GDOP | PDOP | HDOP | VDOP | TDOP);

   ecef_x = tsip_dword(); // ecefx
   ecef_y = tsip_dword(); // ecefy
   ecef_z = tsip_dword(); // ecefz
   tsip_dword(); // ecefvx
   tsip_dword(); // ecefvy
   tsip_dword(); // ecefvz

   if(have_tow == 0) need_redraw = 2029;
   have_tow = 5;

   if(have_week == 0) need_redraw = 2030;
   have_week = 5;

   jd = (double) (u32) pri_tow;
   jd /= 100.0;
   jd += 0.01;  // adjust for possible roundoff

   if(timing_mode != TMODE_GPS) {  // we want UTC time - convert gps to utc
      jd -= (double) utc_offset;
   }
   
   jd /= (24.0*60.0*60.0);
   jd += GPS_EPOCH;
   jd += ((double) gps_week) * 7.0;
   set_gregorian_time(jd);

   pri_tow /= 100;
   this_tow /= 100;
   survey_tow /= 100;

   query_venus_msg(QUERY_VENUS_LEAP);  // get UTC offset

   level_type = "dBc";
   update_gps_screen(1002); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x8db39(%rip), %rdi     # 0x124926
callq 0x58dc2
leaq 0x2a6ffb(%rip), %rax    # 0x33ddf4
testb $0x2, (%rax)
jne 0x97175
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x96e18
leaq 0x1a815b(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
leaq 0x2763b9(%rip), %rcx    # 0x30d1d8
movb $0xb, %dl
testb $0x20, (%rcx)
jne 0x96e46
leaq 0x2762a6(%rip), %rcx    # 0x30d0d3
movb $0x7, %dl
cmpb $0x0, (%rcx)
jne 0x96e46
movb $0x63, %dl
testb $-0x4, %al
jne 0x96e46
shll $0x3, %eax
movl $0x4040309, %edx        # imm = 0x4040309
movl %eax, %ecx
shrl %cl, %edx
leaq 0x276283(%rip), %rax    # 0x30d0d0
movb %dl, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x96e65
leaq 0x1a810e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588d2
leaq 0x2768c7(%rip), %r12    # 0x30d738
movw %ax, (%r12)
leaq 0x2768cb(%rip), %rax    # 0x30d748
movl $0x0, (%rax)
callq 0x58964
movl %eax, %ecx
leaq 0x2768bf(%rip), %rbx    # 0x30d750
movq %rcx, (%rbx)
leaq 0x2768a1(%rip), %rcx    # 0x30d73c
movl %eax, (%rcx)
leaq 0x27689c(%rip), %r14    # 0x30d740
movl %eax, (%r14)
leaq 0x276896(%rip), %r15    # 0x30d744
movl %eax, (%r15)
callq 0x58964
cvtsi2sd %eax, %xmm0
mulsd 0x87396(%rip), %xmm0    # 0x11e258
mulsd 0x7495e(%rip), %xmm0    # 0x10b828
divsd 0x7495e(%rip), %xmm0    # 0x10b830
leaq 0x2760f7(%rip), %rax    # 0x30cfd0
movsd %xmm0, (%rax)
callq 0x58964
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x87367(%rip), %xmm0    # 0x11e258
mulsd 0x7492f(%rip), %xmm0    # 0x10b828
divsd 0x7492f(%rip), %xmm0    # 0x10b830
leaq 0x2760d0(%rip), %rax    # 0x30cfd8
movsd %xmm0, (%rax)
callq 0x58964
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x72140(%rip), %xmm0    # 0x109060
leaq 0x2760b9(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
callq 0x58964
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x7612b(%rip), %xmm0    # 0x10d070
cvtss2sd %xmm0, %xmm0
leaq 0x18c5b0(%rip), %rax    # 0x223500
movsd %xmm0, (%rax)
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x76107(%rip), %xmm0    # 0x10d070
cvtss2sd %xmm0, %xmm0
leaq 0x18c574(%rip), %rax    # 0x2234e8
movsd %xmm0, (%rax)
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x760e3(%rip), %xmm0    # 0x10d070
cvtss2sd %xmm0, %xmm0
leaq 0x18c558(%rip), %rax    # 0x2234f0
movsd %xmm0, (%rax)
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x760bf(%rip), %xmm0    # 0x10d070
cvtss2sd %xmm0, %xmm0
leaq 0x18c53c(%rip), %rax    # 0x2234f8
movsd %xmm0, (%rax)
callq 0x588d2
cwtl
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x7609b(%rip), %xmm0    # 0x10d070
cvtss2sd %xmm0, %xmm0
leaq 0x18c528(%rip), %rax    # 0x223508
movsd %xmm0, (%rax)
leaq 0x18c4f9(%rip), %rax    # 0x2234e4
orb $0x1f, (%rax)
callq 0x58964
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x275fe4(%rip), %rax    # 0x30cfe8
movsd %xmm0, (%rax)
callq 0x58964
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x275fd2(%rip), %rax    # 0x30cff0
movsd %xmm0, (%rax)
callq 0x58964
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x275fc0(%rip), %rax    # 0x30cff8
movsd %xmm0, (%rax)
callq 0x58964
callq 0x58964
callq 0x58964
leaq 0x2762d6(%rip), %rax    # 0x30d328
cmpl $0x0, (%rax)
jne 0x97064
leaq 0x1817e6(%rip), %rcx    # 0x218844
movl $0x7ed, (%rcx)          # imm = 0x7ED
movl $0x5, (%rax)
leaq 0x2762bb(%rip), %rax    # 0x30d32c
cmpl $0x0, (%rax)
jne 0x97083
leaq 0x1817c7(%rip), %rcx    # 0x218844
movl $0x7ee, (%rcx)          # imm = 0x7EE
movl $0x5, (%rax)
movl (%r15), %eax
cvtsi2sd %rax, %xmm1
divsd 0x71fc7(%rip), %xmm1    # 0x109060
addsd 0x7205f(%rip), %xmm1    # 0x109100
leaq 0x276415(%rip), %rax    # 0x30d4bd
cmpb $0x0, (%rax)
xorpd %xmm0, %xmm0
je 0x970bf
leaq 0x276670(%rip), %rax    # 0x30d728
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
subsd %xmm0, %xmm1
divsd 0x71f4d(%rip), %xmm1    # 0x109018
addsd 0x747c5(%rip), %xmm1    # 0x10b898
movzwl (%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x74821(%rip), %xmm0    # 0x10b908
addsd %xmm1, %xmm0
callq 0x5c71d
movq (%rbx), %rcx
movabsq $-0x5c28f5c28f5c28f5, %rdx # imm = 0xA3D70A3D70A3D70B
movq %rcx, %rax
imulq %rdx
movl (%r15), %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
movl %eax, (%r15)
movl (%r14), %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
movl %eax, (%r14)
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x6, %rdx
addq %rax, %rdx
movq %rdx, (%rbx)
movl $0x64, %edi
movl $0x2, %esi
callq 0x5fb3c
movl $0x20, %edi
callq 0x590f7
callq 0x61bc1
leaq 0x8ab7c(%rip), %rax     # 0x121cda
leaq 0x1a7d93(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x730e8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq