// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: set_traim_mode(int, int)
void set_traim_mode(int thresh, int save)
{
int old_thresh;

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

   if(rcvr_type == FURUNO_RCVR) {
      if(thresh <= 0) thresh = 0;
      else            thresh = 1;
      if(pps_enabled) sprintf(out, "GPrrs,%d,%d,%d", thresh,furuno_traim,2);
      else            sprintf(out, "GPrrs,%d,%d,%d", thresh,furuno_traim,0);
      send_furuno_cmd(out);
      send_furuno_cmd("GPrrq");
   }
   else if(rcvr_type == MOTO_RCVR) {
      if(thresh <= 0) {  // 12-channel disable traim
         send_moto_start("Ge");
         send_byte(0);
         send_moto_end();
      }
      else {  // 12-channel enable traim
         send_moto_start("Gf");
         send_word(thresh);
         send_moto_end();

         send_moto_start("Ge");
         send_byte(1);
         send_moto_end();
      }

      // 6/8 channel traim control
      old_thresh = traim_threshold;
      traim_threshold = thresh;
      set_pps(pps_mode, pps_polarity, delay_value, pps1_delay, pps_threshold, save);
      traim_threshold = old_thresh;
set_pps_mode(pps_rate);
   }
   else if(rcvr_type == NVS_RCVR) { 
      send_nvs_start(0xD7);
      send_byte(0x07);
      send_word(thresh);
      send_nvs_end();

      request_pps_info();
   }
   else if(rcvr_type == RFTG_RCVR) {
      if(thresh <= 0) set_rftg_traim(0);
      else            set_rftg_traim(1);
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      if(thresh < 0) thresh = 0;
      set_zod_config(0, 0.0,0.0,0.0, thresh, 6);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x2bcecc(%rip), %rax    # 0x32101a
leaq 0x1c4de9(%rip), %rcx    # 0x228f3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x641f9
movl %edi, %ebx
leaq 0x19e768(%rip), %rax    # 0x2028d0
movq (%rax), %rax
cmpq $0x20, %rax
je 0x64258
cmpq $0x100, %rax            # imm = 0x100
je 0x64202
cmpq $0x800, %rax            # imm = 0x800
je 0x6422c
cmpq $0x400000, %rax         # imm = 0x400000
je 0x64223
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x641f9
xorl %edx, %edx
testl %ebx, %ebx
setg %dl
leaq 0x293b71(%rip), %rax    # 0x2f7d20
xorl %r8d, %r8d
cmpb $0x0, (%rax)
setne %r8b
leaq 0x2c30dc(%rip), %rax    # 0x32729c
movl (%rax), %ecx
addl %r8d, %r8d
leaq 0x2c2054(%rip), %rbx    # 0x326220
leaq 0xa6dc7(%rip), %rsi     # 0x10af9a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x578d5
leaq 0xa6b14(%rip), %rdi     # 0x10ad00
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x578d5
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edi, %edi
movl %ebx, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5faee
testl %ebx, %ebx
jle 0x6427d
pushq $0x1
popq %rdi
jmp 0x6427f
movl $0xd7, %edi
callq 0x5707f
pushq $0x7
popq %rdi
callq 0x523f2
movzwl %bx, %edi
callq 0x52599
callq 0x57171
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x61bf1
movl %esi, %r14d
testl %ebx, %ebx
jle 0x6428c
leaq 0xa7099(%rip), %rdi     # 0x10b2ff
callq 0x59a28
movzwl %bx, %edi
callq 0x52599
callq 0x59aab
movb $0x1, %r15b
jmp 0x6428f
xorl %edi, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6430d
xorl %r15d, %r15d
leaq 0xa7066(%rip), %rdi     # 0x10b2fc
callq 0x59a28
movzbl %r15b, %edi
callq 0x523f2
callq 0x59aab
leaq 0x1a0e14(%rip), %r15    # 0x2050c4
movl (%r15), %r12d
movl %ebx, (%r15)
leaq 0x293a65(%rip), %rax    # 0x2f7d22
movzbl (%rax), %edi
leaq 0x293a51(%rip), %rax    # 0x2f7d18
movzbl (%rax), %esi
leaq 0x293aef(%rip), %rax    # 0x2f7dc0
movsd (%rax), %xmm0
leaq 0x293afc(%rip), %rax    # 0x2f7dd8
movsd (%rax), %xmm1
leaq 0x293a35(%rip), %rax    # 0x2f7d1c
movss (%rax), %xmm2
movl %r14d, %edx
callq 0x61e97
movl %r12d, (%r15)
leaq 0x293a26(%rip), %rax    # 0x2f7d23
movzbl (%rax), %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6327d