// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: request_factory_reset()
void request_factory_reset()
{
   if(read_only) return;
   if(no_poll) return;

   reset_leap_flags();
   extend_com_timeout(0.0);

   if(luxor) {
      send_tsip_start(LUXOR_ID);   // erase EEPROM config
      send_byte(0x08);
      send_tsip_end();
      Sleep(100);

      request_cold_reset();
   }
   else if(rcvr_type == ACRON_RCVR) {
      need_acron_sync = 'h';
   }
   else if(rcvr_type == BRANDY_RCVR) {
      queue_brandy_cmd("$PRCCG,Z,0", BRANDY_RESET_MSG);
   }
   else if(rcvr_type == CS_RCVR) {
//    set_cs_remote(1);
      queue_cs_cmd("*RST", SCPI_NULL_MSG);
//    restore_cs_remote();

      queue_cs_cmd("DIAG:CONT:STAT?", CS_LAMP_MSG);
      queue_cs_cmd("DISP:ENAB?", CS_DISP_MSG);
      queue_cs_cmd("SYST:REM?", CS_REM_MSG);

      user_set_remote = 1;   // *RST forces remote mode
      cs_remote = 1;
   }
   else if(rcvr_type == ESIP_RCVR) {
      send_esip_cmd("PERDAPI,FLASHBACKUP,0x00");  // erase flash settings
      Sleep(2000);
      send_esip_cmd("PERDAPI,RESTART,FACTORY");
   }
   else if(rcvr_type == FURUNO_RCVR) {
      send_furuno_cmd("GPclr,1");
   }
   else if(rcvr_type == MOTO_RCVR) {
      send_moto_start("Cf");
      send_moto_end();
      rcvr_reset = 3;
//    restart_gpsdo();
//    Sleep(2000);
   }
   else if(rcvr_type == NVS_RCVR) {
      request_cold_reset();
   }
   else if(rcvr_type == PRS_RCVR) {
      queue_prs_cmd("RC1", PRS_RC_MSG);
   }
   else if(rcvr_type == RFTG_RCVR) {
      request_rftg_reset('H');
   }
   else if(rcvr_type == SCPI_RCVR) {
      if(scpi_type == NORTEL_TYPE) queue_scpi_cmd("SYST:PRESET", SCPI_RESET_MSG);
      else                         queue_scpi_cmd(":SYST:PRES", SCPI_RESET_MSG);
   }
   else if(rcvr_type == SRO_RCVR) {
      queue_sro_cmd("RESET", SRO_RESET_MSG);
   }
   else if(rcvr_type == SS_RCVR) {
      send_ss_start(2, 12);
      send_ss_string("UGPS-000");
      send_ss_end();
   }
   else if(rcvr_type == STAR_RCVR) {
      if(star_type == OSA_TYPE) queue_star_cmd("SET_DEFAULT", STAR_RESTART_MSG);
      else                      queue_star_cmd("RESTART(C);", STAR_RESTART_MSG);
   }
   else if(rcvr_type == TAIP_RCVR) {
      send_taip_cmd("SRTFACTORY");
   }
   else if(rcvr_type == TICC_RCVR) {
      set_ticc_config(RCVR_PORT, " X");   // reset config to factory defaults
Sleep(4000);
      get_ticc_config(RCVR_PORT);
   }
   else if(rcvr_type == TM4_RCVR) {
      send_tm4_cmd("#08,1");
   }
   else if(rcvr_type == TRUE_RCVR) {
      send_true_cmd("$FACT");    // factory reset unit
   }
   else if(rcvr_type == TSIP_RCVR) {
      send_tsip_start(0x1E);
      if(ACU_GG) send_byte('F');
      else if(ACU_360) send_byte('F');
      else if(ACUTIME) send_byte('F');
      else if(PALISADE) send_byte('F');
      else if(SV6_FAMILY) send_byte('K');
      else send_byte('F');
      send_tsip_end();
   }
   else if(rcvr_type == UBX_RCVR) {
      update_ubx_config(UBX_EE_ALL, 0x0000, UBX_EE_ALL);  // reset eeprom then re-load config from eeprom
      rcvr_reset = 4;
      Sleep(1000);
      init_messages(22, 1);
   }
   else if(rcvr_type == UCCM_RCVR) {
      queue_uccm_cmd("SYST:PRES", SCPI_RESET_MSG);
      queue_uccm_cmd("SYST:STAT?", UCCM_STATUS_MSG);
   }
   else if(rcvr_type == VENUS_RCVR) {
      send_venus_start(VENUS_FACTORY_RESET);
      send_byte(1);
      send_venus_end();
      Sleep(5000);
      init_messages(22, 1);
   }
   else if(rcvr_type == Z12_RCVR) {
      send_z12_cmd("PASHS,RST");
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      send_zod_start(ZOD_REQ_RESTART, 8, 0);
      send_zod_seq();
      send_word(0x8007);
      send_zod_end();

      Sleep(10000);
      restart_zodiac_rcvr();
   }
   else if(rcvr_type == ZYFER_RCVR) {
      send_zyfer_cmd("$FACTORYRESET");
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x2d221a(%rip), %rax    # 0x33701a
leaq 0x2d2219(%rip), %rcx    # 0x337020
movb (%rcx), %cl
orb (%rax), %cl
je 0x64e14
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2a83ce(%rip), %rax    # 0x30d1e9
movb $0x0, (%rax)
leaq 0x2a83bb(%rip), %rax    # 0x30d1e0
movl $0x0, (%rax)
leaq 0x2a83a6(%rip), %rax    # 0x30d1d8
andb $0x7f, (%rax)
xorps %xmm0, %xmm0
callq 0x63c5c
leaq 0x1da0fa(%rip), %rax    # 0x23ef3e
cmpb $0x0, (%rax)
je 0x64e77
movl $0xdc, %edi
callq 0x5e740
movl $0x8, %edi
callq 0x591af
callq 0x5e7c0
movl $0x64, %edi
callq 0xaff7
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x63f21
leaq 0x1b3a52(%rip), %rbx    # 0x2188d0
movq (%rbx), %rax
cmpq $0x1ffff, %rax          # imm = 0x1FFFF
jg 0x64edf
cmpq $0xff, %rax
jg 0x64f2d
cmpq $0xf, %rax
jg 0x64fd5
cmpq $0x1, %rax
je 0x651be
cmpq $0x4, %rax
je 0x65102
cmpq $0x8, %rax
jne 0x64e0d
leaq 0xbb89c(%rip), %rdi     # 0x120760
movl $0x14, %esi
callq 0x5ee52
leaq 0xbf1d9(%rip), %rdi     # 0x1240ae
movl $0x65, %esi
jmp 0x6535d
cmpq $0x7ffffff, %rax        # imm = 0x7FFFFFF
jg 0x64f79
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jg 0x6501d
cmpq $0x20000, %rax          # imm = 0x20000
je 0x65213
cmpq $0x40000, %rax          # imm = 0x40000
je 0x6513f
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x64e0d
leaq 0xbb87f(%rip), %rdi     # 0x1207a1
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f15d
cmpq $0x3fff, %rax           # imm = 0x3FFF
jg 0x65052
cmpq $0x100, %rax            # imm = 0x100
je 0x65273
cmpq $0x800, %rax            # imm = 0x800
je 0x64e6c
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x64e0d
leaq 0x1b6084(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x65351
leaq 0xbb7ff(%rip), %rdi     # 0x120773
jmp 0x65358
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jg 0x650a3
cmpq $0x8000000, %rax        # imm = 0x8000000
je 0x652b4
cmpq $0x20000000, %rax       # imm = 0x20000000
je 0x65150
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x64e0d
leaq 0xbb75f(%rip), %rdi     # 0x120713
callq 0x5ef13
movl $0x7d0, %edi            # imm = 0x7D0
callq 0xaff7
leaq 0xbb762(%rip), %rdi     # 0x12072c
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5ef13
cmpq $0x10, %rax
je 0x652c5
cmpq $0x20, %rax
je 0x65162
cmpq $0x80, %rax
jne 0x64e0d
movl $0x4, %edi
movl $0x2, %esi
callq 0x5fbb4
movl $0x1, %edi
callq 0x591af
callq 0x61bc3
movl $0x1388, %edi           # imm = 0x1388
jmp 0x65125
cmpq $0x200000, %rax         # imm = 0x200000
je 0x652da
cmpq $0x400000, %rax         # imm = 0x400000
je 0x65185
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x64e0d
leaq 0xbb707(%rip), %rdi     # 0x12074f
movl $0x1f4, %esi            # imm = 0x1F4
jmp 0x6535d
cmpq $0x4000, %rax           # imm = 0x4000
je 0x652ec
cmpq $0x8000, %rax           # imm = 0x8000
je 0x65190
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x64e0d
leaq 0xa866f(%rip), %rsi     # 0x10d6ec
movl $0xa, %edi
callq 0x64456
movl $0xfa0, %edi            # imm = 0xFA0
callq 0xaff7
movl $0xa, %edi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x64456
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
je 0x652fb
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x651ac
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x64e0d
movl $0x2, %edi
movl $0xc, %esi
callq 0x653a5
leaq 0xbb678(%rip), %rdi     # 0x12076a
callq 0x653eb
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x65433
movl $0x41f, %edi            # imm = 0x41F
xorl %esi, %esi
movl $0x41f, %edx            # imm = 0x41F
callq 0x61a3f
leaq 0x1b5f0e(%rip), %rax    # 0x21b028
movl $0x4, (%rax)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xaff7
movl $0x16, %edi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x61765
leaq 0xbb4d6(%rip), %rdi     # 0x12061c
movl $0x1a4, %esi            # imm = 0x1A4
jmp 0x6535d
leaq 0xbb5ed(%rip), %rdi     # 0x120744
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f070
leaq 0xbb5e3(%rip), %rdi     # 0x12074c
callq 0x61694
callq 0x6170f
leaq 0x1b5eae(%rip), %rax    # 0x21b028
movl $0x3, (%rax)
jmp 0x64e0d
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x643fa
leaq 0xbb5e8(%rip), %rdi     # 0x12077f
callq 0xa36fd
movl $0x1, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa3789
leaq 0xbb5d7(%rip), %rdi     # 0x12078a
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f1e8
movl $0x1e, %edi
callq 0x5e740
movq (%rbx), %rdx
cmpq $0x1, %rdx
sete %al
leaq 0x1b5dfb(%rip), %rcx    # 0x21afd4
movl (%rcx), %ecx
cmpl $0x41, %ecx
sete %dil
andb %al, %dil
leaq 0x1b370c(%rip), %rax    # 0x2188f8
movl (%rax), %esi
cmpl $0x47, %esi
sete %r8b
movb $0x46, %al
testb %r8b, %dil
je 0x6530d
movzbl %al, %edi
callq 0x591af
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5e7c0
leaq 0xbb4ea(%rip), %rdi     # 0x120704
movl $0x1, %ebx
movl $0x1, %esi
callq 0x5ee52
leaq 0xbb407(%rip), %rdi     # 0x120637
movl $0x14d, %esi            # imm = 0x14D
callq 0x5ee52
leaq 0xc04d6(%rip), %rdi     # 0x125717
movl $0x145, %esi            # imm = 0x145
callq 0x5ee52
leaq 0xbb4b7(%rip), %rdi     # 0x120709
movl $0x146, %esi            # imm = 0x146
callq 0x5ee52
leaq 0x1b5789(%rip), %rax    # 0x21a9ec
movl %ebx, (%rax)
leaq 0x1b5770(%rip), %rax    # 0x21a9dc
movl %ebx, (%rax)
jmp 0x64e0d
movl $0x517, %edi            # imm = 0x517
movl $0x8, %esi
xorl %edx, %edx
callq 0x645ec
movzwl 0x3078a5(%rip), %edi    # 0x36cb30
callq 0x5936c
movl $0x8007, %edi           # imm = 0x8007
callq 0x5936c
callq 0x646c7
movl $0x2710, %edi           # imm = 0x2710
callq 0xaff7
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x615f4
leaq 0xbb3d1(%rip), %rdi     # 0x12068c
movl $0x323, %esi            # imm = 0x323
jmp 0x6535d
leaq 0x1b5d14(%rip), %rax    # 0x21afe0
cmpl $0x4e, (%rax)
jne 0x65343
leaq 0xbb47b(%rip), %rdi     # 0x120753
jmp 0x6534a
leaq 0xbb4af(%rip), %rdi     # 0x120790
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f2a0
movl $0x68, 0x30793a(%rip)   # 0x36cc30
jmp 0x64e0d
leaq 0xbb494(%rip), %rdi     # 0x120796
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5f340
testb %dil, %dil
je 0x65368
cmpl $0x33, %esi
je 0x65200
cmpl $0x47, %esi
je 0x65200
cmpl $0x41, %ecx
sete %sil
cmpl $0x50, %ecx
sete %dil
cmpq $0x1, %rdx
jne 0x65380
orb %dil, %sil
jne 0x65200
jmp 0x65380
leaq 0xbb415(%rip), %rdi     # 0x12075f
movl $0x14, %esi
jmp 0x6535d
leaq 0xbb31f(%rip), %rdi     # 0x120677
movl $0xfb, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5ee52
cmpq $0x1, %rdx
sete %sil
cmpl $0x50, %ecx
sete %dil
testb %dil, %sil
jne 0x65200
cmpq $0x1, %rdx
jne 0x6539e
addl $-0x33, %ecx
cmpl $0x1d, %ecx
ja 0x6539e
movb $0x4b, %al
movl $0x20004009, %edx       # imm = 0x20004009
btl %ecx, %edx
jb 0x65200
movb $0x46, %al
jmp 0x65200