// File: /workspace/github_cpp_makefile_star2_O3/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 0x2cc227(%rip), %rax    # 0x33701a
leaq 0x1d4144(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x6b7fd
movl %esi, %r14d
movl %edi, %ebx
leaq 0x1adac0(%rip), %r12    # 0x2188d0
movq (%r12), %rax
cmpq $0x3ffff, %rax          # imm = 0x3FFFF
jle 0x6ae94
cmpq $0x1ffffff, %rax        # imm = 0x1FFFFFF
jg 0x6af33
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
jle 0x6b1b2
cmpq $0x200000, %rax         # imm = 0x200000
je 0x6b5f9
cmpq $0x400000, %rax         # imm = 0x400000
je 0x6b4dc
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x6b7fd
testb %r14b, %r14b
leaq 0xb6209(%rip), %rax     # 0x12106b
leaq 0xb61fe(%rip), %rcx     # 0x121067
cmoveq %rax, %rcx
leaq 0xb61ff(%rip), %rax     # 0x121073
leaq 0xb61f4(%rip), %rdi     # 0x12106f
cmoveq %rax, %rdi
testb %bl, %bl
cmovneq %rcx, %rdi
movl $0xfffffe06, %esi       # imm = 0xFFFFFE06
callq 0x5edda
jmp 0x6b872
cmpq $0x1f, %rax
jle 0x6b0cd
cmpq $0xff, %rax
jle 0x6b158
cmpq $0x100, %rax            # imm = 0x100
je 0x6b4a1
cmpq $0x800, %rax            # imm = 0x800
je 0x6b3f8
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x6b7fd
leaq 0x1b0113(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x6b80f
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 0x2d1315(%rip), %rbx    # 0x33c220
leaq 0xb61d4(%rip), %rsi     # 0x1210e6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0xfe, %esi
callq 0x5edda
movapd -0x40(%rbp), %xmm0
jmp 0x6b821
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jle 0x6b23e
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
je 0x6b652
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x6b4f5
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x6b7fd
movl $0x45, %edi
movl $0x1f, %esi
movaps %xmm0, -0x40(%rbp)
movsd %xmm1, -0x30(%rbp)
callq 0x65608
movapd -0x40(%rbp), %xmm0
mulsd 0x9e090(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edi
callq 0x592eb
movsd -0x30(%rbp), %xmm0
mulsd 0x9e07a(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edi
callq 0x592eb
leaq 0x2a2dea(%rip), %rax    # 0x30dda8
movsd (%rax), %xmm0
addsd 0xa0b6e(%rip), %xmm0    # 0x10bb38
cvttsd2si %xmm0, %eax
cltq
imulq $0x51eb851f, %rax, %rdi # imm = 0x51EB851F
movq %rdi, %rax
shrq $0x3f, %rax
sarq $0x25, %rdi
addl %eax, %edi
callq 0x592eb
movl $0x2, %edi
callq 0x590f7
xorl %edi, %edi
testb %bl, %bl
sete %dil
shll $0x2, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
leaq 0x2a2da7(%rip), %rax    # 0x30ddb8
movzwl (%rax), %eax
movw %ax, -0x140(%rbp)
leaq 0x1ad7b2(%rip), %rbx    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%rbx)
sete %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%rbx)
setne %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
xorl %edi, %edi
callq 0x590f7
movzwl 0x301a22(%rip), %r14d   # 0x36cabc
movl $0xff, %ebx
movl %r14d, %edi
andl %ebx, %edi
callq 0x590f7
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 0x590f7
cmpq $0x7, %rax
jg 0x6b116
movl %edx, %r15d
cmpq $0x1, %rax
je 0x6b2df
cmpq $0x4, %rax
jne 0x6b7fd
leaq 0x2a2c32(%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 0x6bba8
cmpq $0x8, %rax
je 0x6b38a
cmpq $0x10, %rax
jne 0x6b7fd
movaps %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
callq 0x63ce2
leaq 0x2a2cab(%rip), %rax    # 0x30dde8
cmpl $0x0, (%rax)
je 0x6b761
movapd -0x40(%rbp), %xmm0
mulsd 0x9ded5(%rip), %xmm0    # 0x109028
jmp 0x6b766
cmpq $0x20, %rax
je 0x6b557
cmpq $0x80, %rax
jne 0x6b7fd
movl $0x45, %edi
movl $0x6, %esi
movaps %xmm0, -0x40(%rbp)
callq 0x5fb3c
movapd -0x40(%rbp), %xmm0
mulsd 0xb304a(%rip), %xmm0    # 0x11e1d8
cvttsd2si %xmm0, %edi
callq 0x592eb
movl $0x1, %edi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5fc00
cmpq $0x40000, %rax          # imm = 0x40000
je 0x6b6b0
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x6b7fd
mulsd 0x9de56(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d1043(%rip), %rbx    # 0x33c220
leaq 0xb5f9f(%rip), %rsi     # 0x121183
movq %rbx, %rdi
xorl %eax, %eax
movsd %xmm1, -0x30(%rbp)
callq 0x9060
leaq 0x1(%rbx), %r15
movq %r15, %rdi
callq 0x5f0e5
movsd -0x30(%rbp), %xmm0
mulsd 0x9de1c(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0xb5f75(%rip), %rsi     # 0x12118c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
callq 0x5f0e5
testb %r14b, %r14b
je 0x6bae1
leaq 0xb5f5d(%rip), %rdi     # 0x121196
jmp 0x6bae8
cmpq $0x2000000, %rax        # imm = 0x2000000
je 0x6b713
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x6b7fd
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0xb5dce(%rip), %rcx     # 0x121038
leaq 0xb5dd4(%rip), %rsi     # 0x121045
cmovaq %rcx, %rsi
leaq 0xb3814(%rip), %rcx     # 0x11ea90
mulsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %edx
leaq 0x2d0f94(%rip), %r14    # 0x33c220
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5eff8
xorl %r8d, %r8d
testb %bl, %bl
setne %r8b
addl %r8d, %r8d
leaq 0x1afe0f(%rip), %rax    # 0x21b0c0
movl (%rax), %edx
leaq 0x2d1fe2(%rip), %rax    # 0x33d29c
movl (%rax), %ecx
leaq 0xb5d8f(%rip), %rsi     # 0x121052
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5eff8
movl $0x1d6b, %edi           # imm = 0x1D6B
jmp 0x6baa9
leaq 0x1afcee(%rip), %r13    # 0x21afd4
movl (%r13), %eax
cmpl $0x33, %eax
je 0x6b7fd
cmpl $0x36, %eax
je 0x6b7fd
movl $0x8e, %edi
movaps %xmm0, -0x40(%rbp)
movss %xmm2, -0x30(%rbp)
callq 0x5e6be
movl $0x4a, %edi
callq 0x590f7
movzbl %bl, %edi
callq 0x590f7
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 0x590f7
movzbl %r14b, %edi
callq 0x590f7
movaps -0x40(%rbp), %xmm0
callq 0x593bd
movss -0x30(%rbp), %xmm0
callq 0x59376
callq 0x5e73c
testl %r15d, %r15d
je 0x6b7fd
movl $0x6, %edi
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6a4ce
leaq 0x2d0e8f(%rip), %r14    # 0x33c220
leaq 0xb5db0(%rip), %rsi     # 0x121148
movq %r14, %rdi
movb $0x1, %al
callq 0x9060
xorpd %xmm0, %xmm0
callq 0x63ce2
movq %r14, %rdi
movl $0x26, %esi
callq 0x5edda
leaq 0xb5d9b(%rip), %rdi     # 0x12115a
movl $0xe, %esi
callq 0x5edda
testb %bl, %bl
leaq 0xb5da4(%rip), %rax     # 0x121176
leaq 0xb5d8f(%rip), %rdi     # 0x121168
cmoveq %rax, %rdi
movl $0x6a, %esi
callq 0x5edda
leaq 0xb5a26(%rip), %rdi     # 0x120e14
movl $0x6b, %esi
jmp 0x6bacb
movl $0xd7, %edi
movaps %xmm0, -0x40(%rbp)
callq 0x5e6be
movl $0x6, %edi
callq 0x590f7
movapd -0x40(%rbp), %xmm0
mulsd 0x9dc33(%rip), %xmm0    # 0x109050
callq 0x593bd
callq 0x5e7c0
testb %r14b, %r14b
sete %al
shlb $0x3, %al
leaq 0x2a206d(%rip), %rcx    # 0x30d4a4
movb (%rcx), %r14b
andb $0x1, %r14b
shlb $0x5, %r14b
orb %al, %r14b
orb $0x12, %r14b
movl $0xd7, %edi
callq 0x5e6be
movl $0x5, %edi
callq 0x590f7
movzbl %r14b, %edi
callq 0x590f7
movl $0x1, %edi
callq 0x590f7
testb %bl, %bl
je 0x6b85c
leaq 0x2a28e9(%rip), %rax    # 0x30dd68
movl (%rax), %edi
testl %edi, %edi
jne 0x6b85e
leaq 0x2a28dc(%rip), %rax    # 0x30dd6c
movl (%rax), %eax
testl %eax, %eax
movl $0xf4240, %edi          # imm = 0xF4240
cmovnel %eax, %edi
jmp 0x6b85e
leaq 0x2a2920(%rip), %rbx    # 0x30ddc8
movsd (%rbx), %xmm1
movsd %xmm1, -0x40(%rbp)
movsd %xmm0, (%rbx)
leaq 0x1afc08(%rip), %rax    # 0x21b0c4
movl (%rax), %esi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edi, %edi
callq 0x68563
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rbx)
jmp 0x6b7fd
movsd %xmm1, -0x30(%rbp)
callq 0x6bafe
movsd -0x30(%rbp), %xmm0
callq 0x6bb69
jmp 0x6b872
mulsd 0x9db2b(%rip), %xmm0    # 0x109028
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
leaq 0xb5c08(%rip), %rax     # 0x121118
leaq 0xb5bf7(%rip), %rsi     # 0x12110e
cmovbq %rax, %rsi
leaq 0x2d0cfe(%rip), %r14    # 0x33c220
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movq %r14, %rdi
callq 0x5f170
testb %bl, %bl
leaq 0xb5bea(%rip), %rax     # 0x121127
leaq 0xb5bdd(%rip), %rdi     # 0x121121
cmoveq %rax, %rdi
callq 0x5f170
movl $0x1386, %edi           # imm = 0x1386
jmp 0x6baa9
mulsd 0x9dac9(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %r14d
leaq 0xb5a68(%rip), %rdi     # 0x120fd3
movsd %xmm1, -0x30(%rbp)
callq 0x6160d
movl %r14d, %edi
callq 0x592eb
callq 0x61688
leaq 0xb5a4d(%rip), %rdi     # 0x120fd6
callq 0x6160d
cvttsd2si -0x30(%rbp), %edi
callq 0x592eb
callq 0x61688
leaq 0xb5a35(%rip), %rdi     # 0x120fd9
callq 0x6160d
movzbl %bl, %ebx
movl %ebx, %edi
callq 0x590f7
callq 0x61688
leaq 0xb5aa2(%rip), %rdi     # 0x121061
callq 0x6160d
movl $0x1, %edi
callq 0x590f7
leaq 0x1afaef(%rip), %r14    # 0x21b0c4
cmpl $0x0, (%r14)
je 0x6b888
movl $0x1, %edi
callq 0x590f7
movzwl (%r14), %eax
movw %ax, -0x140(%rbp)
jmp 0x6b898
mulsd 0x9da27(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d0c14(%rip), %rbx    # 0x33c220
leaq 0xb5b1a(%rip), %rsi     # 0x12112d
movq %rbx, %rdi
xorl %eax, %eax
movsd %xmm1, -0x30(%rbp)
callq 0x9060
movq %rbx, %rdi
callq 0x5f228
cvttsd2si -0x30(%rbp), %edx
leaq 0xb5b04(%rip), %rsi     # 0x12113a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5f228
movl $0x1366, %edi           # imm = 0x1366
jmp 0x6baa9
movaps %xmm0, -0x40(%rbp)
leaq 0x2d0bc3(%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 0x2a26ed(%rip), %r13    # 0x30dd74
movl (%r13), %r12d
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
testl %r12d, %r12d
je 0x6b98c
movw $0x4b, 0x4(%rax)
movl $0x4c43472c, (%rax)     # imm = 0x4C43472C
jmp 0x6b999
testb %bl, %bl
je 0x6babf
leaq 0x2d0799(%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 0x2d076f(%rip), %rax    # 0x33be50
movl (%rax), %edx
leaq 0xb5916(%rip), %rax     # 0x121000
leaq 0xb5920(%rip), %rsi     # 0x121011
cmovgq %rax, %rsi
leaq 0x2d0b24(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x191, %esi            # imm = 0x191
jmp 0x6bacb
leaq 0x1af6be(%rip), %rax    # 0x21add8
movl (%rax), %eax
xorl %ecx, %ecx
testb %bl, %bl
sete %cl
andl $-0x9, %eax
leal (%rax,%rcx,8), %edi
callq 0x6bdc6
testb %bl, %bl
je 0x6b73e
movzbl %bl, %eax
leaq 0x1af798(%rip), %rcx    # 0x21aed4
movl %eax, (%rcx)
leaq 0x1af777(%rip), %rax    # 0x21aebc
movl $0x1, (%rax)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6be07
movapd -0x40(%rbp), %xmm0
leaq 0x1af873(%rip), %r12    # 0x21afe0
cmpl $0x4e, (%r12)
leaq 0xb58fe(%rip), %rax     # 0x121077
leaq 0xb591b(%rip), %rsi     # 0x12109b
cmoveq %rax, %rsi
leaq 0xb5900(%rip), %rax     # 0x12108b
leaq 0xb9cc2(%rip), %rbx     # 0x125454
cmoveq %rax, %rbx
leaq 0x2d0a83(%rip), %r15    # 0x33c220
movq %r15, %rdi
movb $0x1, %al
callq 0x9060
movq %r15, %rdi
movl $0x26, %esi
callq 0x5edda
movq %rbx, %rdi
movl $0xe, %esi
callq 0x5edda
movl (%r12), %eax
andl $-0x2, %eax
cmpl $0x38, %eax
jne 0x6b7fd
testb %r14b, %r14b
leaq 0xb58ec(%rip), %rax     # 0x1210c3
leaq 0xb58d1(%rip), %rdi     # 0x1210af
cmoveq %rax, %rdi
movl $0x22, %esi
callq 0x5edda
leaq 0xb58e3(%rip), %rdi     # 0x1210d6
movl $0x22, %esi
jmp 0x6bacb
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 0x6b821
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
mulsd 0x9d7ff(%rip), %xmm0    # 0x109028
cvttsd2si %xmm0, %edx
leaq 0x2d09ec(%rip), %rbx    # 0x33c220
leaq 0xb58bf(%rip), %rsi     # 0x1210fa
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0xfd, %esi
callq 0x5edda
movl $0x1365, %edi           # imm = 0x1365
jmp 0x6baa9
xorl %edi, %edi
callq 0x592eb
callq 0x5e7c0
movl $0xc8, %edi
callq 0xafe8
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6ab01
xorl %edi, %edi
callq 0x590f7
movw $0x3e8, -0x140(%rbp)    # imm = 0x3E8
leaq 0x1acf35(%rip), %r15    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%r15)
sete %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%r15)
setne %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
movl $0xa, %r15d
xorl %edi, %edi
callq 0x590f7
decl %r15d
jne 0x6b8d8
callq 0x61688
leaq 0xb5774(%rip), %rdi     # 0x121064
callq 0x6160d
movl $0x1, %edi
callq 0x590f7
cmpl $0x0, (%r14)
je 0x6b91c
movl $0x1, %edi
callq 0x590f7
movzwl (%r14), %eax
movw %ax, -0x140(%rbp)
jmp 0x6b92c
xorl %edi, %edi
callq 0x590f7
movw $0x3e8, -0x140(%rbp)    # imm = 0x3E8
leaq 0x1acea1(%rip), %r14    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%r14)
sete %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%r14)
setne %al
movzbl -0x140(%rbp,%rax), %edi
callq 0x590f7
movl %ebx, %edi
callq 0x590f7
movl $0xa, %ebx
xorl %edi, %edi
callq 0x590f7
decl %ebx
jne 0x6b96b
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x61688
movabsq $0x59434147454c2c, %rcx # imm = 0x59434147454C2C
movq %rcx, (%rax)
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
testb %bl, %bl
je 0x6b9b3
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6b9bc
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0x2a2360(%rip), %rax    # 0x30dd23
movb (%rax), %bl
movq %r15, %rdi
callq 0x9120
addq %r15, %rax
cmpb $-0x7e, %bl
jne 0x6b9e0
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6b9e9
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0x2a2380(%rip), %rax    # 0x30dd70
movl (%rax), %edx
leaq 0xb581f(%rip), %rbx     # 0x121218
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 0x9d603(%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 0x6ba64
testl %ebx, %ebx
je 0x6ba64
movb $0x0, 0x2(%rax)
movw $0x312c, (%rax)         # imm = 0x312C
jmp 0x6ba6d
movb $0x0, 0x2(%rax)
movw $0x302c, (%rax)         # imm = 0x302C
leaq 0xb57a4(%rip), %rsi     # 0x121218
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movl $0x12c, %edx            # imm = 0x12C
xorl %eax, %eax
callq 0x9060
leaq 0x2d078f(%rip), %r14    # 0x33c220
movq %r14, %rdi
movq %rbx, %rsi
callq 0x96c0
movq %r14, %rdi
callq 0x5ee9b
movl $0x2253, %edi           # imm = 0x2253
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x667f2
leaq 0xb555b(%rip), %rdi     # 0x121021
movl $0x192, %esi            # imm = 0x192
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5edda
leaq 0xb56b6(%rip), %rdi     # 0x12119e
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f0e5