// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_in.c
// Function: tcp_oos_insert_segment
static void
tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next)
{
  struct tcp_seg *old_seg;

  LWIP_ASSERT("tcp_oos_insert_segment: invalid cseg", cseg != NULL);

  if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) {
    /* received segment overlaps all following segments */
    tcp_segs_free(next);
    next = NULL;
  } else {
    /* delete some following segments
       oos queue may have segments with FIN flag */
    while (next &&
           TCP_SEQ_GEQ((seqno + cseg->len),
                       (next->tcphdr->seqno + next->len))) {
      /* cseg with FIN already processed */
      if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) {
        TCPH_SET_FLAG(cseg->tcphdr, TCP_FIN);
      }
      old_seg = next;
      next = next->next;
      tcp_seg_free(old_seg);
    }
    if (next &&
        TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) {
      /* We need to trim the incoming segment. */
      cseg->len = (u16_t)(next->tcphdr->seqno - seqno);
      pbuf_realloc(cseg->p, cseg->len);
    }
  }
  cseg->next = next;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x12898
jmp 0x12869
leaq 0x14a5c(%rip), %rdi     # 0x272cc
leaq 0x1611f(%rip), %rsi     # 0x28996
movl $0x42f, %edx            # imm = 0x42F
leaq 0x15d21(%rip), %rcx     # 0x285a4
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1289a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movzwl 0xc(%rax), %edi
callq 0x251c0
movzwl %ax, %eax
andl $0x3f, %eax
movzbl %al, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x128d2
movq -0x10(%rbp), %rdi
callq 0xbc50
movq $0x0, -0x10(%rbp)
jmp 0x129e9
jmp 0x128d4
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x19(%rbp)
je 0x12910
movl 0x1d05e(%rip), %eax     # 0x2f944
movq -0x8(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x4(%rcx), %ecx
movq -0x10(%rbp), %rdx
movzwl 0x10(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
cmpl $0x0, %eax
setge %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0x12919
jmp 0x1298f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movzwl 0xc(%rax), %edi
callq 0x251c0
movzwl %ax, %eax
andl $0x3f, %eax
movzbl %al, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1296e
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movzwl 0xc(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x1, %edi
callq 0x251c0
movw %ax, %cx
movl -0x20(%rbp), %eax
movzwl %cx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movw %cx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
callq 0xd7a0
jmp 0x128d4
cmpq $0x0, -0x10(%rbp)
je 0x129e7
movl 0x1cfa8(%rip), %eax     # 0x2f944
movq -0x8(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
subl 0x4(%rcx), %eax
cmpl $0x0, %eax
jle 0x129e7
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %eax
subl 0x1cf7d(%rip), %eax     # 0x2f944
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movzwl 0x10(%rax), %esi
callq 0x75a0
jmp 0x129e9
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)