// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: send_byte(unsigned char)
void send_byte(u08 val)
{
   // send a byte to the receiver and update the message checksum
   // NEW_RCVR
   if(log_file && (log_stream & LOG_PACKET_START)) {
      if(superpacket) fprintf(log_file, "Superpacket:    %02X\n", val);
   }
   if(log_file && (log_stream & LOG_SENT_DATA) && sts) fprintf(log_file, "{%02X} ", val);

   superpacket = 0;

   sendout(RCVR_PORT, val, eom_flag);  
   ++tsip_send_count;

   nmea_tx_cksum ^= val;  // we always update these since we may need to send
   moto_tx_cksum ^= val;  // ... messaages in these formats to wake up other receivers
   venus_tx_cksum ^= val;
   sirf_tx_cksum += val;
   ss_tx_cksum += val;
   rt17_tx_cksum += val;

   if(rcvr_type == TSIP_RCVR) {
      if(val == DLE) {  // we are sending a TSIP message
         sendout(RCVR_PORT, DLE, eom_flag);  // DLE character must be sent twice
         ++tsip_send_count;
      }
   }
   else if(rcvr_type == NVS_RCVR) {
      nvs_tx_crc = calc_nvs_crc(nvs_tx_crc, val);
      if(val == DLE) {  // we are sending a TSIP message
         nvs_tx_crc = calc_nvs_crc(nvs_tx_crc, DLE);
         sendout(RCVR_PORT, DLE, eom_flag);  // DLE character must be sent twice
         ++tsip_send_count;
      }
   }
   else if(rcvr_type == UBX_RCVR) { // sending ublox ubx message
      ubx_txa += val;    // add byte to message checksums
      ubx_txb += ubx_txa;
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      if(zodiac_tx_cnt & 1) zodiac_tx_cksum += ( (((u16) val) * 256) + zodiac_low_byte );
      else zodiac_low_byte = (u16) val;
      ++zodiac_tx_cnt;
   }

   eom_flag = ADD_CHAR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebx
leaq 0x1e5255(%rip), %r12    # 0x23e360
movq (%r12), %rdi
movzbl %bl, %r14d
testq %rdi, %rdi
je 0x59168
leaq 0x1e52f1(%rip), %r15    # 0x23e410
testb $0x4, (%r15)
je 0x59148
cmpb $0x0, 0x316ee4(%rip)    # 0x370010
je 0x59148
leaq 0xc710f(%rip), %rsi     # 0x120244
movl %r14d, %edx
xorl %eax, %eax
callq 0x9560
movq (%r12), %rdi
testq %rdi, %rdi
je 0x59168
testb $0x10, (%r15)
je 0x59168
cmpl $0x0, 0x316ebf(%rip)    # 0x370014
je 0x59168
leaq 0xc70fc(%rip), %rsi     # 0x12025a
movl %r14d, %edx
xorl %eax, %eax
callq 0x9560
movb $0x0, 0x316ea1(%rip)    # 0x370010
movl 0x312c9b(%rip), %edx    # 0x36be10
movl $0xa, %edi
movl %r14d, %esi
callq 0xbcaa
incl 0x312c90(%rip)          # 0x36be18
xorb %r14b, 0x313927(%rip)   # 0x36cab6
xorb %r14b, 0x31392d(%rip)   # 0x36cac3
xorb %r14b, 0x313936(%rip)   # 0x36cad3
addw %r14w, 0x31394f(%rip)   # 0x36caf4
addw %r14w, 0x31390f(%rip)   # 0x36cabc
addb %r14b, 0x31390c(%rip)   # 0x36cac0
leaq 0x1bf715(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0xff, %rax
jg 0x591ed
cmpq $0x1, %rax
je 0x59248
cmpq $0x4, %rax
jne 0x5929d
addb 0x31389c(%rip), %bl     # 0x36ca78
movb %bl, 0x313896(%rip)     # 0x36ca78
addb %bl, 0x313891(%rip)     # 0x36ca79
jmp 0x5929d
cmpq $0x100, %rax            # imm = 0x100
je 0x5926a
cmpq $0x800, %rax            # imm = 0x800
jne 0x5929d
movzwl 0x3138fc(%rip), %edx    # 0x36cb04
movl %edx, %eax
shrl $0x8, %eax
movzwl %r14w, %ecx
xorl %eax, %ecx
shll $0x8, %edx
leaq 0x111163(%rip), %rax    # 0x16a380
movzwl (%rax,%rcx,2), %ecx
xorl %ecx, %edx
movw %dx, 0x3138da(%rip)     # 0x36cb04
cmpb $0x10, %bl
jne 0x5929d
movzwl %dx, %edx
shrl $0x8, %edx
xorl $0x10, %edx
shll $0x8, %ecx
xorw (%rax,%rdx,2), %cx
movw %cx, 0x3138be(%rip)     # 0x36cb04
jmp 0x5924d
cmpb $0x10, %bl
jne 0x5929d
movl 0x312bbd(%rip), %edx    # 0x36be10
movl $0xa, %edi
movl $0x10, %esi
callq 0xbcaa
incl 0x312bb0(%rip)          # 0x36be18
jmp 0x5929d
movzwl 0x3138a7(%rip), %eax    # 0x36cb18
testb $0x1, %al
jne 0x5927f
movw %r14w, 0x3138b7(%rip)   # 0x36cb34
jmp 0x59294
movzwl %r14w, %ecx
shll $0x8, %ecx
addw 0x3138a7(%rip), %cx     # 0x36cb34
addw %cx, 0x313886(%rip)     # 0x36cb1a
incl %eax
movw %ax, 0x31387b(%rip)     # 0x36cb18
movl $0x0, 0x312b69(%rip)    # 0x36be10
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq