// File: /workspace/github_cpp_makefile_star2_O3/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
subq $0x10, %rsp
leaq 0x2c9c90(%rip), %rax    # 0x33701a
leaq 0x1d1bad(%rip), %rcx    # 0x23ef3e
movb (%rcx), %cl
orb (%rax), %cl
jne 0x6d46a
movl %edi, %ebx
leaq 0x1ab52c(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0x7ff, %rax            # imm = 0x7FF
jle 0x6d433
cmpq $0x800, %rax            # imm = 0x800
je 0x6d477
cmpq $0x400000, %rax         # imm = 0x400000
je 0x6d4d0
cmpq $0x20000000, %rax       # imm = 0x20000000
jne 0x6d46a
xorl %edx, %edx
testl %ebx, %ebx
setg %dl
leaq 0x2a093b(%rip), %rax    # 0x30dd20
xorl %r8d, %r8d
cmpb $0x0, (%rax)
setne %r8b
leaq 0x2cfea6(%rip), %rax    # 0x33d29c
movl (%rax), %ecx
addl %r8d, %r8d
leaq 0x2cee1e(%rip), %rbx    # 0x33c220
leaq 0xb3c49(%rip), %rsi     # 0x121052
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
callq 0x5eff8
leaq 0xb3996(%rip), %rdi     # 0x120db8
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5eff8
cmpq $0x20, %rax
je 0x6d4db
cmpq $0x100, %rax            # imm = 0x100
jne 0x6d46a
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorl %edi, %edi
movl %ebx, %esi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x68563
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0xd7, %edi
callq 0x5e6be
movl $0x7, %edi
callq 0x590f7
movw %bx, -0x24(%rbp)
leaq 0x1ab33e(%rip), %rbx    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%rbx)
sete %al
movzbl -0x24(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%rbx)
setne %al
movzbl -0x24(%rbp,%rax), %edi
callq 0x590f7
callq 0x5e7c0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6ab01
testl %ebx, %ebx
jle 0x6d529
movl $0x1, %edi
jmp 0x6d52b
movl %esi, %r14d
testl %ebx, %ebx
jle 0x6d53c
leaq 0xb3ece(%rip), %rdi     # 0x1213b7
callq 0x6160d
movw %bx, -0x22(%rbp)
leaq 0x1ab2db(%rip), %r15    # 0x2187d4
xorl %eax, %eax
cmpb $0x0, (%r15)
sete %al
movzbl -0x22(%rbp,%rax), %edi
callq 0x590f7
xorl %eax, %eax
cmpb $0x0, (%r15)
setne %al
movzbl -0x22(%rbp,%rax), %edi
callq 0x590f7
callq 0x61688
movb $0x1, %r15b
jmp 0x6d53f
xorl %edi, %edi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6d5c1
xorl %r15d, %r15d
leaq 0xb3e6e(%rip), %rdi     # 0x1213b4
callq 0x6160d
movzbl %r15b, %edi
callq 0x590f7
callq 0x61688
leaq 0x1adb64(%rip), %r15    # 0x21b0c4
movl (%r15), %r12d
movl %ebx, (%r15)
leaq 0x2a07b5(%rip), %rax    # 0x30dd22
movzbl (%rax), %edi
leaq 0x2a07a1(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2a083f(%rip), %rax    # 0x30ddc0
movsd (%rax), %xmm0
leaq 0x2a084c(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2a0785(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
movl %r14d, %edx
callq 0x6add8
movl %r12d, (%r15)
leaq 0x2a0776(%rip), %rax    # 0x30dd23
movzbl (%rax), %edi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6c3a7