// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: set_pps(unsigned char, unsigned char, double, double, float, int)
void set_pps(u08 pps_enable,  u08 pps_polarity,  double delay, double pps_delay, float threshold, int save)
{
int val;
int i;
u08 flags;
double dly;
char s[SLEN+1];

   if(read_only) return;
   if(luxor) return;

   // pps_polarity 0=positive  1=negative

   if(rcvr_type == BRANDY_RCVR) {
      i = brandy_pps_width;  // pulse width
      if(i < 0) i = 0 - i;
if(i == 0) i = 1;
      if(pps_polarity) i = 0-i;

      if(pps_enable) {  // enable J10 PPS output
         if(i > 0) sprintf(out, "$PRCCG,C,P%d,+%d", brandy_pps_rate, i);
         else      sprintf(out, "$PRCCG,C,P%d,%d", brandy_pps_rate, i);
         queue_brandy_cmd(out, BRANDY_PULSE_MSG);
      }
      else {  // disable PPS output
         queue_brandy_cmd("$PRCCG,E,X,0,X,X", BRANDY_CODE_MSG);
      }
   }
   else if(rcvr_type == ESIP_RCVR) {
      sprintf(out, "PERDAPI");
      strcat(out, ",PPS");
      if(esip_pps_type) strcat(out, ",GCLK");
      else              strcat(out, ",LEGACY");

      if(pps_enable) strcat(out, ",1");
      else           strcat(out, ",0");

      if(pps_rate == RATE_PP2S) strcat(out, ",1");    // PPS2S rate
      else                      strcat(out, ",0");    // 1PPS rate

      sprintf(s, ",%d", esip_pps_width);  // pps pulse width
      strcat(out, s); 

      sprintf(s, ",%d", (int) (delay*1.0E9));
      strcat(out, s);  // cable delay

      if((esip_pps_type == 0) || (pps_polarity == 0)) strcat(out, ",0"); // only rising edge avail in LEGACY mode
      else strcat(out, ",1");  // falling edge (only available in GCLK mode)

threshold = 300.0F;
      sprintf(s, ",%d", (int) (threshold));  // accuracy threshold
      strcat(out, s); 
      send_esip_cmd(out);

      request_rcvr_config(8787);
   }
   else if(rcvr_type == FURUNO_RCVR) {
      if(delay < 0.0) sprintf(out, "GPset,t-%06d", (int) (delay*1.0E9*(-1.0)));
      else            sprintf(out, "GPset,t+%06d", (int) (delay*1.0E9));
      send_furuno_cmd(out); 

      if(pps_enable) {  // !!!! pps output enabled if sats tracked
         sprintf(out, "GPrrs,%d,%d,%d", traim_mode,furuno_traim,2);
      }
      else {
         sprintf(out, "GPrrs,%d,%d,%d", traim_mode,furuno_traim,0);
      }
      send_furuno_cmd(out);

      request_rcvr_config(7531);
   }
   else if(rcvr_type == MOTO_RCVR) {  // !!! moto_chans
      val = (int) (delay*1.0E9);
      send_moto_start("Az");
      send_dword(val);
      send_moto_end();

      send_moto_start("Ay");
      send_dword((S32) pps_delay);
      send_moto_end();

      send_moto_start("Gc");
      send_byte(pps_enable);
      send_moto_end();

      send_moto_start("Bn");  // 6 chan traim control
      send_byte(1);
      if(traim_threshold) {
         send_byte(1);
         send_word(traim_threshold);
      }
      else {
         send_byte(0);
         send_word(1000);
      }
      send_byte(pps_enable);
      for(i=0; i<10; i++) send_byte(0);
      send_moto_end();

      send_moto_start("En");  // 8 chan traim control
      send_byte(1);
      if(traim_threshold) {
         send_byte(1);
         send_word(traim_threshold);
      }
      else {
         send_byte(0);
         send_word(1000);
      }
      send_byte(pps_enable);
      for(i=0; i<10; i++) send_byte(0);
      send_moto_end();
   }
   else if(rcvr_type == NVS_RCVR) { 
      send_nvs_start(0xD7);
      send_byte(0x06);
      send_double(delay * 1.0E6);   
      send_nvs_end();

      flags = 0x02;    // software PPS every second
      if(pps_polarity == 0)       flags |= 0x08;  // rising edge (direct PPS)
      if(time_flags & TFLAGS_UTC) flags |= 0x30;  // sync PPS to UTC time
      else                        flags |= 0x10;  // sync PPS to GPS time
      send_nvs_start(0xD7); // qqqqqqqqq !!!!! can also sync to GLONASS or UTC-SU
      send_byte(0x05);
      send_byte(flags);     // PPS config byte
      send_byte(1);         // keep internal time scale aligned
      if(pps_enable) {
         if(nvs_pps_width) send_dword(nvs_pps_width); // set pps width in nanoseconds
         else if(last_nvs_pps_width) send_dword(last_nvs_pps_width); // set pps width in nanoseconds
         else send_dword(NVS_PPS_WIDTH); // set pps width in nanoseconds
      }
      else send_dword(0); // set pps width in nanoseconds
      send_nvs_end();

      Sleep(200);
      request_pps_info();
   }
   else if(rcvr_type == PRS_RCVR) {
      if(pps_enable) {
         // !!!!! LM command does not respond with "OK" in verbose mode... use -PRS_LM_MSG kludge
         if(pps_polarity) {
            queue_prs_cmd("LM0", -PRS_LM_MSG);  // pps enabled - no lock filter
         }
         else {
            queue_prs_cmd("LM1", -PRS_LM_MSG);  // pps enabled -  with lock filter
         }
      }
      else {
         if(pps_polarity) {
            queue_prs_cmd("LM2", -PRS_LM_MSG);  // pps diabled, active  low on lock
         }
         else {
            queue_prs_cmd("LM3", -PRS_LM_MSG);  // pps diabled, active high on lock
         }
      }
      request_pps_info();
   }
   else if(rcvr_type == RFTG_RCVR) {
      set_rftg_cable(delay);
      set_rftg_offset(pps_delay);
      request_pps_info();
   }
   else if(rcvr_type == SCPI_RCVR) {
      extend_com_timeout(0.0);
      if(cable_nsecs) delay *= 1.0E9;
      if(scpi_type == NORTEL_TYPE) {
         sprintf(out, "GPS:REF:ADELAY %.9f", delay);
         queue_scpi_cmd(out, SCPI_SET_CABLE_MSG);
         queue_scpi_cmd("GPS:REF:ADELAY?", SCPI_GET_CABLE_MSG);
      }
      else {
         sprintf(out, ":PTIM:GPS:ADEL %.9f", delay);
         queue_scpi_cmd(out, SCPI_SET_CABLE_MSG);
         queue_scpi_cmd("PTIM:GPS:ADEL?", SCPI_GET_CABLE_MSG);
      }

      if((scpi_type == HP_TYPE) || (scpi_type == HP_TYPE2)) {
         if(pps_polarity) {  // falling edge  Z3816 HP59xxx
            queue_scpi_cmd(":PTIM:PPS:EDGE FALL", SCPI_EDGE_MSG);
         }
         else {  // rising edge
            queue_scpi_cmd(":PTIM:PPS:EDGE RIS", SCPI_EDGE_MSG);
         }
         queue_scpi_cmd(":PTIM:PPS:EDGE?", SCPI_EDGE_MSG);  // HP_TYPE2 only
      }

      // !!!! Z3816 / HP5xxxx can set pps rate
      // :PULSE:CONT:PER seconds
      // :PULSE:CONT:STAT (0 | 1)
   }
   else if(rcvr_type == SS_RCVR) {
      send_ss_start(69, 31);
      send_dword((int) (delay*1.0E9));
      send_dword((int) (pps_delay*1.0E9));
      val = (int) (ss_pps_width+50.0);  // in nsec (rounded up)
      val /= 100;
      send_dword(val);
      send_byte(2);     // keep pps aligned continuously
      if(pps_enable) send_byte(0); // pps always on
      else           send_byte(4); // disable pps
      send_byte(0);  // reserved
      send_word(ss_intrinsic_delay);  // intrinsic delay in ns
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_byte(0);  // reserved
      send_ss_end();
   }
   else if(rcvr_type == STAR_RCVR) {
      if(star_type == OSA_TYPE) {
         if(delay < 0.0) delay = 0.0 - delay;  // uses positive values

         sprintf(out, "PPS_USER_OFFSET=%d;", (int) (pps_delay));
         queue_star_cmd(out, STAR_OFFSET_MSG);
      }
      else {
         if(delay > 0.0) delay = 0.0 - delay;  // uses negative values
      }
      sprintf(out, "PPS_CABLE_DELAY=%d;", (int) (delay*1.0E9));
      queue_star_cmd(out, STAR_CABLE_MSG);

      request_rcvr_config(4965);  // CONF command returns the setting
   }
   else if(rcvr_type == TM4_RCVR) {
      delay *= 1.0E9;
      if(delay >= 0) sprintf(out, "#06,+%05d", (int) delay);
      else           sprintf(out, "#06,%06d", (int) delay);
      send_tm4_cmd(out);

      if(pps_enable) {
         send_tm4_cmd("#09,7");
      }
      else {
         send_tm4_cmd("#09,8");
      }
      request_rcvr_config(4998); 
   }
   else if(rcvr_type == TRUE_RCVR) {
      sprintf(out, "$SETDELAY %d", (int) (delay*1.0E9));
      send_true_cmd(out);  // $SETDELAY %d
      sprintf(out, "$SETBDELAY %d", (int) pps_delay);
      send_true_cmd(out);  // $SETBDELAY %d
      request_rcvr_config(4966);
   }
   else if(rcvr_type == TSIP_RCVR) {
      if(ACU_GG) ;
      else if(ACU_360) ;
      else if(ACUTIME) ;
      else if(PALISADE) ;
      else if(SV6_FAMILY) return;

      send_tsip_start(0x8E);
      send_byte(0x4A);
      send_byte(pps_enable);
      if(ACUTIME || PALISADE) {
         send_byte(0x01);   // !!!!!!!!!!!  use timing mode
      }
      else {
         send_byte(0x00);           // ACUTIME/PALISADE  0=GPS PPS   1=UTC PPS
      }
      send_byte(pps_polarity);
      send_double(delay);
      send_single(threshold);
      send_tsip_end();

      if(save) save_segment(6, 22);  // save timing config in EEPROM
   }
   else if(rcvr_type == UBX_RCVR) {  // !!!! zorky TP5
      set_ubx_pps(0, pps_rate, pps_enable, pps_polarity, delay, pps_delay, save);
   }
   else if(rcvr_type == UCCM_RCVR) {   // can't change polarity
      sprintf(out, "GPS:REF:ADEL %.9f", delay);
      extend_com_timeout(0.0);
      queue_uccm_cmd(out, SCPI_SET_CABLE_MSG);
      queue_uccm_cmd("GPS:REF:ADEL?", SCPI_GET_CABLE_MSG);

      if(pps_enable) queue_uccm_cmd("OUTP:ACT:ENAB", UCCM_OUTP_MSG);
      else           queue_uccm_cmd("OUTP:ACT:DIS", UCCM_OUTP_MSG);
      queue_uccm_cmd("OUTP:STAT?", UCCM_STATE_MSG);

      // !!!! Z3816 / HP5xxxx can set pps rate
      // :PULSE:CONT:PER seconds
      // :PULSE:CONT:STAT (0 | 1)
   }
   else if(rcvr_type == VENUS_RCVR) {
      send_venus_start(SET_VENUS_CABLE);
      send_dword((S32) (delay*1.0E11));
      send_venus_save(1);
   }
   else if(rcvr_type == X72_RCVR) {
      val = x72_creg;
      if(pps_enable) val &= (~0x0008);
      else           val |= (0x0008);
      set_x72_creg(val);

      if(pps_enable) last_x72_pps_enable = pps_enable;
      user_set_x72_pps_enable = 1;
      save_x72_state();
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      dly = cable_delay;
      cable_delay = delay;
      set_zod_config(0, 0.0,0.0,0.0, traim_threshold, 4);  // cable delay
      cable_delay = dly;
   }
   else if(rcvr_type == ZYFER_RCVR) {
      sprintf(out, "$ANTD,%d", (int) (delay*1.0E9));
      send_zyfer_cmd(out);

      sprintf(out, "$OFST,%d", (int) (pps_delay*1.0E9));
      send_zyfer_cmd(out);

      if(pps_polarity) send_zyfer_cmd("$PULP,-");      
      else             send_zyfer_cmd("$PULP,+");      
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0x2cc2e2(%rip), %rax    # 0x33701a
leaq 0x1d41ff(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x6b767
movl %esi, %r14d
movl %edi, %ebx
leaq 0x1adb7b(%rip), %r12    # 0x2188d0
movq (%r12), %rax
cmpq $0x3ffff, %rax          # imm = 0x3FFFF
jle 0x6add9
cmpq $0x1ffffff, %rax        # imm = 0x1FFFFFF
jg 0x6ae78
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jle 0x6b0c4
cmpq $0x200000, %rax         # imm = 0x200000
je 0x6b50d
cmpq $0x400000, %rax         # imm = 0x400000
je 0x6b3f7
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x6b767
testb %r14b, %r14b
leaq 0xb61e4(%rip), %rax     # 0x120f8b
leaq 0xb61d9(%rip), %rcx     # 0x120f87
cmoveq %rax, %rcx
leaq 0xb61da(%rip), %rax     # 0x120f93
leaq 0xb61cf(%rip), %rdi     # 0x120f8f
cmoveq %rax, %rdi
testb %bl, %bl
cmovneq %rcx, %rdi
movl $0xfffffe06, %esi       # imm = 0xFFFFFE06
callq 0x5ee52
jmp 0x6b7dc
cmpq $0x1f, %rax
jle 0x6afdf
cmpq $0xff, %rax
jle 0x6b06a
cmpq $0x100, %rax            # imm = 0x100
je 0x6b3bc
cmpq $0x800, %rax            # imm = 0x800
je 0x6b313
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x6b767
leaq 0x1b01ce(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x6b779
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm3
cmpltsd %xmm2, %xmm3
subsd %xmm0, %xmm2
andpd %xmm3, %xmm2
andnpd %xmm0, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, -0x40(%rbp)
cvttsd2si %xmm1, %edx
leaq 0x2d13d0(%rip), %rbx    # 0x33c220
leaq 0xb61af(%rip), %rsi     # 0x121006
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0xfe, %esi
callq 0x5ee52
movapd -0x40(%rbp), %xmm0
jmp 0x6b78b
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jle 0x6b150
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x6b566
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x6b410
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x6b767
movl $0x45, %edi
movl $0x1f, %esi
movaps %xmm0, -0x40(%rbp)
movsd %xmm1, -0x30(%rbp)
callq 0x653a5
movapd -0x40(%rbp), %xmm0
mulsd 0x9e14b(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edi
callq 0x593b5
movsd -0x30(%rbp), %xmm0
mulsd 0x9e135(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edi
callq 0x593b5
leaq 0x2a2ea5(%rip), %rax    # 0x30dda8
movsd (%rax), %xmm0
addsd 0xa09e1(%rip), %xmm0    # 0x10b8f0
cvttsd2si %xmm0, %eax
cltq
imulq $0x51eb851f, %rax, %rdi # imm = 0x51EB851F
movq %rdi, %rax
shrq $0x3f, %rax
sarq $0x25, %rdi
addl %eax, %edi
callq 0x593b5
movl $0x2, %edi
callq 0x591af
xorl %edi, %edi
testb %bl, %bl
sete %dil
shll $0x2, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
leaq 0x2a2e62(%rip), %rax    # 0x30ddb8
movzwl (%rax), %edi
callq 0x5936c
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
xorl %edi, %edi
callq 0x591af
movzwl 0x301b10(%rip), %r14d   # 0x36cabc
movl $0xff, %ebx
movl %r14d, %edi
andl %ebx, %edi
callq 0x591af
addl %r14d, %ebx
testw %r14w, %r14w
cmovnsl %r14d, %ebx
movzbl %bh, %edi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x591af
cmpq $0x7, %rax
jg 0x6b028
movl %edx, %r15d
cmpq $0x1, %rax
je 0x6b1f1
cmpq $0x4, %rax
jne 0x6b767
leaq 0x2a2d20(%rip), %rax    # 0x30dd23
movzbl (%rax), %esi
movzbl %bl, %edx
movzbl %r14b, %ecx
xorl %edi, %edi
movl %r15d, %r8d
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6baab
cmpq $0x8, %rax
je 0x6b2a5
cmpq $0x10, %rax
jne 0x6b767
movaps %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
callq 0x63c5c
leaq 0x2a2d99(%rip), %rax    # 0x30dde8
cmpl $0x0, (%rax)
je 0x6b6cb
movapd -0x40(%rbp), %xmm0
mulsd 0x9dfc3(%rip), %xmm0    # 0x109028
jmp 0x6b6d0
cmpq $0x20, %rax
je 0x6b472
cmpq $0x80, %rax
jne 0x6b767
movl $0x45, %edi
movl $0x6, %esi
movaps %xmm0, -0x40(%rbp)
callq 0x5fbb4
movapd -0x40(%rbp), %xmm0
mulsd 0xb3090(%rip), %xmm0    # 0x11e130
cvttsd2si %xmm0, %edi
callq 0x593b5
movl $0x1, %edi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5fc43
cmpq $0x40000, %rax          # imm = 0x40000
je 0x6b5c4
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x6b767
mulsd 0x9df44(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d1131(%rip), %rbx    # 0x33c220
leaq 0xb5fad(%rip), %rsi     # 0x1210a3
movq %rbx, %rdi
xorl %eax, %eax
movsd %xmm1, -0x30(%rbp)
callq 0x9060
leaq 0x1(%rbx), %r15
movq %r15, %rdi
callq 0x5f15d
movsd -0x30(%rbp), %xmm0
mulsd 0x9df0a(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0xb5f83(%rip), %rsi     # 0x1210ac
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
callq 0x5f15d
testb %r14b, %r14b
je 0x6b9e4
leaq 0xb5f6b(%rip), %rdi     # 0x1210b6
jmp 0x6b9eb
cmpq $0x2000000, %rax        # imm = 0x2000000
je 0x6b627
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x6b767
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0xb5ddc(%rip), %rcx     # 0x120f58
leaq 0xb5de2(%rip), %rsi     # 0x120f65
cmovaq %rcx, %rsi
leaq 0xb3852(%rip), %rcx     # 0x11e9e0
mulsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %edx
leaq 0x2d1082(%rip), %r14    # 0x33c220
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5f070
xorl %r8d, %r8d
testb %bl, %bl
setne %r8b
addl %r8d, %r8d
leaq 0x1afefd(%rip), %rax    # 0x21b0c0
movl (%rax), %edx
leaq 0x2d20d0(%rip), %rax    # 0x33d29c
movl (%rax), %ecx
leaq 0xb5d9d(%rip), %rsi     # 0x120f72
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5f070
movl $0x1d6b, %edi           # imm = 0x1D6B
jmp 0x6b9ac
leaq 0x1afddc(%rip), %r13    # 0x21afd4
movl (%r13), %ecx
movl %ecx, %esi
xorl $0x41, %esi
leaq 0x1ad6f0(%rip), %rdx    # 0x2188f8
movl (%rdx), %edx
movl %edx, %edi
xorl $0x47, %edi
orl %esi, %edi
jne 0x6b675
movl $0x8e, %edi
movaps %xmm0, -0x40(%rbp)
movss %xmm2, -0x30(%rbp)
callq 0x5e740
movl $0x4a, %edi
callq 0x591af
movzbl %bl, %edi
callq 0x591af
cmpq $0x1, (%r12)
sete %al
movl (%r13), %ecx
cmpl $0x41, %ecx
sete %dl
cmpl $0x50, %ecx
sete %cl
orb %dl, %cl
andb %al, %cl
movzbl %cl, %edi
callq 0x591af
movzbl %r14b, %edi
callq 0x591af
movaps -0x40(%rbp), %xmm0
callq 0x59487
movss -0x30(%rbp), %xmm0
callq 0x59440
callq 0x5e7c0
testl %r15d, %r15d
je 0x6b767
movl $0x6, %edi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6a306
leaq 0x2d0f74(%rip), %r14    # 0x33c220
leaq 0xb5db5(%rip), %rsi     # 0x121068
movq %r14, %rdi
movb $0x1, %al
callq 0x9060
xorpd %xmm0, %xmm0
callq 0x63c5c
movq %r14, %rdi
movl $0x26, %esi
callq 0x5ee52
leaq 0xb5da0(%rip), %rdi     # 0x12107a
movl $0xe, %esi
callq 0x5ee52
testb %bl, %bl
leaq 0xb5da9(%rip), %rax     # 0x121096
leaq 0xb5d94(%rip), %rdi     # 0x121088
cmoveq %rax, %rdi
movl $0x6a, %esi
callq 0x5ee52
leaq 0xb5a2b(%rip), %rdi     # 0x120d34
movl $0x6b, %esi
jmp 0x6b9ce
movl $0xd7, %edi
movaps %xmm0, -0x40(%rbp)
callq 0x5e740
movl $0x6, %edi
callq 0x591af
movapd -0x40(%rbp), %xmm0
mulsd 0x9dd18(%rip), %xmm0    # 0x109050
callq 0x59487
callq 0x5e844
testb %r14b, %r14b
sete %al
shlb $0x3, %al
leaq 0x2a2152(%rip), %rcx    # 0x30d4a4
movb (%rcx), %r14b
andb $0x1, %r14b
shlb $0x5, %r14b
orb %al, %r14b
orb $0x12, %r14b
movl $0xd7, %edi
callq 0x5e740
movl $0x5, %edi
callq 0x591af
movzbl %r14b, %edi
callq 0x591af
movl $0x1, %edi
callq 0x591af
testb %bl, %bl
je 0x6b7c6
leaq 0x2a29ce(%rip), %rax    # 0x30dd68
movl (%rax), %edi
testl %edi, %edi
jne 0x6b7c8
leaq 0x2a29c1(%rip), %rax    # 0x30dd6c
movl (%rax), %eax
testl %eax, %eax
movl $0xf4240, %edi          # imm = 0xF4240
cmovnel %eax, %edi
jmp 0x6b7c8
leaq 0x2a2a05(%rip), %rbx    # 0x30ddc8
movsd (%rbx), %xmm1
movsd %xmm1, -0x40(%rbp)
movsd %xmm0, (%rbx)
leaq 0x1afced(%rip), %rax    # 0x21b0c4
movl (%rax), %esi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edi, %edi
callq 0x683cd
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rbx)
jmp 0x6b767
movsd %xmm1, -0x30(%rbp)
callq 0x6ba01
movsd -0x30(%rbp), %xmm0
callq 0x6ba6c
jmp 0x6b7dc
mulsd 0x9dc10(%rip), %xmm0    # 0x109028
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
leaq 0xb5c0d(%rip), %rax     # 0x121038
leaq 0xb5bfc(%rip), %rsi     # 0x12102e
cmovbq %rax, %rsi
leaq 0x2d0de3(%rip), %r14    # 0x33c220
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5f1e8
testb %bl, %bl
leaq 0xb5bef(%rip), %rax     # 0x121047
leaq 0xb5be2(%rip), %rdi     # 0x121041
cmoveq %rax, %rdi
callq 0x5f1e8
movl $0x1386, %edi           # imm = 0x1386
jmp 0x6b9ac
mulsd 0x9dbae(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %r14d
leaq 0xb5a6d(%rip), %rdi     # 0x120ef3
movsd %xmm1, -0x30(%rbp)
callq 0x61694
movl %r14d, %edi
callq 0x593b5
callq 0x6170f
leaq 0xb5a52(%rip), %rdi     # 0x120ef6
callq 0x61694
cvttsd2si -0x30(%rbp), %edi
callq 0x593b5
callq 0x6170f
leaq 0xb5a3a(%rip), %rdi     # 0x120ef9
callq 0x61694
movzbl %bl, %ebx
movl %ebx, %edi
callq 0x591af
callq 0x6170f
leaq 0xb5aa7(%rip), %rdi     # 0x120f81
callq 0x61694
movl $0x1, %edi
callq 0x591af
leaq 0x1afbd4(%rip), %r14    # 0x21b0c4
cmpl $0x0, (%r14)
je 0x6b7f2
movl $0x1, %edi
callq 0x591af
movzwl (%r14), %eax
jmp 0x6b7fd
mulsd 0x9db13(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d0d00(%rip), %rbx    # 0x33c220
leaq 0xb5b26(%rip), %rsi     # 0x12104d
movq %rbx, %rdi
xorl %eax, %eax
movsd %xmm1, -0x30(%rbp)
callq 0x9060
movq %rbx, %rdi
callq 0x5f2a0
cvttsd2si -0x30(%rbp), %edx
leaq 0xb5b10(%rip), %rsi     # 0x12105a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5f2a0
movl $0x1366, %edi           # imm = 0x1366
jmp 0x6b9ac
movaps %xmm0, -0x40(%rbp)
leaq 0x2d0caf(%rip), %r15    # 0x33c220
movabsq $0x49504144524550, %rax # imm = 0x49504144524550
movq %rax, (%r15)
movq %r15, %rdi
callq 0x9120
movl $0x5350502c, (%r15,%rax) # imm = 0x5350502C
movb $0x0, 0x4(%r15,%rax)
leaq 0x2a27d9(%rip), %r13    # 0x30dd74
movl (%r13), %r12d
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
testl %r12d, %r12d
je 0x6b88f
movw $0x4b, 0x4(%rax)
movl $0x4c43472c, (%rax)     # imm = 0x4C43472C
jmp 0x6b89c
testb %bl, %bl
je 0x6b9c2
leaq 0x2d0885(%rip), %rax    # 0x33be58
movl (%rax), %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
cmpl $0x1, %edx
adcl $0x0, %edx
movl %edx, %ecx
negl %ecx
testb %r14b, %r14b
cmovel %edx, %ecx
testl %ecx, %ecx
leaq 0x2d085b(%rip), %rax    # 0x33be50
movl (%rax), %edx
leaq 0xb5922(%rip), %rax     # 0x120f20
leaq 0xb592c(%rip), %rsi     # 0x120f31
cmovgq %rax, %rsi
leaq 0x2d0c10(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x191, %esi            # imm = 0x191
jmp 0x6b9ce
leaq 0x1af7aa(%rip), %rax    # 0x21add8
movl (%rax), %eax
xorl %ecx, %ecx
testb %bl, %bl
sete %cl
andl $-0x9, %eax
leal (%rax,%rcx,8), %edi
callq 0x6bc7b
testb %bl, %bl
je 0x6b652
movzbl %bl, %eax
leaq 0x1af884(%rip), %rcx    # 0x21aed4
movl %eax, (%rcx)
leaq 0x1af863(%rip), %rax    # 0x21aebc
movl $0x1, (%rax)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bcbc
cmpl $0x41, %ecx
jne 0x6b68c
cmpl $0x33, %edx
je 0x6b217
cmpl $0x47, %edx
je 0x6b217
cmpl $0x41, %ecx
sete %dl
cmpl $0x50, %ecx
setne %sil
cmpq $0x1, %rax
jne 0x6b217
xorb %sil, %dl
je 0x6b217
addl $-0x33, %ecx
cmpl $0x1d, %ecx
ja 0x6b217
movl $0x20004009, %eax       # imm = 0x20004009
btl %ecx, %eax
jb 0x6b767
jmp 0x6b217
movapd -0x40(%rbp), %xmm0
leaq 0x1af909(%rip), %r12    # 0x21afe0
cmpl $0x4e, (%r12)
leaq 0xb58b4(%rip), %rax     # 0x120f97
leaq 0xb58d1(%rip), %rsi     # 0x120fbb
cmoveq %rax, %rsi
leaq 0xb58b6(%rip), %rax     # 0x120fab
leaq 0xb9c78(%rip), %rbx     # 0x125374
cmoveq %rax, %rbx
leaq 0x2d0b19(%rip), %r15    # 0x33c220
movq %r15, %rdi
movb $0x1, %al
callq 0x9060
movq %r15, %rdi
movl $0x26, %esi
callq 0x5ee52
movq %rbx, %rdi
movl $0xe, %esi
callq 0x5ee52
movl (%r12), %eax
andl $-0x2, %eax
cmpl $0x38, %eax
jne 0x6b767
testb %r14b, %r14b
leaq 0xb58a2(%rip), %rax     # 0x120fe3
leaq 0xb5887(%rip), %rdi     # 0x120fcf
cmoveq %rax, %rdi
movl $0x22, %esi
callq 0x5ee52
leaq 0xb5899(%rip), %rdi     # 0x120ff6
movl $0x22, %esi
jmp 0x6b9ce
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6b78b
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
mulsd 0x9d895(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d0a82(%rip), %rbx    # 0x33c220
leaq 0xb5875(%rip), %rsi     # 0x12101a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0xfd, %esi
callq 0x5ee52
movl $0x1365, %edi           # imm = 0x1365
jmp 0x6b9ac
xorl %edi, %edi
callq 0x593b5
callq 0x5e844
movl $0xc8, %edi
callq 0xaff7
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6a9e7
xorl %edi, %edi
callq 0x591af
movw $0x3e8, %ax             # imm = 0x3E8
movzwl %ax, %edi
callq 0x5936c
movl %ebx, %edi
callq 0x591af
movl $0xa, %r15d
xorl %edi, %edi
callq 0x591af
decl %r15d
jne 0x6b812
callq 0x6170f
leaq 0xb575a(%rip), %rdi     # 0x120f84
callq 0x61694
movl $0x1, %edi
callq 0x591af
cmpl $0x0, (%r14)
je 0x6b84f
movl $0x1, %edi
callq 0x591af
movzwl (%r14), %eax
jmp 0x6b85a
xorl %edi, %edi
callq 0x591af
movw $0x3e8, %ax             # imm = 0x3E8
movzwl %ax, %edi
callq 0x5936c
movl %ebx, %edi
callq 0x591af
movl $0xa, %ebx
xorl %edi, %edi
callq 0x591af
decl %ebx
jne 0x6b86e
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6170f
movabsq $0x59434147454c2c, %rcx # imm = 0x59434147454C2C
movq %rcx, (%rax)
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
testb %bl, %bl
je 0x6b8b6
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6b8bf
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0x2a245d(%rip), %rax    # 0x30dd23
movb (%rax), %bl
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
cmpb $-0x7e, %bl
jne 0x6b8e3
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6b8ec
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0x2a247d(%rip), %rax    # 0x30dd70
movl (%rax), %edx
leaq 0xb583c(%rip), %rbx     # 0x121138
leaq -0x140(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
movq %r12, %rsi
callq 0x96c0
movapd -0x40(%rbp), %xmm0
mulsd 0x9d700(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
movq %r12, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
movq %r12, %rsi
callq 0x96c0
movl (%r13), %ebx
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
testb %r14b, %r14b
je 0x6b967
testl %ebx, %ebx
je 0x6b967
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6b970
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0xb57c1(%rip), %rsi     # 0x121138
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movl $0x12c, %edx            # imm = 0x12C
xorl %eax, %eax
callq 0x9060
leaq 0x2d088c(%rip), %r14    # 0x33c220
movq %r14, %rdi
movq %rbx, %rsi
callq 0x96c0
movq %r14, %rdi
callq 0x5ef13
movl $0x2253, %edi           # imm = 0x2253
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x66617
leaq 0xb5578(%rip), %rdi     # 0x120f41
movl $0x192, %esi            # imm = 0x192
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5ee52
leaq 0xb56d3(%rip), %rdi     # 0x1210be
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f15d