// File: /workspace/github_cpp_makefile_star2_O1/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:
leaq 0x2df2fd(%rip), %rcx    # 0x338254
movzwl (%rcx), %eax
leaq 0x2df2f1(%rip), %rsi    # 0x338252
cmpw (%rsi), %ax
je 0x58f71
leaq 0x1e6003(%rip), %rax    # 0x23ef70
orb $0x10, 0x1(%rax)
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x1e5fee(%rip), %r14    # 0x23ef70
movl (%r14), %edx
testl %edx, %edx
je 0x5917f
leaq 0x2e328c(%rip), %rbx    # 0x33c220
leaq 0xc7166(%rip), %rsi     # 0x120101
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movl (%r14), %r14d
testb $0x8, %r14b
je 0x58fc5
movq %rbx, %rdi
callq 0x9120
movl $0x74796220, (%rbx,%rax) # imm = 0x74796220
movl $0x206574, 0x3(%rbx,%rax) # imm = 0x206574
testb $0x10, %r14b
je 0x58fe2
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 0x58ffe
movq %rbx, %rdi
callq 0x9120
movq %r15, (%rbx,%rax)
testb $0x40, %r14b
je 0x5901a
movq %rbx, %rdi
callq 0x9120
movabsq $0x2074616f6c6620, %rcx # imm = 0x2074616F6C6620
movq %rcx, (%rbx,%rax)
testb %r14b, %r14b
jns 0x5903a
movq %rbx, %rdi
callq 0x9120
movabsq $0x20656c62756f6420, %rcx # imm = 0x20656C62756F6420
movq %rcx, (%rbx,%rax)
movb $0x0, 0x8(%rbx,%rax)
btl $0x8, %r14d
jae 0x59054
movq %rbx, %rdi
callq 0x9120
addq $0x1000, %r15           # imm = 0x1000
movq %r15, (%rbx,%rax)
btl $0x9, %r14d
jae 0x59072
movq %rbx, %rdi
callq 0x9120
movl $0x38706620, (%rbx,%rax) # imm = 0x38706620
movl $0x203038, 0x3(%rbx,%rax) # imm = 0x203038
btl $0xa, %r14d
jae 0x5908f
movq %rbx, %rdi
callq 0x9120
movl $0x4e414e20, (%rbx,%rax) # imm = 0x4E414E20
movw $0x20, 0x4(%rbx,%rax)
btl $0xb, %r14d
jae 0x590b4
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 0x590d8
movq %rbx, %rdi
callq 0x9120
movabsq $0x72726520646e6520, %rcx # imm = 0x72726520646E6520
movq %rcx, (%rbx,%rax)
movw $0x20, 0x8(%rbx,%rax)
btl $0xd, %r14d
jae 0x590f5
movq %rbx, %rdi
callq 0x9120
movl $0x6c6f6520, (%rbx,%rax) # imm = 0x6C6F6520
movw $0x20, 0x4(%rbx,%rax)
btl $0xe, %r14d
jae 0x59112
movq %rbx, %rdi
callq 0x9120
movabsq $0x206d75736b6320, %rcx # imm = 0x206D75736B6320
movq %rcx, (%rbx,%rax)
testw %r14w, %r14w
jns 0x5912f
movq %rbx, %rdi
callq 0x9120
movl $0x66766f20, (%rbx,%rax) # imm = 0x66766F20
movl $0x206c66, 0x3(%rbx,%rax) # imm = 0x206C66
movq %rbx, %rdi
callq 0x9120
leaq 0x1e52e2(%rip), %rcx    # 0x23e420
cmpl $0x0, (%rcx)
movw $0xa, (%rbx,%rax)
setne %al
leaq 0x1e520f(%rip), %rcx    # 0x23e360
movq (%rcx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x59166
callq 0x9420
leaq 0x2e30b3(%rip), %rdi    # 0x33c220
callq 0x58e77
leaq 0x1e5e0f(%rip), %rax    # 0x23ef88
incl (%rax)
movb $0x1, %al
jmp 0x59187
xorl %eax, %eax
movw %ax, (%rsi)
movw %ax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq