LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_zda()
void send_zda()
{
   // send time/date as a NMEA GPZDA sentence
   
//   gregorian(0, jd_utc);

   if     (echo_fmt & ECHO_MSECS) sprintf(out, "GPZDA,%010.3f,%02d,%02d,%04d,00,00", nmea_time(), g_day,g_month,g_year);
   else if(echo_fmt & ECHO_HSECS) sprintf(out, "GPZDA,%09.2f,%02d,%02d,%04d,00,00", nmea_time(), g_day,g_month,g_year);
   else                           sprintf(out, "GPZDA,%06d,%02d,%02d,%04d,00,00", (int)nmea_time(), g_day,g_month,g_year);
   echo_nmea_string(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl 0x1018c3(%rip), %ebx    # 0x154580
testb $0x4, %bl
jne 0x52d04
callq 0x52a38
testb $0x2, %bl
jne 0x52d35
cvttsd2si %xmm0, %edx
leaq 0x2a49c9(%rip), %rax    # 0x2f76a0
movl (%rax), %ecx
leaq 0x2a49bc(%rip), %rax    # 0x2f769c
movl (%rax), %r8d
leaq 0x2a49ba(%rip), %rax    # 0x2f76a4
movl (%rax), %r9d
leaq 0x2d352c(%rip), %rdi    # 0x326220
leaq 0xb750c(%rip), %rsi     # 0x10a207
xorl %eax, %eax
callq 0x9060
jmp 0x52d66
callq 0x52a38
leaq 0x2a4990(%rip), %rax    # 0x2f76a0
movl (%rax), %edx
leaq 0x2a4983(%rip), %rax    # 0x2f769c
movl (%rax), %ecx
leaq 0x2a4982(%rip), %rax    # 0x2f76a4
movl (%rax), %r8d
leaq 0x2d34f4(%rip), %rdi    # 0x326220
leaq 0xb748f(%rip), %rsi     # 0x10a1c2
jmp 0x52d5f
leaq 0x2a4964(%rip), %rax    # 0x2f76a0
movl (%rax), %edx
leaq 0x2a4957(%rip), %rax    # 0x2f769c
movl (%rax), %ecx
leaq 0x2a4956(%rip), %rax    # 0x2f76a4
movl (%rax), %r8d
leaq 0x2d34c8(%rip), %rdi    # 0x326220
leaq 0xb7486(%rip), %rsi     # 0x10a1e5
movb $0x1, %al
callq 0x9060
leaq 0x2d34b3(%rip), %rdi    # 0x326220
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x52935
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_rmc()
void send_rmc()
{
char valid;

   // send NMEA GPRMC sentence
   // !!!!!! we should handle GLONASS/GALILEO/BEIDOU

   valid = 'V';
   if     (rcvr_type == NO_RCVR)   valid = 'A';
   else if(rcvr_type == TIDE_RCVR) valid = 'A';
   else if(lat || lon)             valid = 'A';

//   gregorian(0, jd_utc);
   if     (echo_fmt & ECHO_MSECS) sprintf(out, "GPRMC,%010.3f,%c,%s,%s,%s,%s,%06d,,", nmea_time(),valid,nmea_lat(),nmea_lon(),nmea_speed(),nmea_heading(),nmea_date());
   else if(echo_fmt & ECHO_HSECS) sprintf(out, "GPRMC,%09.2f,%c,%s,%s,%s,%s,%06d,,", nmea_time(),valid,nmea_lat(),nmea_lon(),nmea_speed(),nmea_heading(),nmea_date());
   else                           sprintf(out, "GPRMC,%06d,%c,%s,%s,%s,%s,%06d,,", (int) nmea_time(),valid,nmea_lat(),nmea_lon(),nmea_speed(),nmea_heading(),nmea_date());
   echo_nmea_string(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x1afb47(%rip), %rax    # 0x2028d0
movq (%rax), %rax
pushq $0x41
popq %rbx
cmpq $0x400, %rax            # imm = 0x400
je 0x52dd6
cmpq $0x800000, %rax         # imm = 0x800000
je 0x52dd6
leaq 0x2a422a(%rip), %rax    # 0x2f6fd0
leaq 0x2a422b(%rip), %rcx    # 0x2f6fd8
movsd (%rcx), %xmm0
xorpd %xmm1, %xmm1
movsd (%rax), %xmm2
cmpneqpd %xmm1, %xmm2
cmpneqpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movd %xmm0, %eax
testb $0x1, %al
pushq $0x41
popq %rax
pushq $0x56
popq %rbx
cmovnel %eax, %ebx
movl 0x1017a3(%rip), %r14d   # 0x154580
testb $0x4, %r14b
jne 0x52e5c
callq 0x52a38
testb $0x2, %r14b
jne 0x52e99
cvttsd2si %xmm0, %r14d
callq 0x52aba
callq 0x52b54
callq 0x52c29
callq 0x52c71
callq 0x52a86
movl %eax, %r10d
subq $0x8, %rsp
leaq 0x307602(%rip), %r11    # 0x35a420
leaq 0x3074fb(%rip), %r15    # 0x35a320
leaq 0x2d33f4(%rip), %rdi    # 0x326220
leaq 0xb743b(%rip), %rsi     # 0x10a26e
leaq 0x3071e6(%rip), %r8     # 0x35a020
leaq 0x3072df(%rip), %r9     # 0x35a120
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r15
callq 0x9060
addq $0x20, %rsp
jmp 0x52ef8
callq 0x52a38
movsd %xmm0, -0x20(%rbp)
callq 0x52aba
callq 0x52b54
callq 0x52c29
callq 0x52c71
callq 0x52a86
movl %eax, %r10d
leaq 0x307597(%rip), %r11    # 0x35a420
leaq 0x2d3390(%rip), %rdi    # 0x326220
leaq 0xb7390(%rip), %rsi     # 0x10a227
jmp 0x52ecf
movsd %xmm0, -0x20(%rbp)
callq 0x52aba
callq 0x52b54
callq 0x52c29
callq 0x52c71
callq 0x52a86
movl %eax, %r10d
leaq 0x30755f(%rip), %r11    # 0x35a420
leaq 0x2d3358(%rip), %rdi    # 0x326220
leaq 0xb737c(%rip), %rsi     # 0x10a24b
leaq 0x30714a(%rip), %rcx    # 0x35a020
leaq 0x307243(%rip), %r8     # 0x35a120
leaq 0x30743c(%rip), %r9     # 0x35a320
movsd -0x20(%rbp), %xmm0
movl %ebx, %edx
movb $0x1, %al
pushq %r10
pushq %r11
callq 0x9060
popq %rcx
popq %rdx
leaq 0x2d3321(%rip), %rdi    # 0x326220
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x52935
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: echo_nmea()
void echo_nmea()
{
int last_sec = 99;

   // send receiver data formmated as NMEA to the NMEA_PORT

   if(com[NMEA_PORT].process_com == 0) return;  // NMEA_PORT not open
   if(com[NMEA_PORT].com_running <= 0) return;
//ffff if(fake_time_stamp) return;   // don't echo faked time stamps so NTP works better?

   gregorian(0, jd_utc + jtime(0,0,0,TSX_TWEAK));

   if(echo_fmt & ECHO_ZDA) send_zda();
   if(echo_fmt & ECHO_VTG) send_vtg();  // we don't do this one for now
   if(echo_fmt & ECHO_RMC) send_rmc();
   if(echo_fmt & ECHO_GGA) send_gga();


   if(POLLED_RCVR) {
      if(g_seconds == (SCPI_STATUS_SECOND+10)) {
         if(echo_fmt & ECHO_GSA) send_gsa();
         if(echo_fmt & ECHO_GSV) send_gsv();
      }
   }
   else if((g_seconds % 10) == (SCPI_STATUS_SECOND%10)) {
      if(echo_fmt & ECHO_GSA) send_gsa();
      if(echo_fmt & ECHO_GSV) send_gsv();
   }

   last_sec = g_seconds;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x2a4e24(%rip), %rax    # 0x2f82e0
cmpl $0x0, 0x1beb4(%rax)
je 0x53591
cmpl $0x0, 0x1beb0(%rax)
jle 0x53591
leaq 0x2a4053(%rip), %rax    # 0x2f7530
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x2a49db(%rip), %rax    # 0x2f7ec8
movsd (%rax), %xmm0
divsd 0x9fb3f(%rip), %xmm0    # 0xf3038
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc2faf
addsd -0x8(%rbp), %xmm0
xorl %edi, %edi
callq 0xbfac2
movl 0x10106a(%rip), %eax    # 0x154580
btl $0x8, %eax
jae 0x53527
callq 0x52cb1
movl 0x101059(%rip), %eax    # 0x154580
btl $0xa, %eax
jae 0x53538
callq 0x52d78
movl 0x101048(%rip), %eax    # 0x154580
btl $0xb, %eax
jae 0x53543
callq 0x52f0e
leaq 0x1af386(%rip), %rcx    # 0x2028d0
movabsq $0x101b0e5018, %rdx     # imm = 0x101B0E5018
leaq 0x2a4155(%rip), %rax    # 0x2f76b0
movl (%rax), %eax
testq %rdx, (%rcx)
je 0x53569
cmpl $0x2a, %eax
je 0x53574
jmp 0x53591
pushq $0xa
popq %rcx
cltd
idivl %ecx
cmpl $0x2, %edx
jne 0x53591
movl 0x101006(%rip), %eax    # 0x154580
btl $0xc, %eax
jae 0x5358b
callq 0x530db
movl 0x100ff5(%rip), %eax    # 0x154580
btl $0xd, %eax
jb 0x53597
addq $0x10, %rsp
popq %rbp
retq
addq $0x10, %rsp
popq %rbp
jmp 0x532db
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: dump_prn_info()
void dump_prn_info()
{
int i;

   if(prn_file == 0) return;
   if(new_sat_azel == 0) return;
   new_sat_azel = 0;

   for(i=0; i<=SUN_MOON_PRN; i++) {
      if((sat[i].tracking > 0) || (i == SUN_PRN) || (i == MOON_PRN)) {
         fprintf(prn_file, "%.6f %4d %6.2f %6.2f %6.2f\n", jd_utc, i, sat[i].azimuth, sat[i].elevation, sat[i].sig_level);
      }
   }

   ++prn_count;
   fprintf(prn_file, "# %d\n", prn_count);
   if(prn_flush_mode) fflush(prn_file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x1d3d81(%rip), %r15    # 0x228378
cmpq $0x0, (%r15)
je 0x546c9
cmpl $0x0, 0x3017b4(%rip)    # 0x355dbc
je 0x546c9
andl $0x0, 0x3017a7(%rip)    # 0x355dbc
movl $0x218, %r12d           # imm = 0x218
addq 0xe5926(%rip), %r12     # 0x139f48
xorl %ebx, %ebx
leaq 0x2a2f05(%rip), %r13    # 0x2f7530
leaq 0xbcb64(%rip), %r14     # 0x111196
cmpq $0x3ea, %rbx            # imm = 0x3EA
je 0x54689
movl %ebx, %eax
andl $0x3fe, %eax            # imm = 0x3FE
cmpl $0x3e8, %eax            # imm = 0x3E8
je 0x54650
cmpl $0x0, (%r12)
jle 0x5467d
movq (%r15), %rdi
movsd (%r13), %xmm0
cvtss2sd -0x10(%r12), %xmm1
cvtss2sd -0xc(%r12), %xmm2
cvtss2sd -0x1f8(%r12), %xmm3
movq %r14, %rsi
movl %ebx, %edx
movb $0x4, %al
callq 0x9560
incq %rbx
addq $0x348, %r12            # imm = 0x348
jmp 0x54632
leaq 0x1d3d88(%rip), %rax    # 0x228418
movl (%rax), %edx
incl %edx
movl %edx, (%rax)
movq (%r15), %rdi
leaq 0xbcb12(%rip), %rsi     # 0x1111b2
xorl %eax, %eax
callq 0x9560
leaq 0x1d3d7e(%rip), %rax    # 0x22842c
cmpl $0x0, (%rax)
je 0x546c9
movq (%r15), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9420
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: set_gregorian_time(double)
void set_gregorian_time(double jd)
{
   // set the receiver time/date variables to jd decoded to gregorian

   gregorian(0, jd);  // convert julian date to gregorian

   pri_year = year = g_year;  // update date/time variables to the gregorian values
   pri_month = month = g_month;
   pri_day = day = g_day;

   pri_hours = hours = g_hours;
   pri_minutes = minutes = g_minutes;
   pri_seconds = seconds = g_seconds;
   pri_frac = raw_frac = g_frac;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %edi, %edi
callq 0xbfac2
leaq 0x2a2300(%rip), %rax    # 0x2f76a4
movl (%rax), %eax
leaq 0x2a212f(%rip), %rcx    # 0x2f74dc
movl %eax, (%rcx)
leaq 0x2a215e(%rip), %rcx    # 0x2f7514
movl %eax, (%rcx)
leaq 0x2a22dd(%rip), %rax    # 0x2f769c
movl (%rax), %eax
leaq 0x2a2110(%rip), %rcx    # 0x2f74d8
movl %eax, (%rcx)
leaq 0x2a213f(%rip), %rcx    # 0x2f7510
movl %eax, (%rcx)
leaq 0x2a22c6(%rip), %rax    # 0x2f76a0
movl (%rax), %eax
leaq 0x2a20f1(%rip), %rcx    # 0x2f74d4
movl %eax, (%rcx)
leaq 0x2a2120(%rip), %rcx    # 0x2f750c
movl %eax, (%rcx)
leaq 0x2a22b3(%rip), %rax    # 0x2f76a8
movl (%rax), %eax
leaq 0x2a20d2(%rip), %rcx    # 0x2f74d0
movl %eax, (%rcx)
leaq 0x2a2101(%rip), %rcx    # 0x2f7508
movl %eax, (%rcx)
leaq 0x2a229c(%rip), %rax    # 0x2f76ac
movl (%rax), %eax
leaq 0x2a20b3(%rip), %rcx    # 0x2f74cc
movl %eax, (%rcx)
leaq 0x2a20e2(%rip), %rcx    # 0x2f7504
movl %eax, (%rcx)
leaq 0x2a2285(%rip), %rax    # 0x2f76b0
movl (%rax), %eax
leaq 0x2a2094(%rip), %rcx    # 0x2f74c8
movl %eax, (%rcx)
leaq 0x2a20c3(%rip), %rcx    # 0x2f7500
movl %eax, (%rcx)
leaq 0x2a2272(%rip), %rax    # 0x2f76b8
movsd (%rax), %xmm0
leaq 0x2a208f(%rip), %rax    # 0x2f74e0
movsd %xmm0, (%rax)
leaq 0x2a20bc(%rip), %rax    # 0x2f7518
movsd %xmm0, (%rax)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: lla_to_ecef(double, double, double)
void lla_to_ecef(double lat, double lon, double alt)
{   
double clat;
double slat;
double clon;
double slon;
double N;

   // convert lat/lon/alt values (in radians/meters) to ECEF coordinates

   clat = cos(lat);
   slat = sin(lat);
   clon = cos(lon);
   slon = sin(lon);

   N = WGS84_A / sqrt(1.0 - WGS84_E * WGS84_E * slat * slat);

   ecef_x = (N + alt) * clat * clon;
   ecef_y = (N + alt) * clat * slon;
   ecef_z = (N * (1.0 - WGS84_E * WGS84_E) + alt) * slat;
// sprintf(plot_title, "ecef: %f %f %f", ecef_x,ecef_y,ecef_z);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movsd %xmm2, -0x28(%rbp)
movsd %xmm1, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
callq 0x9710
movsd %xmm0, -0x20(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9710
movsd %xmm0, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9080
movsd 0xb2c3a(%rip), %xmm1    # 0x1081c0
movsd -0x10(%rbp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd 0x9dad5(%rip), %xmm1    # 0xf3070
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x555af
sqrtsd %xmm1, %xmm0
jmp 0x555c2
movapd %xmm1, %xmm0
movsd %xmm4, -0x8(%rbp)
callq 0x9260
movsd -0x8(%rbp), %xmm4
movsd 0xb2bfe(%rip), %xmm1    # 0x1081c8
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm2
addsd %xmm2, %xmm0
movsd -0x20(%rbp), %xmm3
mulsd %xmm0, %xmm3
movsd -0x18(%rbp), %xmm0
mulsd %xmm3, %xmm0
leaq 0x2a19f4(%rip), %rax    # 0x2f6fe8
movsd %xmm0, (%rax)
mulsd %xmm3, %xmm4
leaq 0x2a19ed(%rip), %rax    # 0x2f6ff0
movsd %xmm4, (%rax)
mulsd 0xb2bc1(%rip), %xmm1    # 0x1081d0
addsd %xmm2, %xmm1
movsd -0x10(%rbp), %xmm0
mulsd %xmm1, %xmm0
leaq 0x2a19d5(%rip), %rax    # 0x2f6ff8
movsd %xmm0, (%rax)
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: ecef_to_lla(double, double, double)
void ecef_to_lla(double x, double y, double z)
{
  // convert ECEF coordinate to geocentric lat/lon/alt in radians/meters

  double b = sqrt( (WGS84_A*WGS84_A) * (1.0-(WGS84_E*WGS84_E)) );
  double bsq = (b * b);
  double ep = sqrt( (WGS84_A*WGS84_A - bsq) / bsq);
  double p = sqrt( (x*x) + (y*y) );
  double th = atan2(WGS84_A*z, b*p);

  elon = atan2(y,x);
  elat = atan2( (z + (ep*ep)*b*(sin(th)*sin(th)*sin(th)) ), (p - (WGS84_E*WGS84_E)*WGS84_A*(cos(th)*cos(th)*cos(th))) );

  double N = WGS84_A / ( sqrt(1.0-(WGS84_E*WGS84_E)*(sin(elat)*sin(elat))) );
  ealt = (p / cos(elat)) - N;

  // mod lon to 0-2pi
  elon = fmod(elon,(2.0*PI));
  // correction for altitude near poles left out.  // zork
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movsd %xmm2, -0x18(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm0, -0x28(%rbp)
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm3, %xmm1
sqrtsd %xmm1, %xmm3
movsd %xmm3, -0x20(%rbp)
movsd 0xb2b5f(%rip), %xmm0    # 0x1081c8
mulsd %xmm2, %xmm0
movsd 0xb2b63(%rip), %xmm1    # 0x1081d8
mulsd %xmm3, %xmm1
callq 0x9050
movsd %xmm0, -0x8(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
callq 0x9050
movsd %xmm0, 0x301406(%rip)   # 0x356aa0
movsd -0x8(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9080
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9080
mulsd -0x10(%rbp), %xmm0
mulsd 0xb2b0c(%rip), %xmm0    # 0x1081e0
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9710
movsd %xmm0, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9710
movsd -0x18(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x9710
movsd -0x18(%rbp), %xmm1
mulsd %xmm0, %xmm1
mulsd 0xb2ac8(%rip), %xmm1    # 0x1081e8
addsd -0x20(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
callq 0x9050
movsd %xmm0, 0x301361(%rip)   # 0x356a98
callq 0x9080
movsd %xmm0, -0x8(%rbp)
movsd 0x30134f(%rip), %xmm0   # 0x356a98
callq 0x9080
mulsd -0x8(%rbp), %xmm0
mulsd 0xb2a65(%rip), %xmm0    # 0x1081c0
addsd 0x9d90d(%rip), %xmm0    # 0xf3070
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x55773
sqrtsd %xmm0, %xmm0
jmp 0x55778
callq 0x9260
movsd 0xb2a70(%rip), %xmm1    # 0x1081f0
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rbp)
movsd 0x301307(%rip), %xmm0   # 0x356a98
callq 0x9710
movsd -0x20(%rbp), %xmm1
divsd %xmm0, %xmm1
addsd -0x8(%rbp), %xmm1
movsd %xmm1, 0x3012fc(%rip)   # 0x356aa8
movsd 0x3012ec(%rip), %xmm0   # 0x356aa0
movsd 0xb2a3c(%rip), %xmm1    # 0x1081f8
callq 0x94d0
movsd %xmm0, 0x3012d7(%rip)   # 0x356aa0
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: calc_jd_leap(int)
void calc_jd_leap(int why)
{
double days;

   // calculate the Julian date of the next leapsecond and how many days
   // until the event

   days = jd_leap - jd_utc;
   if(days < 0.0) have_jd_leap = have_leap_days = 0;
   else if(days >= ((double) LEAP_THRESH)) have_jd_leap = have_leap_days = 0;
   else have_jd_leap = have_leap_days = why;

   leap_days = (int) days;

//gregorian(0, jd_leap);
//sprintf(plot_title, "jd_leap %d:  have:%d  %04d/%02d/%02d %02d:%02d:%02d   days:%f", 
//why, have_jd_leap, g_year,g_month,g_day, g_hours,g_minutes,g_seconds, days);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x2a1d86(%rip), %rax    # 0x2f7560
movsd (%rax), %xmm0
leaq 0x2a1d4b(%rip), %rax    # 0x2f7530
subsd (%rax), %xmm0
xorl %eax, %eax
ucomisd 0xb2a0d(%rip), %xmm0    # 0x108200
cmovael %eax, %edi
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmoval %eax, %edi
leaq 0x2a19e8(%rip), %rax    # 0x2f71f0
movl %edi, (%rax)
leaq 0x2a1d57(%rip), %rax    # 0x2f7568
movl %edi, (%rax)
cvttsd2si %xmm0, %eax
leaq 0x2a19ce(%rip), %rcx    # 0x2f71ec
movl %eax, (%rcx)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: calc_leap_days(double, unsigned short, int)
void calc_leap_days(double wn_lsf, unsigned short dn, int why)
{
double jd;

   jd = GPS_EPOCH + (wn_lsf * 7.0) + (dn) - jtime(0,0,0,1.0); // Julian day of leapsecond
if(wn_lsf < 1024) jd += rollover / (1024.0 * 7.0 * 24.0*60.0*60.0);
   jd_leap = jd;
   calc_jd_leap(1);
   return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movapd %xmm0, -0x20(%rbp)
movsd 0xa0149(%rip), %xmm1    # 0xf5980
mulsd %xmm0, %xmm1
addsd 0xa00cd(%rip), %xmm1    # 0xf5910
cvtsi2sd %edi, %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, -0x10(%rbp)
movsd 0x9d818(%rip), %xmm0    # 0xf3070
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc2faf
leaq 0x1afbf6(%rip), %rax    # 0x205460
movsd (%rax), %xmm1
divsd 0xa0322(%rip), %xmm1    # 0xf5b98
movapd -0x10(%rbp), %xmm2
subsd %xmm0, %xmm2
addsd %xmm2, %xmm1
movapd %xmm2, %xmm3
movapd -0x20(%rbp), %xmm2
cmpltsd 0xb2973(%rip), %xmm2    # 0x108208
movapd %xmm2, %xmm0
andnpd %xmm3, %xmm0
andpd %xmm1, %xmm2
orpd %xmm0, %xmm2
leaq 0x2a1cb4(%rip), %rax    # 0x2f7560
movlpd %xmm2, (%rax)
pushq $0x1
popq %rdi
addq $0x20, %rsp
popq %rbp
jmp 0x557cf
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: guess_leap_days()
void guess_leap_days()
{
double today;
double days;

   // If receiver has no day of leapsecond info, we attempt to guess it
   // assuming the leapsecond occurs on 30 Jun or 31 Dec.

   if((minor_alarms & MINOR_LEAP_PEND) == 0) return;  // no leap pending flag
   if(have_leap_days) return;  // receiver provided the leap day

   today = jdate(year,month,day);
   if(month >= 7) {
      days = jdate(year,12,31);
   }
   else {
      days = jdate(year,6,30);
   }
   jd_leap = days + jtime(23,59,59, 0.0);
   have_jd_leap = 2;
//   calc_jd_leap(2);

   days = days-today;
   if(days < 180.0) leap_days = (int) days;
   else leap_days = (-1);
   guessed_leap_days = '?';
}

// Assembly:
leaq 0x2a1914(%rip), %rax    # 0x2f71d8
testb $-0x80, (%rax)
je 0x55995
leaq 0x2a191c(%rip), %rax    # 0x2f71f0
cmpl $0x0, (%rax)
jne 0x55995
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x2a1bed(%rip), %rbx    # 0x2f74dc
movl (%rbx), %edi
leaq 0x2a1be0(%rip), %r14    # 0x2f74d8
movl (%r14), %esi
leaq 0x2a1bd2(%rip), %rax    # 0x2f74d4
movl (%rax), %edx
callq 0xc2f07
movsd %xmm0, -0x20(%rbp)
cmpl $0x7, (%r14)
movl (%rbx), %edi
jl 0x5591d
pushq $0xc
popq %rsi
pushq $0x1f
jmp 0x55922
pushq $0x6
popq %rsi
pushq $0x1e
popq %rdx
callq 0xc2f07
movsd %xmm0, -0x18(%rbp)
pushq $0x17
popq %rdi
pushq $0x3b
popq %rdx
xorpd %xmm0, %xmm0
movl %edx, %esi
callq 0xc2faf
movsd -0x18(%rbp), %xmm1
addsd %xmm1, %xmm0
leaq 0x2a1c12(%rip), %rax    # 0x2f7560
movsd %xmm0, (%rax)
leaq 0x2a1c0f(%rip), %rax    # 0x2f7568
movl $0x2, (%rax)
subsd -0x20(%rbp), %xmm1
movsd 0x9ff3c(%rip), %xmm0    # 0xf58a8
ucomisd %xmm1, %xmm0
cvttsd2si %xmm1, %eax
pushq $-0x1
popq %rcx
cmoval %eax, %ecx
leaq 0x2a186b(%rip), %rax    # 0x2f71ec
movl %ecx, (%rax)
leaq 0x2a186a(%rip), %rax    # 0x2f71f4
movb $0x3f, (%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: record_sig_levels(int)
void record_sig_levels(int prn)
{
float sig;

   // check the signal level for sat PRN "prn", update the sats' max signal
   // level,  and update the signal level map info

   if(prn < 0) return;
   if(prn > MAX_PRN) return;
   if(rcvr_type == RFTG_RCVR) ; 
   else if((lat == 0.0) && (lon == 0.0)) return;

#ifdef SIG_LEVELS
   if(sat[prn].level_msg != 0) { 
      sig = sat[prn].sig_level;
      if(sig < 0.0F) sig = 0.0F - sig;

      if(sat[prn].sig_level > max_sat_db[prn]) {
         max_sat_db[prn] = sig;
      }

      if(sig > max_sig_level) {
         max_sig_level = sig;
      }
      if(sig) {
         if(sig < min_sig_level) {
            min_sig_level = sig;
         }
      }

      sig_level_sum += sig;
      ++sig_level_count;

      if(pause_data) ;
      else if(reading_signals == 0) {
         log_signal(sat[prn].azimuth+0.5F, sat[prn].elevation+0.5F, sig, amu_mode);
      }
      have_snr |= rinex_gnss(prn);
   }
#endif
}

// Assembly:
cmpl $0x3e7, %edi            # imm = 0x3E7
ja 0x55b19
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x1acefb(%rip), %rax    # 0x2028d0
cmpq $0x400000, (%rax)       # imm = 0x400000
jne 0x55ad9
movl %ebx, %ecx
imulq $0x348, %rcx, %rdx      # imm = 0x348
leaq 0x1d35be(%rip), %rax    # 0x228fb0
cmpl $0x0, 0x1c(%rax,%rdx)
je 0x55b13
addq %rdx, %rax
movss 0x20(%rax), %xmm0
xorpd %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss %xmm1, %xmm2
subss %xmm0, %xmm1
andps %xmm2, %xmm1
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
leaq 0x14789b(%rip), %rdx    # 0x19d2c0
ucomiss (%rdx,%rcx,4), %xmm0
jbe 0x55a30
movss %xmm2, (%rdx,%rcx,4)
leaq 0x148831(%rip), %rcx    # 0x19e268
ucomiss (%rcx), %xmm2
jbe 0x55a40
movss %xmm2, (%rcx)
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jne 0x55a4a
jnp 0x55a5e
leaq 0x14881b(%rip), %rcx    # 0x19e26c
movss (%rcx), %xmm0
ucomiss %xmm2, %xmm0
jbe 0x55a5e
movss %xmm2, (%rcx)
cvtss2sd %xmm2, %xmm0
leaq 0x148807(%rip), %rcx    # 0x19e270
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
leaq 0x148800(%rip), %rcx    # 0x19e278
movsd (%rcx), %xmm0
addsd 0x9d5ec(%rip), %xmm0    # 0xf3070
movsd %xmm0, (%rcx)
leaq 0x1af7a5(%rip), %rcx    # 0x205234
leaq 0x2cf842(%rip), %rdx    # 0x3252d8
movb (%rdx), %dl
orb (%rcx), %dl
jne 0x55ac7
movss 0xa1654(%rip), %xmm1    # 0xf70f8
movss 0x208(%rax), %xmm0
addss %xmm1, %xmm0
addss 0x20c(%rax), %xmm1
leaq 0x1d3431(%rip), %rax    # 0x228ef0
movzbl (%rax), %edi
callq 0xe3d50
movl %ebx, %edi
callq 0xca4da
leaq 0x2a1877(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
jmp 0x55b13
leaq 0x2a14f0(%rip), %rax    # 0x2f6fd0
movsd (%rax), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x559e2
jp 0x559e2
leaq 0x2a14d9(%rip), %rax    # 0x2f6fd8
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
jne 0x559e2
jp 0x559e2
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: reset_sat_tracking()
void reset_sat_tracking()
{
int prn;

   // reset all sat tracking flags

   for(prn=0; prn<=MAX_PRN; prn++) {
      sat[prn].tracking = 0;
      sat[prn].level_msg = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x218, %eax            # imm = 0x218
leaq 0x1d2484(%rip), %rcx    # 0x228fb0
cmpq $0xcd358, %rax          # imm = 0xCD358
je 0x56b48
andl $0x0, (%rcx,%rax)
andl $0x0, -0x1fc(%rcx,%rax)
addq $0x348, %rax            # imm = 0x348
jmp 0x56b2c
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: config_sat_rows()
void config_sat_rows()
{
   // calculate how many rows on the screen the sat info display will use

   if(sat_cols <= 0) return;

   sat_rows = max_sat_display / sat_cols;
   ms_row = ms_col = 0;
   if(sat_cols > 1) {
      if(max_sat_display & 1) ++sat_rows;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x29fa3a(%rip), %rax    # 0x2f6784
movl (%rax), %esi
testl %esi, %esi
jle 0x56d91
leaq 0x1d224d(%rip), %rax    # 0x228fa4
movl (%rax), %ecx
movl %ecx, %eax
cltd
idivl %esi
leaq 0x29fa23(%rip), %rdx    # 0x2f6788
movl %eax, (%rdx)
leaq 0x29fa22(%rip), %rdi    # 0x2f6790
andl $0x0, (%rdi)
leaq 0x29fa14(%rip), %rdi    # 0x2f678c
andl $0x0, (%rdi)
cmpl $0x1, %esi
sete %sil
testb $0x1, %cl
sete %cl
orb %sil, %cl
jne 0x56d91
incl %eax
movl %eax, (%rdx)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: config_sat_count(int)
void config_sat_count(int sat_count)
{
   // configure the display for the number of satellite channels

   if(first_key) return;  // delay screen size update until not in a menu
// sprintf(debug_text3, "csc:%d   msd:%d  msc:%d", sat_count, max_sat_display, max_sat_count);
   if(sat_count > max_sat_display) {
      sat_count = max_sat_display;
      have_count = 30;
   }

   if(sat_count > max_sat_count) {
      max_sat_count = sat_count;
      last_ebolt = (-1);
      saw_ebolt();  // !!!! we should do this better  zzzzz
   }

   config_sat_rows();
}

// Assembly:
leaq 0x1d21be(%rip), %rax    # 0x228f58
cmpl $0x0, (%rax)
je 0x56da0
retq
leaq 0x1d21fd(%rip), %rax    # 0x228fa4
movl (%rax), %eax
cmpl %edi, %eax
jge 0x56dbc
leaq 0x2a0564(%rip), %rcx    # 0x2f7318
movl $0x1e, (%rcx)
movl %eax, %edi
leaq 0x29f9bd(%rip), %rax    # 0x2f6780
cmpl (%rax), %edi
jle 0x56d3f
pushq %rbp
movq %rsp, %rbp
movl %edi, (%rax)
leaq 0x1d2150(%rip), %rax    # 0x228f28
orl $-0x1, (%rax)
callq 0x56b98
popq %rbp
jmp 0x56d3f
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: star_sat_sec()
int star_sat_sec()
{
   // The Star receivers use two messages to get the sat info.  We don't want
   // to update the sat count plot during the period between the two messages
   // or else we get spikes on the sat count plot.
   //
   // Returns true if time is such that the sat count info might be invalid
   if(rcvr_type != STAR_RCVR) return 0;

   if(star_msg && star_line) {  // don't update sat table during faked seconds
      return 1;  // ... otherwise you get spikes on the sat count plot
   }

   // piss3
   if(pri_seconds == (SCPI_STATUS_SECOND+0)) {  // don't update sat table during sat info retreival
      return 1;  // ... otherwise you get spikes on the sat count plot
   }
   if(pri_seconds == (SCPI_STATUS_SECOND+1)) {  // don't update sat table during sat info retreival
      return 1;  // ... otherwise you get spikes on the sat count plot
   }
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x1abadf(%rip), %rcx    # 0x2028d0
xorl %eax, %eax
cmpq $0x1000, (%rcx)         # imm = 0x1000
jne 0x56e2f
leaq 0x1ae1f9(%rip), %rax    # 0x204ffc
cmpl $0x0, (%rax)
je 0x56e1b
leaq 0x1ae1e9(%rip), %rax    # 0x204ff8
cmpl $0x0, (%rax)
je 0x56e1b
movl $0x1, %eax
jmp 0x56e2f
leaq 0x2a06de(%rip), %rax    # 0x2f7500
movl (%rax), %ecx
andl $-0x2, %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
sete %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: find_sat_changes()
void find_sat_changes()
{
int prn, j;
int sats_changed;

   // see if the satellite constellation has changed
   // Also converts sat_count from number of visible sats to tracked sats.

   for(prn=1; prn<=MAX_PRN; prn++) {  // save old tracking list
      last_const[prn] = this_const[prn];
      this_const[prn] = 0;
   }

   j = 0;
   sat_count = track_count = vis_count = 0;
   sats_changed = 0;
   for(prn=1; prn<=MAX_PRN; prn++) { 
      if(sat[prn].level_msg == 0x00) continue;
//    if(++j > max_sats) break;

      if(sat[prn].tracking > 0) {
         this_const[prn] = 1;
         if(last_const[prn] != this_const[prn]) ++sats_changed;
         ++sat_count;
         ++track_count;
         ++vis_count;
         have_count = 100;
      }
      else if(sat[prn].tracking < 0) {
         ++track_count;
      }
   }
   if(lte_lite && (have_sawtooth == 0)) sat_count = jackson_sat_count;

   if(sats_changed) {
      if(sat_count > SAT_COUNT_MASK) new_const = (SAT_COUNT_MASK | CONST_CHANGE);
      else                           new_const = (sat_count | CONST_CHANGE);
   }
}

// Assembly:
movabsq $0x1, %rdx
leaq 0x3036de(%rip), %rax    # 0x35a520
leaq 0x303ac7(%rip), %rcx    # 0x35a910
cmpq $0x3e8, %rdx            # imm = 0x3E8
je 0x56e63
movb (%rdx,%rax), %sil
movb %sil, (%rdx,%rcx)
movb $0x0, (%rdx,%rax)
incq %rdx
jmp 0x56e49
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x1d208f(%rip), %r8     # 0x228f04
andl $0x0, (%r8)
leaq 0x1d2080(%rip), %r9     # 0x228f00
andl $0x0, (%r9)
leaq 0x1d2081(%rip), %rdx    # 0x228f0c
andl $0x0, (%rdx)
movl $0x364, %r10d           # imm = 0x364
addq 0xe30ad(%rip), %r10     # 0x139f48
xorl %r11d, %r11d
movabsq $0x1, %rbx
leaq 0x2a0469(%rip), %r14    # 0x2f7318
xorl %esi, %esi
xorl %r15d, %r15d
xorl %edi, %edi
cmpq $0x3e8, %rbx            # imm = 0x3E8
je 0x56f0e
cmpl $0x0, (%r10)
je 0x56f02
cmpl $0x0, 0x1fc(%r10)
jle 0x56efa
movb $0x1, (%rbx,%rax)
xorl %r12d, %r12d
cmpb $0x1, (%rbx,%rcx)
setne %r12b
addl %r12d, %edi
incl %esi
movl %esi, (%rdx)
incl %r15d
movl %r15d, (%r9)
incl %r11d
movl %r11d, (%r8)
movl $0x64, (%r14)
jmp 0x56f02
jns 0x56f02
incl %r15d
movl %r15d, (%r9)
incq %rbx
addq $0x348, %r10            # imm = 0x348
jmp 0x56eb6
leaq 0x1ae0bb(%rip), %rax    # 0x204fd0
cmpl $0x0, (%rax)
je 0x56f31
leaq 0x2a04a3(%rip), %rax    # 0x2f73c4
cmpl $0x0, (%rax)
jne 0x56f31
leaq 0x1d1fe3(%rip), %rax    # 0x228f10
movl (%rax), %esi
movl %esi, (%rdx)
testl %edi, %edi
je 0x56f53
movl %esi, %eax
orl $0x800, %eax            # imm = 0x800
cmpl $0x100, %esi            # imm = 0x100
movl $0x8ff, %ecx            # imm = 0x8FF
cmovll %eax, %ecx
leaq 0x1d1ff7(%rip), %rax    # 0x228f48
movl %ecx, (%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: fmt_fp(int, int, int, int)
void fmt_fp(int v1,int v2,int v3,int v4)
{
unsigned char v[4];

   // debug routine for show showing four integers as a floating point value

   v[3] = v1;
   v[2] = v2;
   v[1] = v3;
   v[0] = v4;
   sprintf(plot_title, "%02X:%02X:%02X:%02X -> %f", v1,v2,v3,v4, *((float *) (void *) &v));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %ecx, %r9d
movl %edx, %r8d
movl %esi, %ecx
movl %edi, %eax
shll $0x18, %eax
movl $0xff, %edx
andl %edx, %esi
shll $0x10, %esi
orl %eax, %esi
movl %r8d, %eax
shll $0x8, %eax
movzwl %ax, %eax
orl %esi, %eax
andl %r9d, %edx
orl %eax, %edx
movd %edx, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2d18b8(%rip), %rax    # 0x328850
leaq 0xb33b4(%rip), %rsi     # 0x10a353
movl %edi, %edx
movq %rax, %rdi
movb $0x1, %al
popq %rbp
jmp 0x9060
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: calc_msg_ofs()
void calc_msg_ofs()
{
double rcvr_jd;

   rcvr_jd = jd_utc;
   rcvr_jd *= (24.0*60.0*60.0*1000.0);  // convert Julian to milliseconds

   get_clock_time();   // the system clock time when the message arrived
   clk_jd *= (24.0*60.0*60.0*1000.0);
   if(1 || !fake_time_stamp) {
      msg_ofs = clk_jd - rcvr_jd;  // ffff offset from message time to time the message arrived
   }

   if(measure_jitter) {   // rrrrrr
      sprintf(plot_title, "rcvr-clock %d: %f  rcvr:%f  clk:%f  /tsx=%f", fake_time_stamp,msg_ofs, fmod(rcvr_jd,10000.0), fmod(clk_jd,10000.0), time_sync_offset);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x2a0572(%rip), %rax    # 0x2f7530
movsd (%rax), %xmm0
mulsd 0xb1246(%rip), %xmm0    # 0x108210
movsd %xmm0, -0x18(%rbp)
callq 0xa386
movsd -0x18(%rbp), %xmm0
leaq 0x2a0700(%rip), %r14    # 0x2f76e0
movsd 0xb1228(%rip), %xmm1    # 0x108210
mulsd (%r14), %xmm1
movsd %xmm1, (%r14)
subsd %xmm0, %xmm1
leaq 0x2a0ed3(%rip), %rax    # 0x2f7ed0
movsd %xmm1, -0x20(%rbp)
movsd %xmm1, (%rax)
leaq 0x1cfcbb(%rip), %rax    # 0x226cc8
cmpl $0x0, (%rax)
je 0x57076
leaq 0x2a06d7(%rip), %rax    # 0x2f76f0
movl (%rax), %ebx
movsd 0x9c0b5(%rip), %xmm1    # 0xf30d8
callq 0x94d0
movsd %xmm0, -0x18(%rbp)
movsd (%r14), %xmm0
movsd 0x9c09e(%rip), %xmm1    # 0xf30d8
callq 0x94d0
movaps %xmm0, %xmm2
leaq 0x2a0e7f(%rip), %rax    # 0x2f7ec8
movsd (%rax), %xmm3
leaq 0x2d17fc(%rip), %rdi    # 0x328850
leaq 0xb3312(%rip), %rsi     # 0x10a36d
movl %ebx, %edx
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movb $0x4, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9060
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_tsip_start(unsigned char)
void send_tsip_start(u08 id)
{
   if(log_file && (log_stream & LOG_PACKET_START)) {
      fprintf(log_file, "\nSend tsip start %02X\n", id);
   }
// if(log_file && (log_stream & LOG_SENT_DATA)) fprintf(log_file, "send start: %02X\n", id); //wax 
   sts = 1;

   sendout(RCVR_PORT, DLE, ADD_CHAR);
   nvs_tx_crc = 0;
   send_byte(id);
   tsip_send_count = 2;

   if(id == 0x8E) superpacket = id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %eax
leaq 0x1d12d2(%rip), %rcx    # 0x228360
movq (%rcx), %rdi
movzbl %al, %ebx
testq %rdi, %rdi
je 0x570b5
leaq 0x1d1370(%rip), %rax    # 0x228410
testb $0x4, (%rax)
je 0x570b5
leaq 0xb32ed(%rip), %rsi     # 0x10a399
movl %ebx, %edx
xorl %eax, %eax
callq 0x9560
movl $0x1, 0x302f55(%rip)    # 0x35a014
pushq $0xa
popq %rdi
pushq $0x10
popq %rsi
xorl %edx, %edx
callq 0xba3b
andw $0x0, 0x2ffa30(%rip)    # 0x356b04
movl %ebx, %edi
callq 0x523f2
movl $0x2, 0x2fed33(%rip)    # 0x355e18
cmpb $-0x72, %bl
jne 0x570f1
movb $-0x72, 0x302f1f(%rip)  # 0x35a010
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_tsip_end()
void send_tsip_end()
{
   if(log_file && (log_stream & LOG_SENT_DATA)) fprintf(log_file, "tsip end\n"); //wax 
   sendout(RCVR_PORT, DLE, ADD_CHAR);
   sendout(RCVR_PORT, ETX, EOM);  // sending last byte of a TSIP message
   tsip_send_count += 2;
   if(sim_file == 0) Sleep(20); 

   sts = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x1d125b(%rip), %rax    # 0x228360
movq (%rax), %rcx
testq %rcx, %rcx
je 0x5712b
leaq 0x1d12fc(%rip), %rax    # 0x228410
testb $0x10, (%rax)
je 0x5712b
leaq 0xb3290(%rip), %rdi     # 0x10a3b0
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
callq 0x9750
pushq $0xa
popq %rbx
pushq $0x10
popq %rsi
movl %ebx, %edi
xorl %edx, %edx
callq 0xba3b
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
movl %ebx, %edi
callq 0xba3b
addl $0x2, 0x2fecca(%rip)    # 0x355e18
leaq 0x1d126b(%rip), %rax    # 0x2283c0
cmpq $0x0, (%rax)
jne 0x57163
pushq $0x14
popq %rdi
callq 0xae83
andl $0x0, 0x302eaa(%rip)    # 0x35a014
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_nvs_end()
void send_nvs_end()
{
u16 crc;

if(1) {  // send CRC
   crc = nvs_tx_crc;
   sendout(RCVR_PORT, DLE, ADD_CHAR);
   sendout(RCVR_PORT, 0xFF, ADD_CHAR);
   sendout(RCVR_PORT, crc & 0xFF, ADD_CHAR);
   sendout(RCVR_PORT, (crc/256) & 0xFF, ADD_CHAR);
}

   sendout(RCVR_PORT, DLE, ADD_CHAR);
   sendout(RCVR_PORT, ETX, EOM);  // sending last byte of a TSIP message to an NVS receiver
   tsip_send_count += 2;
   if(sim_file == 0) Sleep(50);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movzwl 0x2ff981(%rip), %r15d   # 0x356b04
pushq $0xa
popq %rbx
pushq $0x10
popq %r14
movl %ebx, %edi
movl %r14d, %esi
xorl %edx, %edx
callq 0xba3b
movl %ebx, %edi
movl $0xff, %esi
xorl %edx, %edx
callq 0xba3b
movzbl %r15b, %esi
movl %ebx, %edi
xorl %edx, %edx
callq 0xba3b
shrl $0x8, %r15d
movl %ebx, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0xba3b
movl %ebx, %edi
movl %r14d, %esi
xorl %edx, %edx
callq 0xba3b
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
movl %ebx, %edi
callq 0xba3b
addl $0x2, 0x2fec37(%rip)    # 0x355e18
leaq 0x1d11d8(%rip), %rax    # 0x2283c0
cmpq $0x0, (%rax)
je 0x571f9
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x32
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xae83
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_ascii_string(char*, int)
void send_ascii_string(char *s, int add_crlf)
{
   if(s) {
      send_nmea_string(s, 0);
   }

   if(add_crlf) {
      send_byte(0x0D);
      eom_flag = EOM;
      send_byte(0x0A);
      eom_flag = ADD_CHAR;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
testq %rdi, %rdi
je 0x5721f
xorl %esi, %esi
callq 0x5724b
testl %ebx, %ebx
je 0x57244
pushq $0xd
popq %rdi
callq 0x523f2
movl $0x1, 0x2febdb(%rip)    # 0x355e10
pushq $0xa
popq %rdi
callq 0x523f2
andl $0x0, 0x2febcc(%rip)    # 0x355e10
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_nmea_string(char*, int)
void send_nmea_string(char *s, int comma)
{
int i, j;

   if(s == 0) return;

   j = strlen(s);
   for(i=0; i<j; i++) send_byte((u08) s[i]);

   if(comma) send_byte((u08) ',');
}

// Assembly:
testq %rdi, %rdi
je 0x5729a
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
callq 0x9120
movq %rax, %r15
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
cmpq %r12, %r15
je 0x57286
movzbl (%r14,%r12), %edi
callq 0x523f2
incq %r12
jmp 0x57272
testl %ebx, %ebx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
je 0x5729a
pushq $0x2c
popq %rdi
jmp 0x523f2
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_acron_cmd(char*)
void send_acron_cmd(char *s)
{
int i, j;

   if(s == 0) return;
   
   j = strlen(s);
   if(j) this_acron_cmd = toupper(s[j-1]);
   else  this_acron_cmd = 0;
//if(debug_file) fprintf(debug_file, "send acron cmd:[%s]  len:%d  cmd:%c\n", s, j, this_acron_cmd);

   for(i=0; i<j; i++) {
      send_acron_byte((u08) s[i]);
   }

   send_acron_byte((u08) 0x0D);

//if(debug_file) fprintf(debug_file, "this_acron_cmd: %c\n", this_acron_cmd);

   if(FAKE_ACRON_RCVR) {
      if(this_acron_cmd == 'O') {
         get_clock_time();   // get system clock time in UTC
         sprintf(out, "%02d%02d%02d6%02d%02d%02d47\r", clk_hours,clk_minutes,clk_seconds,
         clk_day,clk_month,clk_year-2000);
         strcpy((char *) &com[RCVR_PORT].rcv_buffer[0], (char *) out);
         com[RCVR_PORT].next_rcv_byte = 0;
         com[RCVR_PORT].rcv_byte_count = 16;
      }
      else if(this_acron_cmd == 'G') {
         sprintf(out, "1%c\r", '0'+(pri_minutes%6));
         strcpy((char *) &com[RCVR_PORT].rcv_buffer[0], (char *) out);
         com[RCVR_PORT].next_rcv_byte = 0;
         com[RCVR_PORT].rcv_byte_count = 3;
      }
      else if(this_acron_cmd == 'H') {  // receiver sync request
      }
   }
}

// Assembly:
testq %rdi, %rdi
je 0x5769a
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x9120
movq %rax, %r14
xorl %r15d, %r15d
testl %r14d, %r14d
je 0x5769b
movl %r14d, %eax
decl %eax
cltq
movsbl (%rbx,%rax), %edi
callq 0x9700
jmp 0x5769d
retq
xorl %eax, %eax
movb %al, 0x2ff589(%rip)     # 0x356c2c
testl %r14d, %r14d
movl $0x0, %r12d
cmovgl %r14d, %r12d
cmpq %r15, %r12
je 0x576c4
movzbl (%rbx,%r15), %edi
callq 0x966f0
incq %r15
jmp 0x576b0
pushq $0xd
popq %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x966f0
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: queue_polled_cmd(char*, int)
void queue_polled_cmd(char *s, int id)
{
static int last_id = 0;

   // add a command to a queue of messages to send to the receiver.  SCPI 
   // receivers are REALLY dumb and not designed for talking to computer
   // programs.  Their responses to messages have NO indication of what
   // request the response is from.  If responses get out of sync with
   // requests, you a SCREWED!
   if((id == STAR_CONF_MSG) && (last_id == STAR_CONF_MSG)) {
      return;
   }
   last_id = id;
   brandy_msg_id = id;

   strcpy(polled_q[polled_q_in].msg, s);
   polled_q[polled_q_in].id = id;
   ++polled_q_entries;
   if(++polled_q_in >= POLLED_Q_SIZE) polled_q_in = 0;

if(debug_file) fprintf(debug_file,   "\nQ SCPI id:%d  sqe:%d  in:%d out:%d: %s\n", id, polled_q_entries, polled_q_in,polled_q_out, s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
cmpl $0xca, %esi
jne 0x576ff
cmpl $0xca, 0x3047df(%rip)   # 0x35bed8
je 0x57782
movl %ebx, 0x3047d3(%rip)    # 0x35bed8
movl %ebx, 0x304781(%rip)    # 0x35be8c
movslq 0x3028be(%rip), %r15    # 0x359fd0
imulq $0x84, %r15, %r12
leaq 0x2ff520(%rip), %r13    # 0x356c40
leaq (%r12,%r13), %rdi
movq %r14, %rsi
callq 0x9330
movl %ebx, 0x80(%r12,%r13)
movl 0x30289e(%rip), %ecx    # 0x359fd8
incl %ecx
leal 0x1(%r15), %eax
xorl %r8d, %r8d
cmpq $0x63, %r15
movl %ecx, 0x30288b(%rip)    # 0x359fd8
cmovll %eax, %r8d
movl %r8d, 0x302878(%rip)    # 0x359fd0
leaq 0x1d0c31(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57782
movl 0x302866(%rip), %r9d    # 0x359fd4
movq %r14, (%rsp)
leaq 0xb7aa0(%rip), %rsi     # 0x10f219
movl %ebx, %edx
xorl %eax, %eax
callq 0x9560
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_esip_cmd(char*)
void send_esip_cmd(char *s)
{
int p;

   if(s == 0) return;

   if(debug_file) fprintf(debug_file, "Sent eSIP:%s\n", s);

   send_nmea_start();
   if(s[0] == '$')    send_nmea_string(&s[1], 0);
   else               send_nmea_string(&s[0], 0);
   if(strchr(s, '*')) send_nmea_end(0);
   else               send_nmea_end(1);

   if(ESIP_SLEEP) Sleep(ESIP_SLEEP);

   s = strstr(s, "PERDCFG,UART1");  // baud rate change command was just sent
   if(s) {  // adjust com port setting
      Sleep(1000);
      s += 14;   // skip over the command and get the baud rate
      p = atoi(s);

      if     (p == 4800) ;
      else if(p == 9600) ;
      else if(p == 19200) ;
      else if(p == 38400) ;
      else if(p == 57600) ;
      else if(p == 115200) ;
      else if(p == 230400) ;
      else p = 0;
      if(p) {
         have_doppler = 0;
         have_range = 0;
         com[RCVR_PORT].baud_rate = p;
         init_com(RCVR_PORT, 100);
         Sleep(800);
         need_redraw = 9600;
         init_receiver(9600, 0);   // setup the receiver
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x578ce
movq %rdi, %rbx
leaq 0x1d0be6(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x577c3
leaq 0xb2cf0(%rip), %rsi     # 0x10a4a9
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
callq 0x57d18
xorl %edi, %edi
cmpb $0x24, (%rbx)
sete %dil
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
pushq $0x2a
popq %rsi
movq %rbx, %rdi
callq 0x9100
xorl %edi, %edi
testq %rax, %rax
sete %dil
callq 0x57d32
leaq 0xb2cbc(%rip), %rsi     # 0x10a4b7
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x578ce
movq %rax, %rbx
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xae83
addq $0xe, %rbx
movq %rbx, %rdi
callq 0x95e0
cmpl $0x12c0, %eax           # imm = 0x12C0
setne %cl
cmpl $0x2580, %eax           # imm = 0x2580
setne %dil
cmpl $0x4b00, %eax           # imm = 0x4B00
setne %r8b
cmpl $0x9600, %eax           # imm = 0x9600
setne %dl
cmpl $0xe100, %eax           # imm = 0xE100
setne %r9b
cmpl $0x1c200, %eax          # imm = 0x1C200
setne %r10b
cmpl $0x38400, %eax          # imm = 0x38400
setne %sil
testl %eax, %eax
je 0x578ce
andb %dil, %cl
andb %r8b, %dl
andb %cl, %dl
andb %r9b, %r10b
andb %r10b, %sil
andb %dl, %sil
jne 0x578ce
leaq 0x29fac0(%rip), %rcx    # 0x2f7340
andl $0x0, (%rcx)
leaq 0x29fabe(%rip), %rcx    # 0x2f7348
andl $0x0, (%rcx)
leaq 0x2a0a4c(%rip), %rcx    # 0x2f82e0
movl %eax, 0x159d0(%rcx)
pushq $0xa
popq %rdi
pushq $0x64
popq %rsi
callq 0xb30a
movl $0x320, %edi            # imm = 0x320
callq 0xae83
leaq 0x1aaf8e(%rip), %rax    # 0x202844
movl $0x2580, (%rax)         # imm = 0x2580
movl $0x2580, %edi           # imm = 0x2580
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5839e
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_furuno_cmd(char*)
void send_furuno_cmd(char *s)
{
   if(s == 0) return;


   send_nmea_start();
   if(strstr(s, "PFEC") || (strstr(s, "pfec"))) {
      if(s[0] == '$') {
         if(debug_file) fprintf(debug_file, "Sent1 furuno:$%s\n", &s[1]);
         send_nmea_string(&s[1], 0);
      }
      else {
         if(debug_file) fprintf(debug_file, "Sent2 furuno:$%s\n", &s[0]);
         send_nmea_string(&s[0], 0);
      }
   }
   else {
      if(s[0] == '$') {
         if(debug_file) fprintf(debug_file, "Sent3 furuno:%s\n", &s[0]);
         send_nmea_string(&s[1], 0);
      }
      else {
         if(debug_file) fprintf(debug_file, "Sent furuno:$PFEC,%s\n", &s[0]);
         send_nmea_string("PFEC,", 0);
         send_nmea_string(&s[0], 0);
      }
   }

send_nmea_end(0);  // !!!!! don't send checksums
return;
   if(strchr(s, '*')) send_nmea_end(0);
   else               send_nmea_end(1);
}

// Assembly:
testq %rdi, %rdi
je 0x5793b
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x57d18
leaq 0xbd0f8(%rip), %rsi     # 0x1149e7
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x57910
leaq 0xb2bc2(%rip), %rsi     # 0x10a4c5
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
je 0x57954
cmpb $0x24, (%rbx)
leaq 0x1d0a76(%rip), %rax    # 0x228390
movq (%rax), %rdi
jne 0x5793c
testq %rdi, %rdi
je 0x57936
leaq 0x1(%rbx), %rdx
leaq 0xb2b9b(%rip), %rsi     # 0x10a4ca
xorl %eax, %eax
callq 0x9560
incq %rbx
jmp 0x57998
retq
testq %rdi, %rdi
je 0x57998
leaq 0xb2b94(%rip), %rsi     # 0x10a4dc
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
jmp 0x57998
cmpb $0x24, (%rbx)
leaq 0x1d0a32(%rip), %rax    # 0x228390
movq (%rax), %rdi
jne 0x57974
testq %rdi, %rdi
je 0x57936
leaq 0xb2b7f(%rip), %rsi     # 0x10a4ee
movq %rbx, %rdx
jmp 0x5792f
testq %rdi, %rdi
je 0x5798a
leaq 0xb2b7f(%rip), %rsi     # 0x10a4ff
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
leaq 0xb2b84(%rip), %rdi     # 0x10a515
xorl %esi, %esi
callq 0x5724b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57d32
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_nmea_cmd(char*)
void send_nmea_cmd(char *s)
{
   if(s == 0) return;

   if(log_file && (log_stream & LOG_PACKET_START)) {
      fprintf(log_file, "\nSend nmea cmd: %s\n", s);
   }

   send_nmea_start();
   if(s[0] == '$')    send_nmea_string(&s[1], 0);
   else               send_nmea_string(&s[0], 0);
   if(strchr(s, '*')) send_nmea_end(0);
   else               send_nmea_end(1);
}

// Assembly:
testq %rdi, %rdi
je 0x57a20
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1d099c(%rip), %rax    # 0x228360
movq (%rax), %rdi
testq %rdi, %rdi
je 0x579e9
leaq 0x1d0a3d(%rip), %rax    # 0x228410
testb $0x4, (%rax)
je 0x579e9
leaq 0xb2a50(%rip), %rsi     # 0x10a42f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
callq 0x57d18
xorl %edi, %edi
cmpb $0x24, (%rbx)
sete %dil
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
pushq $0x2a
popq %rsi
movq %rbx, %rdi
callq 0x9100
xorl %edi, %edi
testq %rax, %rax
sete %dil
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x57d32
retq
// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: send_tm4_cmd(char*)
void send_tm4_cmd(char *s)
{
   // Spectrum TM4

   if(s == 0) return;

   if(log_file && (log_stream & LOG_PACKET_START)) {
      fprintf(log_file, "\nSend TM4 cmd: %s\n", s);
   }
if(debug_file) fprintf(debug_file, "\nSend TM4 cmd: %s\n", s);

   sendout(RCVR_PORT, '#', ADD_CHAR);
   if(s[0] == '#')    send_nmea_string(&s[1], 0);
   else               send_nmea_string(&s[0], 0);
   sendout(RCVR_PORT, 0x0D, ADD_CHAR);
   sendout(RCVR_PORT, 0x0A, EOM);

   if(TM4_SLEEP) Sleep(TM4_SLEEP);
}

// Assembly:
testq %rdi, %rdi
je 0x57acb
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x1d0925(%rip), %rax    # 0x228360
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57a60
leaq 0x1d09c6(%rip), %rax    # 0x228410
testb $0x4, (%rax)
je 0x57a60
leaq 0xb2a00(%rip), %rsi     # 0x10a456
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
leaq 0x1d0929(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57a80
leaq 0xb29e0(%rip), %rsi     # 0x10a456
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9560
pushq $0xa
popq %r14
pushq $0x23
popq %rsi
movl %r14d, %edi
xorl %edx, %edx
callq 0xba3b
xorl %edi, %edi
cmpb $0x23, (%rbx)
sete %dil
addq %rbx, %rdi
xorl %esi, %esi
callq 0x5724b
pushq $0xd
popq %rsi
movl %r14d, %edi
xorl %edx, %edx
callq 0xba3b
pushq $0x1
popq %rdx
movl %r14d, %edi
movl %r14d, %esi
callq 0xba3b
pushq $0x32
popq %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xae83
retq