// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: check_tsip_end(unsigned char)
u08 check_tsip_end(u08 report_err)
{
   // handle the end of a TSIP message and check the error flags

   if(tsip_rptr != tsip_wptr) {  // we are not at the end of the message
      tsip_error |= END_ERROR;
   }
   if(tsip_error) {
      sprintf(out, "#     Bad packet. Err=%04X!", tsip_error);
      if(tsip_error & 0x08)   strcat(out, " byte ");
      if(tsip_error & 0x10)   strcat(out, " word ");
      if(tsip_error & 0x20)   strcat(out, " dword ");
      if(tsip_error & 0x40)   strcat(out, " float ");
      if(tsip_error & 0x80)   strcat(out, " double ");
      if(tsip_error & 0x100)  strcat(out, " tword ");
      if(tsip_error & 0x200)  strcat(out, " fp80 ");
      if(tsip_error & 0x400)  strcat(out, " NAN ");
      if(tsip_error & 0x800)  strcat(out, " range err ");
      if(tsip_error & 0x1000) strcat(out, " end err ");
      if(tsip_error & 0x2000) strcat(out, " eol ");
      if(tsip_error & 0x4000) strcat(out, " cksum ");
      if(tsip_error & 0x8000) strcat(out, " ovfl ");
      strcat(out, "\n");
      if(log_flush_mode && log_file) fflush(log_file);
      log_packet_id(out);

      ++bad_packets;
      return 1;
   }
   tsip_rptr = tsip_wptr = 0;
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x2df3a8(%rip), %rcx    # 0x338254
movzwl (%rcx), %eax
leaq 0x2df39c(%rip), %rsi    # 0x338252
leaq 0x1e60b3(%rip), %r14    # 0x23ef70
movl (%r14), %edx
cmpw (%rsi), %ax
jne 0x58ed6
testl %edx, %edx
jne 0x58edf
xorl %eax, %eax
movw %ax, (%rsi)
movw %ax, (%rcx)
jmp 0x590cf
orl $0x1000, %edx           # imm = 0x1000
movl %edx, (%r14)
leaq 0x2e333a(%rip), %rbx    # 0x33c220
leaq 0xc72f4(%rip), %rsi     # 0x1201e1
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movl (%r14), %r14d
testb $0x8, %r14b
je 0x58f17
movq %rbx, %rdi
callq 0x9120
movl $0x74796220, (%rbx,%rax) # imm = 0x74796220
movl $0x206574, 0x3(%rbx,%rax) # imm = 0x206574
testb $0x10, %r14b
je 0x58f34
movq %rbx, %rdi
callq 0x9120
movl $0x726f7720, (%rbx,%rax) # imm = 0x726F7720
movl $0x206472, 0x3(%rbx,%rax) # imm = 0x206472
movabsq $0x2064726f776420, %r15 # imm = 0x2064726F776420
testb $0x20, %r14b
je 0x58f50
movq %rbx, %rdi
callq 0x9120
movq %r15, (%rbx,%rax)
testb $0x40, %r14b
je 0x58f6c
movq %rbx, %rdi
callq 0x9120
movabsq $0x2074616f6c6620, %rcx # imm = 0x2074616F6C6620
movq %rcx, (%rbx,%rax)
testb %r14b, %r14b
jns 0x58f8c
movq %rbx, %rdi
callq 0x9120
movabsq $0x20656c62756f6420, %rcx # imm = 0x20656C62756F6420
movq %rcx, (%rbx,%rax)
movb $0x0, 0x8(%rbx,%rax)
btl $0x8, %r14d
jae 0x58fa6
movq %rbx, %rdi
callq 0x9120
addq $0x1000, %r15           # imm = 0x1000
movq %r15, (%rbx,%rax)
btl $0x9, %r14d
jae 0x58fc4
movq %rbx, %rdi
callq 0x9120
movl $0x38706620, (%rbx,%rax) # imm = 0x38706620
movl $0x203038, 0x3(%rbx,%rax) # imm = 0x203038
btl $0xa, %r14d
jae 0x58fe1
movq %rbx, %rdi
callq 0x9120
movl $0x4e414e20, (%rbx,%rax) # imm = 0x4E414E20
movw $0x20, 0x4(%rbx,%rax)
btl $0xb, %r14d
jae 0x59006
movq %rbx, %rdi
callq 0x9120
movabsq $0x652065676e617220, %rcx # imm = 0x652065676E617220
movq %rcx, (%rbx,%rax)
movl $0x207272, 0x8(%rbx,%rax) # imm = 0x207272
btl $0xc, %r14d
jae 0x5902a
movq %rbx, %rdi
callq 0x9120
movabsq $0x72726520646e6520, %rcx # imm = 0x72726520646E6520
movq %rcx, (%rbx,%rax)
movw $0x20, 0x8(%rbx,%rax)
btl $0xd, %r14d
jae 0x59047
movq %rbx, %rdi
callq 0x9120
movl $0x6c6f6520, (%rbx,%rax) # imm = 0x6C6F6520
movw $0x20, 0x4(%rbx,%rax)
btl $0xe, %r14d
jae 0x59064
movq %rbx, %rdi
callq 0x9120
movabsq $0x206d75736b6320, %rcx # imm = 0x206D75736B6320
movq %rcx, (%rbx,%rax)
testw %r14w, %r14w
jns 0x59081
movq %rbx, %rdi
callq 0x9120
movl $0x66766f20, (%rbx,%rax) # imm = 0x66766F20
movl $0x206c66, 0x3(%rbx,%rax) # imm = 0x206C66
movq %rbx, %rdi
callq 0x9120
leaq 0x1e5390(%rip), %rcx    # 0x23e420
cmpl $0x0, (%rcx)
movw $0xa, (%rbx,%rax)
setne %al
leaq 0x1e52bd(%rip), %rcx    # 0x23e360
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x590b8
callq 0x9420
leaq 0x2e3161(%rip), %rdi    # 0x33c220
callq 0x58dc2
leaq 0x1e5ebd(%rip), %rax    # 0x23ef88
incl (%rax)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq