// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: sendout(unsigned int, unsigned char, int)
void sendout(unsigned port, unsigned char val, int eom_flag)
{
unsigned long written;
int flag;
static long x = 0;

   // Ssend data to the receiver.
   // We queue up data until end of message to reduce per-packet overhead.
   // If eom_flag == FLUSH_COM then send buffered chars without adding a new one
   // If eom_flag == 0, add char to buffer (sends buffer if full)
   // If eom_flag != 0, add char to buffer and send buffer

   if((port == RCVR_PORT) && (rcvr_type == NO_RCVR) && (enable_terminal == 0)) { // alternate ready/not ready each check
      return;
   }
if((port == RCVR_PORT) && (rcvr_type == TIDE_RCVR) && (enable_terminal == 0)) {
      return;
}

   if(com[port].com_fd < 0) return;

   if(com[port].process_com == 0) return;
   if(com[port].com_error & XMIT_ERR) return;
   if(just_read && (port == RCVR_PORT)) return;
   if(no_send && (port == RCVR_PORT)) return;
   if(sim_file) return;  // don't send anything out if reading a simulation file

   if(FAKE_ACRON_RCVR && (rcvr_type == ACRON_RCVR) && (port == RCVR_PORT)) {  // simulate echo by sticking char in rcv buffer
      com[port].rcv_buffer[com[port].next_rcv_byte] = val;
      ++com[port].rcv_byte_count;
      return;
   }

   if((zoom_screen == 'O') && (port == monitor_port)) {  // echo data to "terminal" monitor screen
      echo_term(port, (unsigned) val, monitor_hex, 1);
   }

   // we buffer up output chars until buffer full or end of message flag seen
   if(eom_flag == FLUSH_COM) {  // just send buffered chars
      if(x == 0) return;   // nothing to flush
   }
   else com[port].xmit_buffer[x++] = val;  // add char to send buffer

   if((x < (long) XMIT_BUF_SIZE) && (eom_flag == ADD_CHAR)) return;

   update_pwm();   // if doing pwm temperature control

   if(1 || (com[port].com_port != 0) || (com[port].usb_port != 0)) {   // zork COM port in use: send bytes via serial port
      flag = write(com[port].com_fd, com[port].xmit_buffer, x);
if((eom_flag == EOM) || (eom_flag == FLUSH_COM)) {
   fsync(com[port].com_fd);
}
      if(flag == x) written = 1;
      else          written = 0;
   }

   x = 0;

   if((flag == 0) || (written != 1)) {
      if(com_error_exit) {
         error_exit(3, "Serial transmit error");
      }
      else {
         com[port].com_error |= XMIT_ERR;
         ++com_errors;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %r14d
cmpl $0xa, %edi
sete %cl
movq 0x20cc0a(%rip), %rax    # 0x2188d0
cmpq $0x400, %rax            # imm = 0x400
sete %dl
andb %cl, %dl
movl 0x233259(%rip), %ecx    # 0x23ef30
testl %ecx, %ecx
sete %sil
testb %sil, %dl
jne 0xbd39
testl %ecx, %ecx
sete %cl
cmpl $0xa, %edi
sete %dl
cmpq $0x800000, %rax         # imm = 0x800000
sete %al
andb %dl, %al
testb %cl, %al
jne 0xbd39
movl %edi, %eax
imulq $0x2260, %rax, %rax     # imm = 0x2260
leaq 0x3025d4(%rip), %r15    # 0x30e2e0
cmpl $0x0, 0x8(%rax,%r15)
js 0xbd39
addq %rax, %r15
cmpl $0x0, 0x2234(%r15)
je 0xbd39
testb $0x2, 0x2251(%r15)
jne 0xbd39
cmpl $0xa, %edi
jne 0xbd44
cmpb $0x0, 0x32b2e1(%rip)    # 0x337018
je 0xbd44
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0xa, %edi
sete %al
cmpb $0x0, 0x32b2c8(%rip)    # 0x337019
setne %cl
testb %cl, %al
jne 0xbd39
cmpq $0x0, 0x232660(%rip)    # 0x23e3c0
jne 0xbd39
cmpb $0x4f, 0x300a3f(%rip)   # 0x30c7a8
jne 0xbd87
cmpl %edi, 0x30255f(%rip)    # 0x30e2d0
jne 0xbd87
movzbl %r14b, %esi
movl 0x2326c7(%rip), %edx    # 0x23e444
movl $0x1, %ecx
callq 0xac18
cmpl $0x2, %ebx
jne 0xbd98
cmpq $0x0, 0x3341b4(%rip)    # 0x33ff48
jne 0xbdc8
jmp 0xbd39
movq 0x3341a9(%rip), %rax    # 0x33ff48
leaq 0x1(%rax), %rcx
movq %rcx, 0x33419e(%rip)    # 0x33ff48
movb %r14b, 0x220(%r15,%rax)
cmpq $0xfff, %rax            # imm = 0xFFF
setl %al
testl %ebx, %ebx
sete %cl
testb %al, %cl
jne 0xbd39
callq 0xd1efe
movl 0x8(%r15), %edi
leaq 0x220(%r15), %rsi
movq 0x334169(%rip), %rdx    # 0x33ff48
callq 0x90f0
movq %rax, %r14
decl %ebx
cmpl $0x1, %ebx
ja 0xbdf7
movl 0x8(%r15), %edi
callq 0x9300
movq 0x33414a(%rip), %rax    # 0x33ff48
movq $0x0, 0x33413f(%rip) # 0x33ff48
testl %r14d, %r14d
je 0xbe1a
movslq %r14d, %rcx
cmpq %rax, %rcx
je 0xbd39
cmpb $0x0, 0x20f412(%rip)    # 0x21b233
je 0xbe3e
leaq 0xfdc9a(%rip), %rsi     # 0x109ac4
movl $0x3, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xb424
orb $0x2, 0x2251(%r15)
incl 0x32b1c8(%rip)          # 0x337014
jmp 0xbd39