// File: /workspace/github_cpp_makefile_star2_O1/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 0x2c9b56(%rip), %rax    # 0x33701a
leaq 0x1d1a73(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x6d594
movl %edi, %ebx
leaq 0x1ab3f2(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x7ff, %rax            # imm = 0x7FF
jle 0x6d565
cmpq $0x800, %rax            # imm = 0x800
je 0x6d59d
cmpq $0x400000, %rax         # imm = 0x400000
je 0x6d5cb
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x6d594
xorl %edx, %edx
testl %ebx, %ebx
setg %dl
leaq 0x2a0805(%rip), %rax    # 0x30dd20
xorl %r8d, %r8d
cmpb $0x0, (%rax)
setne %r8b
leaq 0x2cfd70(%rip), %rax    # 0x33d29c
movl (%rax), %ecx
addl %r8d, %r8d
leaq 0x2cece8(%rip), %rbx    # 0x33c220
leaq 0xb3a33(%rip), %rsi     # 0x120f72
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5f070
leaq 0xb3780(%rip), %rdi     # 0x120cd8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5f070
cmpq $0x20, %rax
je 0x6d5d6
cmpq $0x100, %rax            # imm = 0x100
jne 0x6d594
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 0x683cd
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0xd7, %edi
callq 0x5e740
movl $0x7, %edi
callq 0x591af
movzwl %bx, %edi
callq 0x5936c
callq 0x5e844
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6a9e7
testl %ebx, %ebx
jle 0x6d5fb
movl $0x1, %edi
jmp 0x6d5fd
movl %esi, %r14d
testl %ebx, %ebx
jle 0x6d60a
leaq 0xb3cf3(%rip), %rdi     # 0x1212d7
callq 0x61694
movzwl %bx, %edi
callq 0x5936c
callq 0x6170f
movb $0x1, %r15b
jmp 0x6d60d
xorl %edi, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6d68b
xorl %r15d, %r15d
leaq 0xb3cc0(%rip), %rdi     # 0x1212d4
callq 0x61694
movzbl %r15b, %edi
callq 0x591af
callq 0x6170f
leaq 0x1ada96(%rip), %r15    # 0x21b0c4
movl (%r15), %r12d
movl %ebx, (%r15)
leaq 0x2a06e7(%rip), %rax    # 0x30dd22
movzbl (%rax), %edi
leaq 0x2a06d3(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2a0771(%rip), %rax    # 0x30ddc0
movsd (%rax), %xmm0
leaq 0x2a077e(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2a06b7(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl %r14d, %edx
callq 0x6ad1d
movl %r12d, (%r15)
leaq 0x2a06a8(%rip), %rax    # 0x30dd23
movzbl (%rax), %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6c31c