// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/inet_chksum.c
// Function: inet_cksum_pseudo_partial_base
static u16_t
inet_cksum_pseudo_partial_base(struct pbuf *p, u8_t proto, u16_t proto_len,
                               u16_t chksum_len, u32_t acc)
{
  struct pbuf *q;
  int swapped = 0;
  u16_t chklen;

  /* iterate through all pbuf in chain */
  for (q = p; (q != NULL) && (chksum_len > 0); q = q->next) {
    LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n",
                             (void *)q, (void *)q->next));
    chklen = q->len;
    if (chklen > chksum_len) {
      chklen = chksum_len;
    }
    acc += LWIP_CHKSUM(q->payload, chklen);
    chksum_len = (u16_t)(chksum_len - chklen);
    LWIP_ASSERT("delete me", chksum_len < 0x7fff);
    /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/
    /* fold the upper bit down */
    acc = FOLD_U32T(acc);
    if (q->len % 2 != 0) {
      swapped = !swapped;
      acc = SWAP_BYTES_IN_WORD(acc);
    }
    /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/
  }

  if (swapped) {
    acc = SWAP_BYTES_IN_WORD(acc);
  }

  acc += (u32_t)lwip_htons((u16_t)proto);
  acc += (u32_t)lwip_htons(proto_len);

  /* Fold 32-bit sum to 16 bits
     calling this twice is probably faster than if statements... */
  acc = FOLD_U32T(acc);
  acc = FOLD_U32T(acc);
  LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc));
  return (u16_t)~(acc & 0xffffUL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebp
movl %ecx, %r15d
movl %edx, 0x14(%rsp)
testq %rdi, %rdi
sete %al
testl %ecx, %ecx
sete %cl
orb %al, %cl
jne 0x13aa8
movq %rdi, %r12
movl %esi, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl $0xffff, %ebx           # imm = 0xFFFF
movzwl 0x12(%r12), %r13d
cmpw %r15w, %r13w
movl %r13d, %r14d
cmovael %r15d, %r14d
movq 0x8(%r12), %rdi
movl %r14d, %esi
andl %ebx, %esi
callq 0x13790
subl %r14d, %r15d
movl %r15d, %ecx
andl %ebx, %ecx
cmpl $0x7fff, %ecx           # imm = 0x7FFF
jae 0x13ae5
movzwl %ax, %eax
addl %eax, %ebp
movl %ebp, %eax
shrl $0x10, %eax
movzwl %bp, %ebp
addl %eax, %ebp
testb $0x1, %r13b
je 0x13a84
xorl %eax, %eax
cmpl $0x0, 0xc(%rsp)
sete %al
rolw $0x8, %bp
movzwl %bp, %ebp
movl %eax, 0xc(%rsp)
testw %r15w, %r15w
je 0x13a93
movq (%r12), %r12
testq %r12, %r12
jne 0x13a26
movl %ebp, %eax
rolw $0x8, %ax
cmpl $0x0, 0xc(%rsp)
movzwl %ax, %eax
cmovnel %eax, %ebp
movl 0x10(%rsp), %esi
movzbl %sil, %edi
callq 0x135b4
movzwl %ax, %ebx
addl %ebp, %ebx
movzwl 0x14(%rsp), %edi
callq 0x135b4
movzwl %ax, %eax
addl %ebx, %eax
movzwl %ax, %ecx
shrl $0x10, %eax
addl %eax, %ecx
movl %ecx, %eax
shrl $0x10, %eax
addl %ecx, %eax
notl %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7e0(%rip), %rdi       # 0x142cc
leaq 0x2d3d(%rip), %rsi      # 0x16830
leaq 0x2d40(%rip), %rcx      # 0x1683a
movl $0x1a0, %edx            # imm = 0x1A0
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050