// File: jkingan[P]ladyheather/heather.cpp
// Function: recover_com(unsigned int)
int recover_com(unsigned port)
{
    // attempt to restart a port after a receive timeout

   if(port >= NUM_COM_PORTS) return (-1);         // bad port number
   if(com[port].user_disabled_com)  return (-2);  // disabled port
   if(com[port].com_running <= 0) return (-3);    // port not init'd
   if(com[port].com_data_lost != DATA_LOSS_REINIT) return (-4);  // not timeout out or recovery failed
   if(com[port].com_recover == 0) return (-5);    // com recovery disabled on the port
   if(com[port].com_port || com[port].usb_port || com[port].IP_addr[0]) ;
   else return (-6); // port not assigned to a device or IP address

   com[port].com_data_lost = DATA_LOSS_NO_INIT;  // prevents futile re-init attempts
   if(com[port].process_com) {
      init_com(port, 3);
      return 1;
   }
   else {
      com[port].process_com = 2;
      if(com[port].com_running) {
         init_com(port, 4);
         return 2;
      }
   }
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
cmpl $0x13, -0x8(%rbp)
jb 0x2b75d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341d57(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2228(%rax)
je 0x2b788
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341d2c(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2230(%rax)
jg 0x2b7b3
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341d01(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movzbl 0x2250(%rax), %eax
cmpl $0x1, %eax
je 0x2b7e1
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341cd3(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2254(%rax)
jne 0x2b80c
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341ca8(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x2b862
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341c8d(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x2b862
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341c71(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpb $0x0, 0x10d(%rax)
je 0x2b864
jmp 0x2b870
movl $0xfffffffa, -0x4(%rbp) # imm = 0xFFFFFFFA
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341c44(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movb $0x2, 0x2250(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341c27(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2234(%rax)
je 0x2b8c2
movl -0x8(%rbp), %edi
movl $0x3, %esi
callq 0xc0e0
movl $0x1, -0x4(%rbp)
jmp 0x2b920
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341bf2(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x2, 0x2234(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x341bd2(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2230(%rax)
je 0x2b917
movl -0x8(%rbp), %edi
movl $0x4, %esi
callq 0xc0e0
movl $0x2, -0x4(%rbp)
jmp 0x2b920
jmp 0x2b919
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)