// File: /workspace/github_cpp_makefile_star2_O1/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
je 0x2047e
leaq 0x31f967(%rip), %rdi    # 0x33fde0
callq 0x9340
movq (%rbx), %rsi
leaq 0xeb0cf(%rip), %rdi     # 0x10b557
xorl %eax, %eax
callq 0x9030
movl %r14d, %edi
movq %rbx, %rsi
callq 0x200d2
cmpl $0x0, 0x1f834b(%rip)    # 0x2187ec
je 0x204c9
cmpl $0x0, 0x2ed3f6(%rip)    # 0x30d8a0
sete %al
cmpb $0x0, 0x2ed3e0(%rip)    # 0x30d894
sete %cl
andb %al, %cl
movzbl %cl, %eax
leal 0xb(,%rax,4), %eax
movl %eax, 0x20310b(%rip)    # 0x2235d4
cmpb $0x0, 0x21ea6e(%rip)    # 0x23ef3e
je 0x204d7
callq 0x49e7c
testl $0x400904, 0x1f83ef(%rip) # imm = 0x400904
setne 0x1f82ec(%rip)          # 0x2187d4
callq 0x10c1e
callq 0x1ca74
callq 0xbe66
movl $0x1, 0x1fab33(%rip)    # 0x21b034
callq 0xd1865
movq 0x21dea3(%rip), %rdi    # 0x23e3b0
testq %rdi, %rdi
je 0x2052e
callq 0x9370
movq $0x0, 0x21de8e(%rip) # 0x23e3b0
leaq 0xea80e(%rip), %rdi     # 0x10ad37
callq 0x1cf23
cmpl $0x0, 0x21ea1b(%rip)    # 0x23ef50
jne 0x207d3
callq 0x20270
callq 0xd9e8
cmpb $0x0, 0x21deb0(%rip)    # 0x23e3fc
je 0x20575
movq 0x1fae53(%rip), %rax    # 0x21b3a8
incq %rax
movq %rax, 0x21dea1(%rip)    # 0x23e400
movq 0x21ddf2(%rip), %rdi    # 0x23e358
callq 0xc327f
movl $0x0, 0x21de77(%rip)    # 0x23e3ec
cmpb $0x0, 0x21de6c(%rip)    # 0x23e3e8
je 0x205ce
movb $0x0, 0x21de63(%rip)    # 0x23e3e8
movq 0x21de04(%rip), %rdi    # 0x23e390
testq %rdi, %rdi
je 0x20596
callq 0x9370
movq $0x0, 0x21ddef(%rip) # 0x23e390
movb $0x0, 0x21d4b8(%rip)    # 0x23da60
movabsq $0x6f6c2e6775626564, %rax # imm = 0x6F6C2E6775626564
movq %rax, 0x31bc67(%rip)    # 0x33c220
movw $0x67, 0x31bc66(%rip)   # 0x33c228
leaq 0x31bc57(%rip), %rdi    # 0x33c220
callq 0xa37b
cmpb $0x0, 0x21de14(%rip)    # 0x23e3e9
je 0x2061b
movb $0x0, 0x21de0b(%rip)    # 0x23e3e9
movq 0x21dd83(%rip), %rdi    # 0x23e368
testq %rdi, %rdi
je 0x205ef
callq 0x9370
movq $0x0, 0x21dd6e(%rip) # 0x23e368
movb $0x0, 0x21c95f(%rip)    # 0x23cf60
callq 0xa41c
cmpb $0x0, 0x31bc13(%rip)    # 0x33c220
je 0x2061b
leaq 0x31bc0a(%rip), %rdi    # 0x33c220
callq 0xa558
cmpb $0x0, 0x21ddc2(%rip)    # 0x23e3e4
je 0x20688
movb $0x0, 0x21ddb9(%rip)    # 0x23e3e4
movq 0x21dd3e(%rip), %rdi    # 0x23e370
testq %rdi, %rdi
je 0x2063c
callq 0x9370
movq $0x0, 0x21dd29(%rip) # 0x23e370
leaq 0x21ca12(%rip), %rbx    # 0x23d060
leaq 0xeaf10(%rip), %rsi     # 0x10b565
leaq 0xe93ee(%rip), %rdx     # 0x109a4a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe98f1(%rip), %rsi     # 0x109f5e
movq %rbx, %rdi
callq 0xa639
movq %rax, 0x21dcf4(%rip)    # 0x23e370
testq %rax, %rax
je 0x20688
orb $0x8, 0x21dd88(%rip)    # 0x23e410
cmpb $0x0, 0x21dd56(%rip)    # 0x23e3e5
je 0x206e9
movb $0x0, 0x21dd4d(%rip)    # 0x23e3e5
movq 0x21dcd9(%rip), %rdi    # 0x23e378
testq %rdi, %rdi
je 0x206a9
callq 0x9370
movq $0x0, 0x21dcc4(%rip) # 0x23e378
leaq 0x21caa5(%rip), %rbx    # 0x23d160
leaq 0xeaeaa(%rip), %rsi     # 0x10b56c
leaq 0xe9381(%rip), %rdx     # 0x109a4a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe9884(%rip), %rsi     # 0x109f5e
movq %rbx, %rdi
callq 0xa709
movq %rax, 0x21dc8f(%rip)    # 0x23e378
cmpb $0x0, 0x21dcf7(%rip)    # 0x23e3e7
je 0x2074a
movb $0x0, 0x21dcee(%rip)    # 0x23e3e7
movq 0x21dc88(%rip), %rdi    # 0x23e388
testq %rdi, %rdi
je 0x2070a
callq 0x9370
movq $0x0, 0x21dc73(%rip) # 0x23e388
leaq 0x21cb44(%rip), %rbx    # 0x23d260
leaq 0xeae42(%rip), %rsi     # 0x10b565
leaq 0xeae49(%rip), %rdx     # 0x10b573
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
leaq 0xe9823(%rip), %rsi     # 0x109f5e
movq %rbx, %rdi
callq 0x9a4d
movq %rax, 0x21dc3e(%rip)    # 0x23e388
cmpl $0x0, 0x1fa877(%rip)    # 0x21afc8
je 0x207b0
xorl %edi, %edi
callq 0x61d0f
cmpq $0x10000, 0x1f816b(%rip) # imm = 0x10000
jne 0x207b0
callq 0xd1865
movsd 0x2ecff4(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x30556c(%rip)   # 0x325ce8
xorl %ebx, %ebx
movb %bl, 0x30556c(%rip)     # 0x325cf0
movl $0x1513, %edi           # imm = 0x1513
callq 0xbe9d
callq 0xd1865
movsd 0x2ecfcd(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x305545(%rip)   # 0x325ce8
movb %bl, 0x305547(%rip)     # 0x325cf0
movb $0x3, 0x2ed6bd(%rip)    # 0x30de6d
cmpl $0x50, 0x1f8151(%rip)   # 0x218908
jne 0x20829
cmpq $0x10000, 0x1f810c(%rip) # imm = 0x10000
jne 0x207dd
xorps %xmm0, %xmm0
cvtsi2sdl 0x3034df(%rip), %xmm0 # 0x323cb0
jmp 0x207f1
movl $0x1, %edi
callq 0x1f9f3
callq 0x701f2
testl %eax, %eax
je 0x20829
xorps %xmm0, %xmm0
cvtsi2sdl 0x309bdf(%rip), %xmm0 # 0x32a3d0
divsd 0xe897f(%rip), %xmm0    # 0x109178
movsd %xmm0, 0x2ec1ef(%rip)   # 0x30c9f0
movsd 0x2ec1ef(%rip), %xmm1   # 0x30c9f8
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x20829
jp 0x20829
movsd 0xe8843(%rip), %xmm1    # 0x109060
divsd %xmm0, %xmm1
movsd %xmm1, 0x2ec1cf(%rip)   # 0x30c9f8
movq 0x1f80a0(%rip), %rax    # 0x2188d0
movabsq $0x105b8b0400, %rcx     # imm = 0x105B8B0400
testq %rcx, %rax
jne 0x20859
cmpl $0x0, 0x1fa78a(%rip)    # 0x21afd0
je 0x209d1
cmpl $0x0, 0x2ecb71(%rip)    # 0x30d3c4
jne 0x209d1
callq 0x202d4
callq 0x5f743
testl %eax, %eax
je 0x20871
movl $0x1, %edi
callq 0x39326
cmpl $0x0, 0x31dec0(%rip)    # 0x33e738
jne 0x208cd
movq 0x150407(%rip), %rsi    # 0x170c88
testq %rsi, %rsi
je 0x208d2
cmpb $0x0, (%rsi)
je 0x208d2
leaq 0x13d37e(%rip), %rdi    # 0x15dc10
callq 0x9340
movb 0x13d373(%rip), %al     # 0x15dc10
testb %al, %al
je 0x208bc
leaq 0x13d369(%rip), %rbx    # 0x15dc11
movsbl %al, %edi
callq 0x9700
movb %al, -0x1(%rbx)
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0x208a8
movb $0x0, 0x13d34d(%rip)    # 0x15dc10
movl $0x2, 0x31de6b(%rip)    # 0x33e738
callq 0xdea4
cmpq $0x10000, 0x1f7ff3(%rip) # imm = 0x10000
je 0x208e8
callq 0x701f2
testl %eax, %eax
je 0x208f2
movl $0x0, 0x21c442(%rip)    # 0x23cd34
callq 0x1817f
cmpb $0x0, 0x21e640(%rip)    # 0x23ef3e
je 0x2090a
movl $0x1, %edi
callq 0x7e40a
callq 0x727c3
callq 0xc1a24
callq 0x1ea6e
callq 0x1ec53
leaq 0x21cd3b(%rip), %rdi    # 0x23d660
movl $0x1, %esi
callq 0x234f0
cmpl $0x0, 0x21db02(%rip)    # 0x23e438
jne 0x20965
cmpl $0x0, 0x21e5f1(%rip)    # 0x23ef30
je 0x2096a
movl 0x2ed98d(%rip), %edi    # 0x30e2d4
callq 0x1f3ac
movq 0x1f7f7d(%rip), %rax    # 0x2188d0
cmpq $0x400, %rax            # imm = 0x400
je 0x209c5
cmpq $0x4000000, %rax        # imm = 0x4000000
je 0x209c5
jmp 0x2096a
callq 0x1f35a
callq 0xd1865
movsd 0x2ecdf1(%rip), %xmm0   # 0x30d768
movsd %xmm0, 0x305369(%rip)   # 0x325ce8
movb $0x0, 0x30536a(%rip)    # 0x325cf0
cmpl $0x0, 0x1faa33(%rip)    # 0x21b3c0
je 0x209ad
movl $0x76, %edi
callq 0xd4e7
movl $0x74, %edi
callq 0xd4e7
movl $0xd, %edi
callq 0xd4e7
cmpl $0x0, 0x1f7f2c(%rip)    # 0x2188e0
je 0x209c0
movl $0x1, %edi
callq 0x20bc4
callq 0x1fdfa
callq 0x1ecbb
xorl %edi, %edi
callq 0xdd23
cmpq $0x400000, %rax         # imm = 0x400000
sete %cl
cmpl $0x0, 0x2ecfd3(%rip)    # 0x30d9b4
sete %dl
cmpq $0x800000, %rax         # imm = 0x800000
je 0x20859
andb %dl, %cl
je 0x2085e
jmp 0x20859