// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: main
int main(int argc, char *argv[])
{
   #ifdef USE_X11
      if(argv[0]) strcpy(exe_name, argv[0]);
      printf("argv[0] (%s)\n", argv[0]);
   #endif

   config_program(argc, argv);  // process command line arguments

   if(1) ;
   else if(((rcvr_type == NO_RCVR) || (rcvr_type == TIDE_RCVR)) && (com[RCVR_PORT].process_com == 0)) {
      com[RCVR_PORT].process_com = 1;
      com[RCVR_PORT].user_disabled_com = 0;
   }

   #ifdef WIN_VFX
     get_screen_size(0);
     if(display_width == 1280) {
        vfx_full:
        if(vfx_fullscreen) {
           SAL_set_preference(SAL_MAXIMIZE_TO_FULLSCREEN, YES);
           initial_window_mode = VFX_TRY_FULLSCREEN;
        }
     }
     else if(display_width == 1024) goto vfx_full;
     else if(display_width == 800)  goto vfx_full;
     else if(display_width == 640)  goto vfx_full;
   #endif

   if(jpl_clock) {
      if(dst_ofs)            time_color = DST_TIME_COLOR;
      else if(time_zone_set) time_color = DST_TIME_COLOR;  // !!! std_time_color is rather dim for the big clock
      else                   time_color = WHITE;
   }

   if(luxor) {
      config_luxor_plots();
   }

   find_endian();     // determine machine byte ordering
   alloc_memory();    // allocate memory for plot and adev queues, etc
   adjust_view();     // tweak screen for user selected view interval, etc


   init_hardware();   // initialize the com port, screen, and any other hardware
   hw_setup = 1;
   update_pwm();

   if(temp_script) {  // heather.cfg created a temporary keyboard script file, process it
      fclose(temp_script);
      temp_script = 0;
      open_script(TEMP_SCRIPT);
   }

   if(take_a_dump) {
      dump_stream(1);
   }

   #ifdef PLM
      init_pl_timer();// setup to monitor power line freq
   #endif
   config_tz_info();  // try to get time zone info from the system
   config_options();  // configure system for command line options

   // user set a log param on the command line, start writing the log file
   if(user_set_log) {
      log_file_time = log_interval + 1;
      open_log_file(log_mode);
      rinex_header_written = 0;
   }

   if(need_debug_log) {
      need_debug_log = 0;
      if(debug_file) fclose(debug_file);
      debug_file = 0;
      debug_name[0] = 0;

      sprintf(out, "debug.log");
      open_debug_file(out);
   }

   if(need_rinex_file) {
      need_rinex_file = 0;
      if(rinex_file) fclose(rinex_file);
      rinex_file = 0;
      rinex_name[0] = 0;

      set_rinex_name();  // into string "out"
      if(out[0]) open_rinex_file(out);
   }

   if(need_raw_file) {  // open raw receiver log file specified on the command line
      need_raw_file = 0;
      if(raw_file) fclose(raw_file);
      raw_file = 0;
      sprintf(raw_name, "%s.raw", "heather");
      raw_file = open_raw_file(raw_name, "wb");
      if(raw_file) log_stream |= LOG_RAW_STREAM;
   }

   if(need_prn_file) {  // open raw receiver log file specified on the command line
      need_prn_file = 0;
      if(prn_file) fclose(prn_file);
      prn_file = 0;
      sprintf(prn_name, "%s.prn", "heather");
      prn_file = open_prn_file(prn_name, "wb");
   }

   if(need_ticc_file) {  // open ticc log file specified on the command line
      need_ticc_file = 0;
      if(ticc_file) fclose(ticc_file);
      ticc_file = 0;
      sprintf(ticc_name, "%s.raw", "ticc");
      ticc_file = topen(ticc_name, "wb");
// aaattt      if(raw_file) log_stream |= LOG_RAW_STREAM;
   }

   if(detect_rcvr_type) {
      auto_detect(0);
      if(rcvr_type == TICC_RCVR) {  // xyzzy  disable watch/azel/signals
         reset_com_timer(RCVR_PORT);
         init_screen(5395);
         reset_com_timer(RCVR_PORT);
not_safe = 3;
      }
   }

   if(ticc_type == PICPET_TICC) {  // scale PICPET wrap interval to 10 MHz clock equivalent
      if(rcvr_type == TICC_RCVR) {
         pet_clock = (double) com[RCVR_PORT].baud_rate / 19200.0;
         if(timestamp_wrap == 0.0) timestamp_wrap = 100.0 / pet_clock;
      }
      else if(ticc_port_open()) {
         pet_clock = (double) com[TICC_PORT].baud_rate / 19200.0;
         if(timestamp_wrap == 0.0) timestamp_wrap = 100.0 / pet_clock;
      }
   }

   if(NO_SATS || (rcvr_type == TIDE_RCVR)) {  // try to get default user position from file
      read_default_lla();
   }

   if(enviro_mode()) {
      config_enviro_plots(1);
   }

   if(user_set_title_bar) { // set title bar text
      set_title_bar(0);
   }
   else if(unit_file_name == 0) {
   }
   else if(unit_file_name[0]) {
      strcpy(szAppName, unit_file_name);
      strupr(szAppName);
szAppName[0] = 0;
      user_set_title_bar = 2;
      set_title_bar(2);
   }

   if(TICC_USED) no_adev_flag = 0;
   else if(0 && no_adev_flag) {
      free_mtie();
      free_adev_queues();

      adev_q_size = 0;
      // disable adevs... if you re-enable them you will need to use
      // the /j command to reset the adev period to a non-zero value!!!!!
      adev_q_size = 1L;
      adev_period = 0.0;
      pps_adev_period = adev_period;
      osc_adev_period = adev_period;
      chc_adev_period = adev_period;
      chd_adev_period = adev_period;
      save_adev_period();
   }

   plot_axes();         // draw graph axes
   if(luxor) reset_luxor_wdt(1);
   show_version_header();
   show_log_state();    // show logging state
   show_com_state();    // show com port state and flush buffer
   get_log_file();      // read in any initial log file
   read_rpn_file(rpn_name, 1);  // read in any calculator user defined functions

   if(monitor_mode) {
      set_monitor_mode(0); // port monitor
   }
   else if(enable_terminal) {
      do_term(term_port);  // debug terminal
      if(rcvr_type == NO_RCVR) goto exit_pgm;
      if(rcvr_type == TERM_RCVR) goto exit_pgm;
   }

   reset_com_timer(RCVR_PORT);

   if(need_view_auto) {     // force a VT auto view command
      add_kbd('v');
      add_kbd('t');
      add_kbd(0x0D);
   }

   if(calc_rcvr) {
      start_calc_zoom(1);
   }

   do_gps();            // run the receiver until something says stop

   exit_pgm:
   clean_up();          // leave the receiver in a nice stand-alone state
   shut_down(0);        // clean up remaining details and exit
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %r14d
movq (%rsi), %rsi
testq %rsi, %rsi
jne 0x20435
xorl %esi, %esi
jmp 0x20444
leaq 0x31f9a4(%rip), %rdi    # 0x33fde0
callq 0x9340
movq (%rbx), %rsi
leaq 0xeb119(%rip), %rdi     # 0x10b564
xorl %eax, %eax
callq 0x9030
movl %r14d, %edi
movq %rbx, %rsi
callq 0x2009c
cmpl $0x0, 0x1f8388(%rip)    # 0x2187ec
je 0x2048c
cmpl $0x0, 0x2ed433(%rip)    # 0x30d8a0
sete %al
cmpb $0x0, 0x2ed41d(%rip)    # 0x30d894
sete %cl
andb %al, %cl
movzbl %cl, %eax
leal 0xb(,%rax,4), %eax
movl %eax, 0x203148(%rip)    # 0x2235d4
cmpb $0x0, 0x21eaab(%rip)    # 0x23ef3e
je 0x2049a
callq 0x49ef2
testl $0x400904, 0x1f842c(%rip) # imm = 0x400904
setne 0x1f8329(%rip)          # 0x2187d4
callq 0x10b99
callq 0x1cab1
callq 0xbe51
movl $0x1, 0x1fab70(%rip)    # 0x21b034
callq 0xd1efe
movq 0x21dee0(%rip), %rdi    # 0x23e3b0
testq %rdi, %rdi
je 0x204f1
callq 0x9370
movq $0x0, 0x21decb(%rip) # 0x23e3b0
leaq 0xea85b(%rip), %rdi     # 0x10ad47
callq 0x1cf62
cmpl $0x0, 0x21ea58(%rip)    # 0x23ef50
jne 0x20796
callq 0x2022f
callq 0xd9c4
cmpb $0x0, 0x21deed(%rip)    # 0x23e3fc
je 0x20538
movq 0x1fae90(%rip), %rax    # 0x21b3a8
incq %rax
movq %rax, 0x21dede(%rip)    # 0x23e400
movq 0x21de2f(%rip), %rdi    # 0x23e358
callq 0xc385c
movl $0x0, 0x21deb4(%rip)    # 0x23e3ec
cmpb $0x0, 0x21dea9(%rip)    # 0x23e3e8
je 0x20591
movb $0x0, 0x21dea0(%rip)    # 0x23e3e8
movq 0x21de41(%rip), %rdi    # 0x23e390
testq %rdi, %rdi
je 0x20559
callq 0x9370
movq $0x0, 0x21de2c(%rip) # 0x23e390
movb $0x0, 0x21d4f5(%rip)    # 0x23da60
movabsq $0x6f6c2e6775626564, %rax # imm = 0x6F6C2E6775626564
movq %rax, 0x31bca4(%rip)    # 0x33c220
movw $0x67, 0x31bca3(%rip)   # 0x33c228
leaq 0x31bc94(%rip), %rdi    # 0x33c220
callq 0xa364
cmpb $0x0, 0x21de51(%rip)    # 0x23e3e9
je 0x205de
movb $0x0, 0x21de48(%rip)    # 0x23e3e9
movq 0x21ddc0(%rip), %rdi    # 0x23e368
testq %rdi, %rdi
je 0x205b2
callq 0x9370
movq $0x0, 0x21ddab(%rip) # 0x23e368
movb $0x0, 0x21c99c(%rip)    # 0x23cf60
callq 0xa3fe
cmpb $0x0, 0x31bc50(%rip)    # 0x33c220
je 0x205de
leaq 0x31bc47(%rip), %rdi    # 0x33c220
callq 0xa53a
cmpb $0x0, 0x21ddff(%rip)    # 0x23e3e4
je 0x2064b
movb $0x0, 0x21ddf6(%rip)    # 0x23e3e4
movq 0x21dd7b(%rip), %rdi    # 0x23e370
testq %rdi, %rdi
je 0x205ff
callq 0x9370
movq $0x0, 0x21dd66(%rip) # 0x23e370
leaq 0x21ca4f(%rip), %rbx    # 0x23d060
leaq 0xeaf5a(%rip), %rsi     # 0x10b572
leaq 0xe943b(%rip), %rdx     # 0x109a5a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe993e(%rip), %rsi     # 0x109f6e
movq %rbx, %rdi
callq 0xa61d
movq %rax, 0x21dd31(%rip)    # 0x23e370
testq %rax, %rax
je 0x2064b
orb $0x8, 0x21ddc5(%rip)    # 0x23e410
cmpb $0x0, 0x21dd93(%rip)    # 0x23e3e5
je 0x206ac
movb $0x0, 0x21dd8a(%rip)    # 0x23e3e5
movq 0x21dd16(%rip), %rdi    # 0x23e378
testq %rdi, %rdi
je 0x2066c
callq 0x9370
movq $0x0, 0x21dd01(%rip) # 0x23e378
leaq 0x21cae2(%rip), %rbx    # 0x23d160
leaq 0xeaef4(%rip), %rsi     # 0x10b579
leaq 0xe93ce(%rip), %rdx     # 0x109a5a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe98d1(%rip), %rsi     # 0x109f6e
movq %rbx, %rdi
callq 0xa6ed
movq %rax, 0x21dccc(%rip)    # 0x23e378
cmpb $0x0, 0x21dd34(%rip)    # 0x23e3e7
je 0x2070d
movb $0x0, 0x21dd2b(%rip)    # 0x23e3e7
movq 0x21dcc5(%rip), %rdi    # 0x23e388
testq %rdi, %rdi
je 0x206cd
callq 0x9370
movq $0x0, 0x21dcb0(%rip) # 0x23e388
leaq 0x21cb81(%rip), %rbx    # 0x23d260
leaq 0xeae8c(%rip), %rsi     # 0x10b572
leaq 0xeae93(%rip), %rdx     # 0x10b580
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe9870(%rip), %rsi     # 0x109f6e
movq %rbx, %rdi
callq 0x9a47
movq %rax, 0x21dc7b(%rip)    # 0x23e388
cmpl $0x0, 0x1fa8b4(%rip)    # 0x21afc8
je 0x20773
xorl %edi, %edi
callq 0x61d0d
cmpq $0x10000, 0x1f81a8(%rip) # imm = 0x10000
jne 0x20773
callq 0xd1efe
movsd 0x2ed031(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x3055a9(%rip)   # 0x325ce8
xorl %ebx, %ebx
movb %bl, 0x3055a9(%rip)     # 0x325cf0
movl $0x1513, %edi           # imm = 0x1513
callq 0xbe88
callq 0xd1efe
movsd 0x2ed00a(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x305582(%rip)   # 0x325ce8
movb %bl, 0x305584(%rip)     # 0x325cf0
movb $0x3, 0x2ed6fa(%rip)    # 0x30de6d
cmpl $0x50, 0x1f818e(%rip)   # 0x218908
jne 0x207ec
cmpq $0x10000, 0x1f8149(%rip) # imm = 0x10000
jne 0x207a0
xorps %xmm0, %xmm0
cvtsi2sdl 0x30351c(%rip), %xmm0 # 0x323cb0
jmp 0x207b4
movl $0x1, %edi
callq 0x1f9c3
callq 0x702e7
testl %eax, %eax
je 0x207ec
xorps %xmm0, %xmm0
cvtsi2sdl 0x309c1c(%rip), %xmm0 # 0x32a3d0
divsd 0xe89c4(%rip), %xmm0    # 0x109180
movsd %xmm0, 0x2ec22c(%rip)   # 0x30c9f0
movsd 0x2ec22c(%rip), %xmm1   # 0x30c9f8
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x207ec
jp 0x207ec
movsd 0xe8880(%rip), %xmm1    # 0x109060
divsd %xmm0, %xmm1
movsd %xmm1, 0x2ec20c(%rip)   # 0x30c9f8
movq 0x1f80dd(%rip), %rax    # 0x2188d0
movabsq $0x105b8b0400, %rcx     # imm = 0x105B8B0400
testq %rcx, %rax
jne 0x2081c
cmpl $0x0, 0x1fa7c7(%rip)    # 0x21afd0
je 0x20994
cmpl $0x0, 0x2ecbae(%rip)    # 0x30d3c4
jne 0x20994
callq 0x20293
callq 0x5f6cb
testl %eax, %eax
je 0x20834
movl $0x1, %edi
callq 0x393f6
cmpl $0x0, 0x31defd(%rip)    # 0x33e738
jne 0x20890
movq 0x150444(%rip), %rsi    # 0x170c88
testq %rsi, %rsi
je 0x20895
cmpb $0x0, (%rsi)
je 0x20895
leaq 0x13d3bb(%rip), %rdi    # 0x15dc10
callq 0x9340
movb 0x13d3b0(%rip), %al     # 0x15dc10
testb %al, %al
je 0x2087f
leaq 0x13d3a6(%rip), %rbx    # 0x15dc11
movsbl %al, %edi
callq 0x9700
movb %al, -0x1(%rbx)
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0x2086b
movb $0x0, 0x13d38a(%rip)    # 0x15dc10
movl $0x2, 0x31dea8(%rip)    # 0x33e738
callq 0xde80
cmpq $0x10000, 0x1f8030(%rip) # imm = 0x10000
je 0x208ab
callq 0x702e7
testl %eax, %eax
je 0x208b5
movl $0x0, 0x21c47f(%rip)    # 0x23cd34
callq 0x181bc
cmpb $0x0, 0x21e67d(%rip)    # 0x23ef3e
je 0x208cd
movl $0x1, %edi
callq 0x7e221
callq 0x72683
callq 0xc1ff4
callq 0x1ea4d
callq 0x1ec32
leaq 0x21cd78(%rip), %rdi    # 0x23d660
movl $0x1, %esi
callq 0x232b4
cmpl $0x0, 0x21db3f(%rip)    # 0x23e438
jne 0x20928
cmpl $0x0, 0x21e62e(%rip)    # 0x23ef30
je 0x2092d
movl 0x2ed9ca(%rip), %edi    # 0x30e2d4
callq 0x1f3a0
movq 0x1f7fba(%rip), %rax    # 0x2188d0
cmpq $0x400, %rax            # imm = 0x400
je 0x20988
cmpq $0x4000000, %rax        # imm = 0x4000000
je 0x20988
jmp 0x2092d
callq 0x1f34e
callq 0xd1efe
movsd 0x2ece2e(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x3053a6(%rip)   # 0x325ce8
movb $0x0, 0x3053a7(%rip)    # 0x325cf0
cmpl $0x0, 0x1faa70(%rip)    # 0x21b3c0
je 0x20970
movl $0x76, %edi
callq 0xd4c8
movl $0x74, %edi
callq 0xd4c8
movl $0xd, %edi
callq 0xd4c8
cmpl $0x0, 0x1f7f69(%rip)    # 0x2188e0
je 0x20983
movl $0x1, %edi
callq 0x20b8c
callq 0x1fdd4
callq 0x1ec9a
xorl %edi, %edi
callq 0xdcff
cmpq $0x400000, %rax         # imm = 0x400000
sete %cl
cmpl $0x0, 0x2ed010(%rip)    # 0x30d9b4
sete %dl
cmpq $0x800000, %rax         # imm = 0x800000
je 0x2081c
andb %dl, %cl
je 0x20821
jmp 0x2081c