// File: /workspace/github_c_makefile_star2_O1/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)
movl %esi, 0x10(%rsp)
testq %rdi, %rdi
sete %cl
testl %r15d, %r15d
sete %dl
movb $0x1, %al
orb %cl, %dl
jne 0x1414a
movq %rdi, %r12
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 0x13e2c
subl %r14d, %r15d
movl %r15d, %ecx
andl %ebx, %ecx
cmpl $0x7fff, %ecx           # imm = 0x7FFF
jae 0x14196
movzwl %ax, %eax
addl %eax, %ebp
movl %ebp, %eax
shrl $0x10, %eax
movzwl %bp, %ebp
addl %eax, %ebp
testb $0x1, %r13b
je 0x14133
xorl %eax, %eax
cmpl $0x0, 0xc(%rsp)
sete %al
rolw $0x8, %bp
movzwl %bp, %ebp
movl %eax, 0xc(%rsp)
testw %r15w, %r15w
je 0x14142
movq (%r12), %r12
testq %r12, %r12
jne 0x140d5
cmpl $0x0, 0xc(%rsp)
sete %al
movl %ebp, %ecx
rolw $0x8, %cx
movzwl %cx, %ebx
testb %al, %al
cmovnel %ebp, %ebx
movzbl 0x10(%rsp), %edi
callq 0x13c50
movzwl %ax, %ebp
movzwl 0x14(%rsp), %edi
callq 0x13c50
movzwl %ax, %eax
addl %ebp, %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 0x112f(%rip), %rdi      # 0x152cc
leaq 0x373c(%rip), %rsi      # 0x178e0
leaq 0x373f(%rip), %rcx      # 0x178ea
movl $0x1a0, %edx            # imm = 0x1A0
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050