// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/inet_chksum.c
// Function: inet_cksum_pseudo_base
static u16_t
inet_cksum_pseudo_base(struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc)
{
  struct pbuf *q;
  int swapped = 0;

  /* iterate through all pbuf in chain */
  for (q = p; q != NULL; q = q->next) {
    LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n",
                             (void *)q, (void *)q->next));
    acc += LWIP_CHKSUM(q->payload, q->len);
    /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/
    /* just executing this next line is probably faster that the if statement needed
       to check whether we really need to execute it, and does no harm */
    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
movq %rsp, %rbp
subq $0x20, %rsp
movw %dx, %ax
movb %sil, %dl
movq %rdi, -0x8(%rbp)
movb %dl, -0x9(%rbp)
movw %ax, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x25864
jmp 0x257d8
jmp 0x257da
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %esi
callq 0x255c0
movzwl %ax, %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x10(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x25852
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl -0x10(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movl -0x10(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
shrl $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
jmp 0x25854
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x257cb
cmpl $0x0, -0x1c(%rbp)
je 0x25886
movl -0x10(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movl -0x10(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
shrl $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
movzbl -0x9(%rbp), %eax
movzwl %ax, %edi
callq 0x251c0
movzwl %ax, %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movzwl -0xc(%rbp), %edi
callq 0x251c0
movzwl %ax, %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x10(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x10(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x10(%rbp)
jmp 0x258df
movl -0x10(%rbp), %eax
andq $0xffff, %rax           # imm = 0xFFFF
xorq $-0x1, %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)