// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movw %cx, %ax
movw %dx, %cx
movb %sil, %dl
movq %rdi, -0x8(%rbp)
movb %dl, -0x9(%rbp)
movw %cx, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movl %r8d, -0x14(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x27(%rbp)
je 0x25bcc
movzwl -0xe(%rbp), %eax
cmpl $0x0, %eax
setg %al
movb %al, -0x27(%rbp)
movb -0x27(%rbp), %al
testb $0x1, %al
jne 0x25bd8
jmp 0x25cce
jmp 0x25bda
jmp 0x25bdc
movq -0x20(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x26(%rbp)
movzwl -0x26(%rbp), %eax
movzwl -0xe(%rbp), %ecx
cmpl %ecx, %eax
jle 0x25bfc
movw -0xe(%rbp), %ax
movw %ax, -0x26(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movzwl -0x26(%rbp), %esi
callq 0x255c0
movzwl %ax, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movzwl -0xe(%rbp), %eax
movzwl -0x26(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0xe(%rbp)
movzwl -0xe(%rbp), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jl 0x25c60
jmp 0x25c31
leaq 0x1694(%rip), %rdi      # 0x272cc
leaq 0x4095(%rip), %rsi      # 0x29cd4
movl $0x1a0, %edx            # imm = 0x1A0
leaq 0x4093(%rip), %rcx      # 0x29cde
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x25c62
movl -0x14(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
movzwl 0x12(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x25cbc
cmpl $0x0, -0x24(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movl -0x14(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
shrl $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0x25cbe
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x25bb3
cmpl $0x0, -0x24(%rbp)
je 0x25cf0
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movl -0x14(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
shrl $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x14(%rbp)
movzbl -0x9(%rbp), %eax
movzwl %ax, %edi
callq 0x251c0
movzwl %ax, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movzwl -0xc(%rbp), %edi
callq 0x251c0
movzwl %ax, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
shrl $0x10, %eax
movl %eax, %eax
movl -0x14(%rbp), %ecx
andq $0xffff, %rcx           # imm = 0xFFFF
addq %rcx, %rax
movl %eax, -0x14(%rbp)
jmp 0x25d49
movl -0x14(%rbp), %eax
andq $0xffff, %rax           # imm = 0xFFFF
xorq $-0x1, %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)