// File: /workspace/github_cpp_makefile_star2_O1/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 0x30d265(%rip), %rax    # 0x33f2e0
cmpb $0x0, (%rax)
je 0x322f4
movl %edi, %ebx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x20(%rbp)
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, -0x18(%rbp)
leaq 0x1e6827(%rip), %r14    # 0x2188d0
movq (%r14), %rax
cmpq $0x20000, %rax          # imm = 0x20000
je 0x32104
cmpq $0x800, %rax            # imm = 0x800
je 0x32118
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
testl %ebx, %ebx
setne %dl
orb %cl, %dl
je 0x32118
testl %ebx, %ebx
setne %cl
movabsq $0x800000000, %rdx      # imm = 0x800000000
cmpq %rdx, %rax
setne %dl
orb %cl, %dl
je 0x32118
cmpq $0x100000, %rax         # imm = 0x100000
je 0x32118
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
jne 0x3233f
leaq 0x30d1d5(%rip), %rdi    # 0x33f2e0
leaq 0x10106e(%rip), %rsi    # 0x133180
leaq -0x20(%rbp), %rdx
jmp 0x3212a
leaq 0x30d1c1(%rip), %rdi    # 0x33f2e0
leaq 0x10105a(%rip), %rsi    # 0x133180
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x9360
movq (%r14), %rax
cmpq $0x20000, %rax          # imm = 0x20000
jne 0x3216d
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
testl %ebx, %ebx
je 0x32206
leaq 0x2dbc73(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm2
leaq 0x2dbc80(%rip), %rax    # 0x30dde0
movsd (%rax), %xmm3
movl %ebx, %edi
xorl %esi, %esi
jmp 0x32227
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
setne %cl
testl %ebx, %ebx
setne %dl
orb %cl, %dl
jne 0x32236
movsd -0x18(%rbp), %xmm0
movsd 0xd6ede(%rip), %xmm1    # 0x109070
ucomisd %xmm0, %xmm1
ja 0x322e8
ucomisd 0xd979c(%rip), %xmm0    # 0x10b940
ja 0x322e8
leaq 0x2dbbbf(%rip), %rbx    # 0x30dd70
cvttsd2si %xmm0, %eax
movl (%rbx), %r14d
movl %eax, (%rbx)
leaq 0x2dbb60(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2dbb4d(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2dbbf3(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm0
leaq 0x2dbbf8(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2dbb31(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl $0x4, %edx
callq 0x6ad1d
movl %r14d, (%rbx)
callq 0x6a9e7
jmp 0x322f4
leaq 0x2dbb0b(%rip), %rax    # 0x30dd18
movl (%rax), %esi
leaq 0x2dbbb2(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm2
leaq 0x2dbbb7(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm3
xorl %edi, %edi
movl $0x1, %edx
callq 0x94dc8
jmp 0x322f4
cmpq $0x100000, %rax         # imm = 0x100000
je 0x3213c
movabsq $0x400000000, %rcx      # imm = 0x400000000
cmpq %rcx, %rax
je 0x3213c
movabsq $0x800000000, %rcx      # imm = 0x800000000
cmpq %rcx, %rax
jne 0x322fd
leaq 0x2dbb39(%rip), %r14    # 0x30dda8
movsd -0x18(%rbp), %xmm0
mulsd 0xd6dbc(%rip), %xmm0    # 0x109038
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd (%r14), %xmm1
movaps %xmm1, -0x30(%rbp)
movlps %xmm0, (%r14)
leaq 0x2dba89(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2dba76(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2dbb1c(%rip), %rax    # 0x30ddc8
movsd (%rax), %xmm0
leaq 0x2dbb21(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2dba5a(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl $0x4, %edx
callq 0x6ad1d
cvttpd2dq -0x30(%rbp), %xmm0
cvtdq2pd %xmm0, %xmm0
movlpd %xmm0, (%r14)
callq 0x6a9e7
jmp 0x3213c
leaq 0xe2df8(%rip), %rdi     # 0x1150e7
callq 0x2326e
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1, %ebx
jne 0x32327
cmpq $0x800, %rax            # imm = 0x800
je 0x3231e
cmpq $0x80, %rax
jne 0x32327
leaq 0x2db10f(%rip), %rcx    # 0x30d428
cmpl $0x0, (%rcx)
jne 0x32327
leaq 0xe2de1(%rip), %rdi     # 0x115106
jmp 0x322ef
movsd -0x20(%rbp), %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x32361
leaq 0xe2de8(%rip), %rdi     # 0x115125
jmp 0x322ef
leaq 0x30cf9a(%rip), %rdi    # 0x33f2e0
leaq 0x100e2f(%rip), %rsi    # 0x13317c
leaq -0x20(%rbp), %rdx
leaq -0x18(%rbp), %rcx
xorl %eax, %eax
callq 0x9360
jmp 0x32131
movsd -0x18(%rbp), %xmm1
ucomisd %xmm1, %xmm2
jae 0x32396
ucomisd 0xd6cfc(%rip), %xmm1    # 0x109070
jb 0x3213c
cmpq $0x800, %rax            # imm = 0x800
je 0x3238c
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jne 0x323a2
divsd 0xd6c94(%rip), %xmm1    # 0x109028
jmp 0x323aa
leaq 0xe2da1(%rip), %rdi     # 0x11513e
jmp 0x322ef
divsd 0xd6ca6(%rip), %xmm1    # 0x109050
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
ucomisd 0xd6cb0(%rip), %xmm0    # 0x109070
jb 0x3213c
leaq 0xe2d98(%rip), %rdi     # 0x115165
jmp 0x322ef