// File: /workspace/github_c_makefile_star2_O0/agl[P]obstcp/libobstcp.c
// Function: client_banner_parse
static int
client_banner_parse(const uint8_t *banner, unsigned len,
                    uint32_t *keyid, const uint8_t **theirpublic,
                    const uint8_t **random) {
  unsigned j = 0;
  char keyid_found = 0, public_found = 0, random_found = 0;
  uint32_t v;

  for (;;) {
    if (j == len) break;
    if (!varint_get(&v, banner, len, &j)) return 0;
    switch (v >> 1) {
    case OBSTCP_KIND_PUBLIC:
      if (!(v & 1)) return 0;
      if (!varint_get(&v, banner, len, &j)) return 0;
      if (v != 32) return 0;
      if (j + v > len) return 0;
      *theirpublic = banner + j;
      public_found = 1;
      j += 32;
      break;
    case OBSTCP_KIND_KEYID:
      if (!(v & 1)) return 0;
      if (!varint_get(&v, banner, len, &j)) return 0;
      if (v != 4) return 0;
      if (j + v > len) return 0;
      *keyid = ntohl(*((uint32_t *) (banner + j)));
      keyid_found = 1;
      j += 4;
      break;
    case OBSTCP_KIND_NONCE:
      if (!(v & 1)) return 0;
      if (!varint_get(&v, banner, len, &j)) return 0;
      if (v != 16) return 0;
      if (j + v > len) return 0;
      *random = banner + j;
      random_found = 1;
      j += 16;
      break;
    default:
      return 0;
    }
  }

  return keyid_found && public_found && random_found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movb $0x0, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
movb $0x0, -0x37(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x28cb
jmp 0x2ac0
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x3c(%rbp), %rdi
leaq -0x34(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x28f0
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movl -0x3c(%rbp), %eax
shrl %eax
movl %eax, -0x40(%rbp)
testl %eax, %eax
je 0x291d
jmp 0x28fe
movl -0x40(%rbp), %eax
subl $0x1, %eax
je 0x29a5
jmp 0x290c
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0x2a33
jmp 0x2ab2
movl -0x3c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2934
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x3c(%rbp), %rdi
leaq -0x34(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x2959
movl $0x0, -0x4(%rbp)
jmp 0x2af4
cmpl $0x20, -0x3c(%rbp)
je 0x296b
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movl -0x34(%rbp), %eax
addl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x2982
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rcx
movl -0x34(%rbp), %eax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x36(%rbp)
movl -0x34(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x34(%rbp)
jmp 0x2abb
movl -0x3c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x29bc
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x3c(%rbp), %rdi
leaq -0x34(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x29e1
movl $0x0, -0x4(%rbp)
jmp 0x2af4
cmpl $0x4, -0x3c(%rbp)
je 0x29f3
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movl -0x34(%rbp), %eax
addl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x2a0a
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx), %edi
callq 0x1120
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x35(%rbp)
movl -0x34(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x34(%rbp)
jmp 0x2abb
movl -0x3c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2a4a
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x3c(%rbp), %rdi
leaq -0x34(%rbp), %rcx
callq 0x4dd0
cmpl $0x0, %eax
jne 0x2a6f
movl $0x0, -0x4(%rbp)
jmp 0x2af4
cmpl $0x10, -0x3c(%rbp)
je 0x2a7e
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movl -0x34(%rbp), %eax
addl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x2a92
movl $0x0, -0x4(%rbp)
jmp 0x2af4
movq -0x10(%rbp), %rcx
movl -0x34(%rbp), %eax
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x37(%rbp)
movl -0x34(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x34(%rbp)
jmp 0x2abb
movl $0x0, -0x4(%rbp)
jmp 0x2af4
jmp 0x28be
movsbl -0x35(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x41(%rbp)
je 0x2ae9
movsbl -0x36(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x41(%rbp)
je 0x2ae9
movsbl -0x37(%rbp), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)