// File: /workspace/github_c_makefile_star2_O0/agl[P]obstcp/libobstcp.c
// Function: advert_parse
static int
advert_parse(const uint8_t *advert, const unsigned length, va_list ap) {
  unsigned j = 0;
  int tlsport = 0, obsport = 0;
  uint16_t port;
  uint32_t v, type;

  for (;;) {
    if (j == length) break;
    if (!varint_get(&type, advert, length, &j)) return 0;
    switch (type >> 1) {
    case OBSTCP_KIND_OBSPORT:
    case OBSTCP_KIND_TLSPORT:
      if (!(type & 1)) return 0;
      if (!varint_get(&v, advert, length, &j)) return 0;
      if (v != 2) return 0;
      if (j + 2 > length) return 0;
      memcpy(&port, advert + j, 2);
      j += 2;
      port = ntohs(port);
      if (type >> 1 == OBSTCP_KIND_OBSPORT) {
        obsport = port;
      } else {
        tlsport = port;
      }
      break;
    default:
      if (type & 1) {
        if (!varint_get(&v, advert, length, &j)) return 0;
        if (j + v > length) return 0;
        j += v;
      }
    }
  }

  for (;;) {
    const int type = va_arg(ap, int);
    int *iptr;

    switch (type) {
    case OBSTCP_ADVERT_END:
      return 1;
    case OBSTCP_ADVERT_OBSPORT:
      iptr = va_arg(ap, int *);
      *iptr = obsport;
      break;
    case OBSTCP_ADVERT_TLSPORT:
      iptr = va_arg(ap, int *);
      *iptr = tlsport;
      break;
    default:
      return 0;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x1a88
jmp 0x1bbd
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x38(%rbp), %rdi
leaq -0x24(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x1aad
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movl -0x38(%rbp), %eax
shrl %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0x1b66
jmp 0x1ac0
movl -0x38(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x1ad7
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x34(%rbp), %rdi
leaq -0x24(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x1afc
movl $0x0, -0x4(%rbp)
jmp 0x1d09
cmpl $0x2, -0x34(%rbp)
je 0x1b0e
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movl -0x24(%rbp), %eax
addl $0x2, %eax
cmpl -0x14(%rbp), %eax
jbe 0x1b25
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movw (%rax,%rcx), %ax
movw %ax, -0x2e(%rbp)
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
movzwl -0x2e(%rbp), %edi
callq 0x10f0
movw %ax, -0x2e(%rbp)
movl -0x38(%rbp), %eax
shrl %eax
cmpl $0x3, %eax
jne 0x1b5d
movzwl -0x2e(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x1b64
movzwl -0x2e(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x1bb8
movl -0x38(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1bb6
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x34(%rbp), %rdi
leaq -0x24(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x1b96
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x1bad
movl $0x0, -0x4(%rbp)
jmp 0x1d09
movl -0x34(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x1bb8
jmp 0x1a7b
jmp 0x1bbf
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x28, %eax
ja 0x1bea
movq -0x58(%rbp), %rcx
movl -0x4c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x60(%rbp)
jmp 0x1c01
movq -0x58(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x64(%rbp)
testl %eax, %eax
je 0x1c2d
jmp 0x1c16
movl -0x64(%rbp), %eax
subl $0x1, %eax
je 0x1c39
jmp 0x1c20
movl -0x64(%rbp), %eax
subl $0x2, %eax
je 0x1c91
jmp 0x1cfb
movl $0x1, -0x4(%rbp)
jmp 0x1d09
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movl (%rax), %eax
movl %eax, -0x68(%rbp)
cmpl $0x28, %eax
ja 0x1c64
movq -0x70(%rbp), %rcx
movl -0x68(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x78(%rbp)
jmp 0x1c7b
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d04
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x28, %eax
ja 0x1cc5
movq -0x88(%rbp), %rcx
movl -0x7c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x90(%rbp)
jmp 0x1ce2
movq -0x88(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x28(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d04
movl $0x0, -0x4(%rbp)
jmp 0x1d09
jmp 0x1bbf
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)