// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_z12_pbn()
void parse_z12_pbn()
{
double tow;
double jd;
double x,y,z;
float clk_ofs;
float drift;
int week;
int leaps;

   log_packet_id("z12_pbn");

   tsip_rptr = 10;

   tow = (double) tsip_dword() / 1000.0;

   jd = jd_gps - GPS_EPOCH;
   week = (int) (jd / 7.0);
   obs_tow = tow;
   jd_obs = GPS_EPOCH + ((double) week * 7.0) + jtime(0,0,0,tow);


   jd = (jd_gps - jd_zda);
   jd *= (24.0*60.0*60.0);
   leaps = (int) (jd);
   if((leaps >= 18) && (leaps <= 32) && (have_utc_ofs == 0)) {
      if(!user_set_utc_ofs) utc_offset = leaps;
      check_utc_ofs(112);
   }

   z12_site[0] = tsip_byte();  // site name
   z12_site[1] = tsip_byte();
   z12_site[2] = tsip_byte();
   z12_site[3] = tsip_byte();
   z12_site[4] = 0;
   strcpy(rinex_site, z12_site);
   if(1 && strstr(marker_name, DEFAULT_NAME)) {
      strcpy(marker_name, z12_site);
   }

   x = tsip_double();  // ecef coords
   y = tsip_double();
   z = tsip_double();
   ecef_to_lla(x,y,z);
if(debug_file && show_debug_info) {
fprintf(debug_file, "PBN: tow %f  jd_obs:%f  ecef:%f %f %f  lat:%f lon:%f  alt:%f\n", tow, jd_obs, x,y,x, elat*180.0/PI,elon*180.0/PI,ealt);
}

   if(x && y && z) {
      lat = elat;
      lon = elon;
      alt = ealt;
   }

   clk_ofs = tsip_single();

   tsip_single();  // ecef velocity
   tsip_single();
   tsip_single();

   drift = tsip_single();

   pdop = (DATA_SIZE) (((double) tsip_word()) / 100.0);
   have_dops |= PDOP;

in_mpc = 0;
poll_z12_time(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0xce85a(%rip), %rdi     # 0x186409
callq 0x7add0
leaq 0x2df879(%rip), %rax    # 0x397434
movw $0xa, (%rax)
callq 0x7a680
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0xb745c(%rip), %xmm1    # 0x16f030
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x2b4b34(%rip), %rax    # 0x36c718
movsd (%rax), %xmm0
movsd 0xb9a28(%rip), %xmm1    # 0x171618
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0xb9a82(%rip), %xmm1    # 0x171688
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x34(%rbp)
movsd -0x8(%rbp), %xmm0
leaq 0x2b4b3b(%rip), %rax    # 0x36c758
movsd %xmm0, (%rax)
cvtsi2sdl -0x34(%rbp), %xmm0
movsd 0xb9a5a(%rip), %xmm1    # 0x171688
mulsd %xmm1, %xmm0
movsd 0xb99de(%rip), %xmm1    # 0x171618
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x8(%rbp), %xmm0
xorl %edx, %edx
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
addsd %xmm1, %xmm0
leaq 0x2b4aea(%rip), %rax    # 0x36c750
movsd %xmm0, (%rax)
leaq 0x2b4aa7(%rip), %rax    # 0x36c718
movsd (%rax), %xmm0
subsd 0x313313(%rip), %xmm0   # 0x3caf90
movsd %xmm0, -0x10(%rbp)
movsd 0xb737e(%rip), %xmm0    # 0x16f008
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
cvttsd2si -0x10(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x12, -0x38(%rbp)
jl 0xb7cd6
cmpl $0x20, -0x38(%rbp)
jg 0xb7cd6
leaq 0x2b484d(%rip), %rax    # 0x36c4fc
cmpl $0x0, (%rax)
jne 0xb7cd6
leaq 0x2b4c59(%rip), %rax    # 0x36c914
cmpl $0x0, (%rax)
jne 0xb7ccc
movl -0x38(%rbp), %ecx
leaq 0x2b4c3e(%rip), %rax    # 0x36c908
movl %ecx, (%rax)
movl $0x70, %edi
callq 0x7a270
callq 0x7a510
movb %al, %cl
leaq 0x2e516d(%rip), %rax    # 0x39ce51
movb %cl, (%rax)
callq 0x7a510
movb %al, %cl
leaq 0x2e515d(%rip), %rax    # 0x39ce51
movb %cl, 0x1(%rax)
callq 0x7a510
movb %al, %cl
leaq 0x2e514c(%rip), %rax    # 0x39ce51
movb %cl, 0x2(%rax)
callq 0x7a510
movb %al, %cl
leaq 0x2e513b(%rip), %rax    # 0x39ce51
movb %cl, 0x3(%rax)
leaq 0x2e5131(%rip), %rax    # 0x39ce51
movb $0x0, 0x4(%rax)
leaq 0x1e59f5(%rip), %rdi    # 0x29d720
leaq 0x2e511f(%rip), %rsi    # 0x39ce51
callq 0x9350
leaq 0x1e58f2(%rip), %rdi    # 0x29d630
leaq 0xb9090(%rip), %rsi     # 0x170dd5
callq 0x9090
cmpq $0x0, %rax
je 0xb7d63
leaq 0x1e58d9(%rip), %rdi    # 0x29d630
leaq 0x2e50f3(%rip), %rsi    # 0x39ce51
callq 0x9350
callq 0x7a9d0
movsd %xmm0, -0x18(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x20(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x28(%rbp), %xmm2
callq 0x7fe10
leaq 0x1e57d4(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xb7e29
leaq 0x1bfcf7(%rip), %rax    # 0x277aa4
cmpb $0x0, (%rax)
je 0xb7e29
leaq 0x1e57b7(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movsd -0x8(%rbp), %xmm0
leaq 0x2b4988(%rip), %rax    # 0x36c750
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm2
movsd -0x20(%rbp), %xmm3
movsd -0x18(%rbp), %xmm4
movsd 0xb7295(%rip), %xmm5    # 0x16f078
mulsd 0x313e8d(%rip), %xmm5   # 0x3cbc78
movsd 0xb97d5(%rip), %xmm6    # 0x1715c8
divsd %xmm6, %xmm5
movsd 0xb7279(%rip), %xmm6    # 0x16f078
mulsd 0x313e79(%rip), %xmm6   # 0x3cbc80
movsd 0xb97b9(%rip), %xmm7    # 0x1715c8
divsd %xmm7, %xmm6
movsd 0x313e6d(%rip), %xmm7   # 0x3cbc88
leaq 0xce5ef(%rip), %rsi     # 0x186411
movb $0x8, %al
callq 0x9550
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb7e3b
jp 0xb7e3b
jmp 0xb7e98
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb7e4d
jp 0xb7e4d
jmp 0xb7e98
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb7e5f
jp 0xb7e5f
jmp 0xb7e98
movsd 0x313e11(%rip), %xmm0   # 0x3cbc78
leaq 0x2b4342(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movsd 0x313e06(%rip), %xmm0   # 0x3cbc80
leaq 0x2b4337(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movsd 0x313dfb(%rip), %xmm0   # 0x3cbc88
leaq 0x2b432c(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
callq 0x7a860
movss %xmm0, -0x2c(%rbp)
callq 0x7a860
callq 0x7a860
callq 0x7a860
callq 0x7a860
movss %xmm0, -0x30(%rbp)
callq 0x7a560
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
movsd 0xb7181(%rip), %xmm1    # 0x16f050
divsd %xmm1, %xmm0
leaq 0x1ca7ee(%rip), %rax    # 0x2826c8
movsd %xmm0, (%rax)
leaq 0x1ca7df(%rip), %rax    # 0x2826c4
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x1ca7d3(%rip), %rax    # 0x2826c4
movl %ecx, (%rax)
movl $0x0, 0x3190ff(%rip)    # 0x3d0ffc
movl $0x1, %edi
callq 0x962d0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)