// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathui.cpp
// Function: edit_pps_freq(int)
void edit_pps_freq(int chan)
{
double freq;
double duty;
int old_width;

   // set lat/lon/altitude
   if(edit_buffer[0] == 0) return;

   freq = 1.0;
   duty = 0.50;
   if     (rcvr_type == NVS_RCVR)   sscanf(edit_buffer, "%lf", &duty);
   else if(rcvr_type == CS_RCVR)    sscanf(edit_buffer, "%lf", &freq);
   else if((rcvr_type == ESIP_RCVR) && (chan == 0)) sscanf(edit_buffer, "%lf", &duty);
   else if((rcvr_type == SS_RCVR) && (chan == 0))   sscanf(edit_buffer, "%lf", &duty);
   else if(rcvr_type == TM4_RCVR)   sscanf(edit_buffer, "%lf", &freq);
   else if(rcvr_type == ZYFER_RCVR) sscanf(edit_buffer, "%lf", &duty);
   else sscanf(edit_buffer, "%lf %lf", &freq, &duty);


   if(rcvr_type == CS_RCVR) {
   }
   else if((rcvr_type == ESIP_RCVR) && (chan == 0)) { // PPS pulse width
      if((duty < 1.0) || (duty > 500.0)) {
         edit_error("PPS width must be 1..500 msecs");
      }
      else {
         old_width = esip_pps_width;
         esip_pps_width = (int) duty;
         set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 4);
         esip_pps_width = old_width;
         request_pps_info();
      }
      return;
   }
   else if(rcvr_type == SS_RCVR) {
      old_width = (int) ss_pps_width;
      ss_pps_width = (int) (duty*1000.0);
      set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 4);
      ss_pps_width = (double) old_width;
      request_pps_info();
   }
   else if(rcvr_type == TM4_RCVR) {
   }
   else if(rcvr_type == ZYFER_RCVR) {
   }
   else if((chan == 1) && ((rcvr_type == NVS_RCVR) || ((rcvr_type == VENUS_RCVR) && !saw_timing_msg)) ) {
      edit_error("Receiver does not support PPS2");
      return;
   }
   else if(freq < 0.0) {
      edit_error("Frequency must be >= 0.0");
      return;
   }
   else if(duty <= 0.0) {
      edit_error("Duty cycle / pulse width must be > 0.0");
      return;
   }
   else if(duty >= 1.0) {  // duty is a pulse width in microseconds (or nanoseconds)
      if(rcvr_type == ESIP_RCVR) duty = freq * (duty/1.0E9);  // convert nanoeconds to duty cycle
      else if(rcvr_type == NVS_RCVR) duty = freq * (duty/1.0E9);  // convert nanoeconds to duty cycle
      else duty = freq * (duty/1.0E6);  // convert microseconds to duty cycle
      if(duty >= 1.0) {
         edit_error("Pulse width too long for specified frequency");
         return;
      }
   }

   if(chan == 0) set_pps_freq(chan, freq, duty, pps_polarity, cable_delay, pps1_delay, 1);
   else          set_pps_freq(chan, freq, duty, 0,            cable_delay, pps2_delay, 1); // rising edge gggg
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq 0x30d0b2(%rip), %rax    # 0x33f2e0
cmpb $0x0, (%rax)
je 0x324a7
movl %edi, %ebx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x20(%rbp)
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, -0x18(%rbp)
leaq 0x1e6674(%rip), %r14    # 0x2188d0
movq (%r14), %rax
cmpq $0x20000, %rax          # imm = 0x20000
je 0x322b7
cmpq $0x800, %rax            # imm = 0x800
je 0x322cb
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
testl %ebx, %ebx
setne %dl
orb %cl, %dl
je 0x322cb
testl %ebx, %ebx
setne %cl
movabsq $0x800000000, %rdx      # imm = 0x800000000
cmpq %rdx, %rax
setne %dl
orb %cl, %dl
je 0x322cb
cmpq $0x100000, %rax         # imm = 0x100000
je 0x322cb
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
jne 0x324f2
leaq 0x30d022(%rip), %rdi    # 0x33f2e0
leaq 0x100fab(%rip), %rsi    # 0x133270
leaq -0x20(%rbp), %rdx
jmp 0x322dd
leaq 0x30d00e(%rip), %rdi    # 0x33f2e0
leaq 0x100f97(%rip), %rsi    # 0x133270
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x9360
movq (%r14), %rax
cmpq $0x20000, %rax          # imm = 0x20000
jne 0x32320
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
testl %ebx, %ebx
je 0x323b9
leaq 0x2dbac0(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm2
leaq 0x2dbacd(%rip), %rax    # 0x30dde0
movsd (%rax), %xmm3
movl %ebx, %edi
xorl %esi, %esi
jmp 0x323da
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
testl %ebx, %ebx
setne %dl
orb %cl, %dl
jne 0x323e9
movsd -0x18(%rbp), %xmm0
movsd 0xd6d2b(%rip), %xmm1    # 0x109070
ucomisd %xmm0, %xmm1
ja 0x3249b
ucomisd 0xd95f1(%rip), %xmm0    # 0x10b948
ja 0x3249b
leaq 0x2dba0c(%rip), %rbx    # 0x30dd70
cvttsd2si %xmm0, %eax
movl (%rbx), %r14d
movl %eax, (%rbx)
leaq 0x2db9ad(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2db99a(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2dba40(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm0
leaq 0x2dba45(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2db97e(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl $0x4, %edx
callq 0x6add8
movl %r14d, (%rbx)
callq 0x6ab01
jmp 0x324a7
leaq 0x2db958(%rip), %rax    # 0x30dd18
movl (%rax), %esi
leaq 0x2db9ff(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm2
leaq 0x2dba04(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm3
xorl %edi, %edi
movl $0x1, %edx
callq 0x94e4c
jmp 0x324a7
cmpq $0x100000, %rax         # imm = 0x100000
je 0x322ef
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x322ef
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x324b0
leaq 0x2db986(%rip), %r14    # 0x30dda8
movsd -0x18(%rbp), %xmm0
mulsd 0xd6c09(%rip), %xmm0    # 0x109038
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd (%r14), %xmm1
movaps %xmm1, -0x30(%rbp)
movlps %xmm0, (%r14)
leaq 0x2db8d6(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2db8c3(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2db969(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm0
leaq 0x2db96e(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2db8a7(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl $0x4, %edx
callq 0x6add8
cvttpd2dq -0x30(%rbp), %xmm0
cvtdq2pd %xmm0, %xmm0
movlpd %xmm0, (%r14)
callq 0x6ab01
jmp 0x322ef
leaq 0xe2cd9(%rip), %rdi     # 0x11517b
callq 0x23027
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1, %ebx
jne 0x324da
cmpq $0x800, %rax            # imm = 0x800
je 0x324d1
cmpq $0x80, %rax
jne 0x324da
leaq 0x2daf5c(%rip), %rcx    # 0x30d428
cmpl $0x0, (%rcx)
jne 0x324da
leaq 0xe2cc2(%rip), %rdi     # 0x11519a
jmp 0x324a2
movsd -0x20(%rbp), %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x32514
leaq 0xe2cc9(%rip), %rdi     # 0x1151b9
jmp 0x324a2
leaq 0x30cde7(%rip), %rdi    # 0x33f2e0
leaq 0x100d6c(%rip), %rsi    # 0x13326c
leaq -0x20(%rbp), %rdx
leaq -0x18(%rbp), %rcx
xorl %eax, %eax
callq 0x9360
jmp 0x322e4
movsd -0x18(%rbp), %xmm1
ucomisd %xmm1, %xmm2
jae 0x32549
ucomisd 0xd6b49(%rip), %xmm1    # 0x109070
jb 0x322ef
cmpq $0x800, %rax            # imm = 0x800
je 0x3253f
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x32555
divsd 0xd6ae1(%rip), %xmm1    # 0x109028
jmp 0x3255d
leaq 0xe2c82(%rip), %rdi     # 0x1151d2
jmp 0x324a2
divsd 0xd6af3(%rip), %xmm1    # 0x109050
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
ucomisd 0xd6b02(%rip), %xmm0    # 0x109070
jb 0x322ef
leaq 0xe2c7e(%rip), %rdi     # 0x1151f9
jmp 0x324a2