// File: CoinBlack[P]blackcoin-seeder/dns.cpp
// Function: dnshandle(dns_opt_t*, unsigned char const*, unsigned long, unsigned char*)
ssize_t static dnshandle(dns_opt_t *opt, const unsigned char *inbuf, size_t insize, unsigned char* outbuf) {
  int error = 0;
  if (insize < 12) // DNS header
    return -1;
  // copy id
  outbuf[0] = inbuf[0];
  outbuf[1] = inbuf[1];
  // copy flags;
  outbuf[2] = inbuf[2];
  outbuf[3] = inbuf[3];
  // clear error
  outbuf[3] &= ~15;
  // check qr
  if (inbuf[2] & 128) return set_error(outbuf, 1); /* printf("Got response?\n"); */
  // check opcode
  if (((inbuf[2] & 120) >> 3) != 0) return set_error(outbuf, 1); /* printf("Opcode nonzero?\n"); */
  // unset TC
  outbuf[2] &= ~2;
  // unset RA
  outbuf[3] &= ~128;
  // check questions
  int nquestion = (inbuf[4] << 8) + inbuf[5];
  if (nquestion == 0) return set_error(outbuf, 0); /* printf("No questions?\n"); */
  if (nquestion > 1) return set_error(outbuf, 4); /* printf("Multiple questions %i?\n", nquestion); */
  const unsigned char *inpos = inbuf + 12;
  const unsigned char *inend = inbuf + insize;
  char name[256];
  int offset = inpos - inbuf;
  int ret = parse_name(&inpos, inend, inbuf, name, 256);
  if (ret == -1) return set_error(outbuf, 1);
  if (ret == -2) return set_error(outbuf, 5);
  int namel = strlen(name), hostl = strlen(opt->host);
  if (strcasecmp(name, opt->host) && (namel<hostl+2 || name[namel-hostl-1]!='.' || strcasecmp(name+namel-hostl,opt->host))) return set_error(outbuf, 5);
  if (inend - inpos < 4) return set_error(outbuf, 1);
  // copy question to output
  memcpy(outbuf+12, inbuf+12, inpos+4 - (inbuf+12));
  // set counts
  outbuf[4] = 0;  outbuf[5] = 1;
  outbuf[6] = 0;  outbuf[7] = 0;
  outbuf[8] = 0;  outbuf[9] = 0;
  outbuf[10] = 0; outbuf[11] = 0;
  // set qr
  outbuf[2] |= 128;
  
  int typ = (inpos[0] << 8) + inpos[1];
  int cls = (inpos[2] << 8) + inpos[3];
  inpos += 4;
  
  unsigned char *outpos = outbuf+(inpos-inbuf);
  unsigned char *outend = outbuf + BUFLEN;
  
//   printf("DNS: Request host='%s' type=%i class=%i\n", name, typ, cls);
  
  // calculate max size of authority section
  
  int max_auth_size = 0;
  
  if (!((typ == TYPE_NS || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY))) {
    // authority section will be necessary, either NS or SOA
    unsigned char *newpos = outpos;
    write_record_ns(&newpos, outend, "", offset, CLASS_IN, 0, opt->ns);
    max_auth_size = newpos - outpos;

    newpos = outpos;
    write_record_soa(&newpos, outend, "", offset, CLASS_IN, opt->nsttl, opt->ns, opt->mbox, time(NULL), 604800, 86400, 2592000, 604800);
    if (max_auth_size < newpos - outpos)
        max_auth_size = newpos - outpos;
//    printf("Authority section will claim %i bytes max\n", max_auth_size);
  }
  
  // Answer section

  int have_ns = 0;

  // NS records
  if ((typ == TYPE_NS || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY)) {
    int ret2 = write_record_ns(&outpos, outend - max_auth_size, "", offset, CLASS_IN, opt->nsttl, opt->ns);
//    printf("wrote NS record: %i\n", ret2);
    if (!ret2) { outbuf[7]++; have_ns++; }
  }

  // SOA records
  if ((typ == TYPE_SOA || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY) && opt->mbox) {
    int ret2 = write_record_soa(&outpos, outend - max_auth_size, "", offset, CLASS_IN, opt->nsttl, opt->ns, opt->mbox, time(NULL), 604800, 86400, 2592000, 604800);
//    printf("wrote SOA record: %i\n", ret2);
    if (!ret2) { outbuf[7]++; }
  }
  
  // A/AAAA records
  if ((typ == TYPE_A || typ == TYPE_AAAA || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY)) {
    addr_t addr[32];
    int naddr = opt->cb((void*)opt, name, addr, 32, typ == TYPE_A || typ == QTYPE_ANY, typ == TYPE_AAAA || typ == QTYPE_ANY);
    int n = 0;
    while (n < naddr) {
      int ret = 1;
      if (addr[n].v == 4)
         ret = write_record_a(&outpos, outend - max_auth_size, "", offset, CLASS_IN, opt->datattl, &addr[n]);
      else if (addr[n].v == 6)
         ret = write_record_aaaa(&outpos, outend - max_auth_size, "", offset, CLASS_IN, opt->datattl, &addr[n]);
//      printf("wrote A record: %i\n", ret);
      if (!ret) {
        n++;
        outbuf[7]++;
      } else
        break;
    }
  }
  
  // Authority section
  if (!have_ns && outbuf[7]) {
    int ret2 = write_record_ns(&outpos, outend, "", offset, CLASS_IN, opt->nsttl, opt->ns);
//    printf("wrote NS record: %i\n", ret2);
    if (!ret2) {
      outbuf[9]++;
    }
  }
  else if (!outbuf[7]) {
    // Didn't include any answers, so reply with SOA as this is a negative
    // response. If we replied with NS above we'd create a bad horizontal
    // referral loop, as the NS response indicates where the resolver should
    // try next.
    int ret2 = write_record_soa(&outpos, outend, "", offset, CLASS_IN, opt->nsttl, opt->ns, opt->mbox, time(NULL), 604800, 86400, 2592000, 604800);
//    printf("wrote SOA record: %i\n", ret2);
    if (!ret2) { outbuf[9]++; }
  }
  
  // set AA
  outbuf[2] |= 4;
  
  return outpos - outbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4f0, %rsp            # imm = 0x4F0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $0xc, -0x20(%rbp)
jae 0x54d6
movq $-0x1, -0x8(%rbp)
jmp 0x5f4d
movq -0x18(%rbp), %rax
movb (%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movb 0x2(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movb 0x3(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x28(%rbp), %rax
movzbl 0x3(%rax), %ecx
andl $-0x10, %ecx
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5543
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0x78, %eax
sarl $0x3, %eax
cmpl $0x0, %eax
je 0x556d
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %ecx
andl $-0x3, %ecx
movb %cl, 0x2(%rax)
movq -0x28(%rbp), %rax
movzbl 0x3(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
shll $0x8, %eax
movq -0x18(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x55be
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
cmpl $0x1, -0x30(%rbp)
jle 0x55db
movq -0x28(%rbp), %rdi
movl $0x4, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
movq -0x18(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x144(%rbp)
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x140(%rbp), %rcx
leaq -0x38(%rbp), %rdi
movl $0x100, %r8d            # imm = 0x100
callq 0x5fd0
movl %eax, -0x148(%rbp)
cmpl $-0x1, -0x148(%rbp)
jne 0x5648
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
cmpl $-0x2, -0x148(%rbp)
jne 0x5668
movq -0x28(%rbp), %rdi
movl $0x5, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
leaq -0x140(%rbp), %rdi
callq 0x4210
movl %eax, -0x14c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4210
movl %eax, -0x150(%rbp)
leaq -0x140(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x4550
cmpl $0x0, %eax
je 0x5720
movl -0x14c(%rbp), %eax
movl -0x150(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jl 0x5709
movl -0x14c(%rbp), %eax
subl -0x150(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x140(%rbp,%rax), %eax
cmpl $0x2e, %eax
jne 0x5709
leaq -0x140(%rbp), %rdi
movslq -0x14c(%rbp), %rax
addq %rax, %rdi
movslq -0x150(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x4550
cmpl $0x0, %eax
je 0x5720
movq -0x28(%rbp), %rdi
movl $0x5, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
cmpq $0x4, %rax
jge 0x5748
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5f60
movq %rax, -0x8(%rbp)
jmp 0x5f4d
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
movq -0x38(%rbp), %rdx
addq $0x4, %rdx
movq -0x18(%rbp), %rax
addq $0xc, %rax
subq %rax, %rdx
callq 0x4410
movq -0x28(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x28(%rbp), %rax
movb $0x1, 0x5(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x6(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x7(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x9(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0xa(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0xb(%rax)
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %ecx
orl $0x80, %ecx
movb %cl, 0x2(%rax)
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
shll $0x8, %eax
movq -0x38(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x154(%rbp)
movq -0x38(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
movq -0x38(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x158(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x160(%rbp)
movq -0x28(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x168(%rbp)
movl $0x0, -0x16c(%rbp)
cmpl $0x2, -0x154(%rbp)
je 0x584b
cmpl $0xff, -0x154(%rbp)
jne 0x5868
cmpl $0x1, -0x158(%rbp)
je 0x59bc
cmpl $0xff, -0x158(%rbp)
je 0x59bc
movq -0x160(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x168(%rbp), %rsi
movl -0x144(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
leaq -0x178(%rbp), %rdi
leaq 0x2fe85(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
xorl %r9d, %r9d
movq %rax, (%rsp)
callq 0x6200
movq -0x178(%rbp), %rax
movq -0x160(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x16c(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x448(%rbp)
movl -0x144(%rbp), %eax
movl %eax, -0x440(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x43c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x438(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x430(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4490
movq -0x448(%rbp), %rsi
movl -0x440(%rbp), %ecx
movl -0x43c(%rbp), %r9d
movq -0x438(%rbp), %r11
movq -0x430(%rbp), %r10
leaq -0x178(%rbp), %rdi
leaq 0x2fdd0(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x93a80, 0x18(%rsp)    # imm = 0x93A80
movl $0x15180, 0x20(%rsp)    # imm = 0x15180
movl $0x278d00, 0x28(%rsp)   # imm = 0x278D00
movl $0x93a80, 0x30(%rsp)    # imm = 0x93A80
callq 0x6330
movslq -0x16c(%rbp), %rax
movq -0x178(%rbp), %rcx
movq -0x160(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jge 0x59ba
movq -0x178(%rbp), %rax
movq -0x160(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x16c(%rbp)
jmp 0x59bc
movl $0x0, -0x17c(%rbp)
cmpl $0x2, -0x154(%rbp)
je 0x59df
cmpl $0xff, -0x154(%rbp)
jne 0x5a6a
cmpl $0x1, -0x158(%rbp)
je 0x59f4
cmpl $0xff, -0x158(%rbp)
jne 0x5a6a
movq -0x168(%rbp), %rsi
movslq -0x16c(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl -0x144(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
leaq -0x160(%rbp), %rdi
leaq 0x2fcf0(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0x6200
movl %eax, -0x180(%rbp)
cmpl $0x0, -0x180(%rbp)
jne 0x5a68
movq -0x28(%rbp), %rax
movb 0x7(%rax), %cl
addb $0x1, %cl
movb %cl, 0x7(%rax)
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x5a6a
cmpl $0x6, -0x154(%rbp)
je 0x5a83
cmpl $0xff, -0x154(%rbp)
jne 0x5b8e
cmpl $0x1, -0x158(%rbp)
je 0x5a9c
cmpl $0xff, -0x158(%rbp)
jne 0x5b8e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5b8e
movq -0x168(%rbp), %rax
movslq -0x16c(%rbp), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x468(%rbp)
movl -0x144(%rbp), %eax
movl %eax, -0x460(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x45c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x458(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x450(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4490
movq -0x468(%rbp), %rsi
movl -0x460(%rbp), %ecx
movl -0x45c(%rbp), %r9d
movq -0x458(%rbp), %r11
movq -0x450(%rbp), %r10
leaq -0x160(%rbp), %rdi
leaq 0x2fbe6(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x93a80, 0x18(%rsp)    # imm = 0x93A80
movl $0x15180, 0x20(%rsp)    # imm = 0x15180
movl $0x278d00, 0x28(%rsp)   # imm = 0x278D00
movl $0x93a80, 0x30(%rsp)    # imm = 0x93A80
callq 0x6330
movl %eax, -0x184(%rbp)
cmpl $0x0, -0x184(%rbp)
jne 0x5b8c
movq -0x28(%rbp), %rax
movb 0x7(%rax), %cl
addb $0x1, %cl
movb %cl, 0x7(%rax)
jmp 0x5b8e
cmpl $0x1, -0x154(%rbp)
je 0x5bb0
cmpl $0x1c, -0x154(%rbp)
je 0x5bb0
cmpl $0xff, -0x154(%rbp)
jne 0x5ddb
cmpl $0x1, -0x158(%rbp)
je 0x5bc9
cmpl $0xff, -0x158(%rbp)
jne 0x5ddb
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x490(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x488(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x480(%rbp)
leaq -0x410(%rbp), %rax
movq %rax, -0x478(%rbp)
movb $0x1, %al
cmpl $0x1, -0x154(%rbp)
movb %al, -0x469(%rbp)
je 0x5c23
cmpl $0xff, -0x154(%rbp)
sete %al
movb %al, -0x469(%rbp)
movb -0x469(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x498(%rbp)
movb $0x1, %al
cmpl $0x1c, -0x154(%rbp)
movb %al, -0x491(%rbp)
je 0x5c58
cmpl $0xff, -0x154(%rbp)
sete %al
movb %al, -0x491(%rbp)
movq -0x490(%rbp), %rax
movl -0x498(%rbp), %r8d
movq -0x478(%rbp), %rdx
movq -0x480(%rbp), %rsi
movq -0x488(%rbp), %rdi
movb -0x491(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %r9d
movl $0x20, %ecx
callq *%rax
movl %eax, -0x414(%rbp)
movl $0x0, -0x418(%rbp)
movl -0x418(%rbp), %eax
cmpl -0x414(%rbp), %eax
jge 0x5dd9
movl $0x1, -0x41c(%rbp)
movslq -0x418(%rbp), %rcx
leaq -0x410(%rbp), %rax
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
cmpl $0x4, (%rax)
jne 0x5d33
movq -0x168(%rbp), %rsi
movslq -0x16c(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl -0x144(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r9d
movslq -0x418(%rbp), %rdx
leaq -0x410(%rbp), %rax
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
leaq -0x160(%rbp), %rdi
leaq 0x2fa02(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0x6730
movl %eax, -0x41c(%rbp)
jmp 0x5dab
movslq -0x418(%rbp), %rcx
leaq -0x410(%rbp), %rax
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
cmpl $0x6, (%rax)
jne 0x5da9
movq -0x168(%rbp), %rsi
movslq -0x16c(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl -0x144(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r9d
movslq -0x418(%rbp), %rdx
leaq -0x410(%rbp), %rax
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
leaq -0x160(%rbp), %rdi
leaq 0x2f98a(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0x6860
movl %eax, -0x41c(%rbp)
jmp 0x5dab
cmpl $0x0, -0x41c(%rbp)
jne 0x5dd2
movl -0x418(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x418(%rbp)
movq -0x28(%rbp), %rax
movb 0x7(%rax), %cl
addb $0x1, %cl
movb %cl, 0x7(%rax)
jmp 0x5dd4
jmp 0x5dd9
jmp 0x5c9f
jmp 0x5ddb
cmpl $0x0, -0x17c(%rbp)
jne 0x5e49
movq -0x28(%rbp), %rax
cmpb $0x0, 0x7(%rax)
je 0x5e49
movq -0x168(%rbp), %rsi
movl -0x144(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
leaq -0x160(%rbp), %rdi
leaq 0x2f905(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0x6200
movl %eax, -0x420(%rbp)
cmpl $0x0, -0x420(%rbp)
jne 0x5e44
movq -0x28(%rbp), %rax
movb 0x9(%rax), %cl
addb $0x1, %cl
movb %cl, 0x9(%rax)
jmp 0x5f2d
movq -0x28(%rbp), %rax
cmpb $0x0, 0x7(%rax)
jne 0x5f2b
movq -0x168(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movl -0x144(%rbp), %eax
movl %eax, -0x4b0(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x4ac(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x4a8(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x4a0(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4490
movq -0x4b8(%rbp), %rsi
movl -0x4b0(%rbp), %ecx
movl -0x4ac(%rbp), %r9d
movq -0x4a8(%rbp), %r11
movq -0x4a0(%rbp), %r10
leaq -0x160(%rbp), %rdi
leaq 0x2f849(%rip), %rdx     # 0x3571e
movl $0x1, %r8d
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x93a80, 0x18(%rsp)    # imm = 0x93A80
movl $0x15180, 0x20(%rsp)    # imm = 0x15180
movl $0x278d00, 0x28(%rsp)   # imm = 0x278D00
movl $0x93a80, 0x30(%rsp)    # imm = 0x93A80
callq 0x6330
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
jne 0x5f29
movq -0x28(%rbp), %rax
movb 0x9(%rax), %cl
addb $0x1, %cl
movb %cl, 0x9(%rax)
jmp 0x5f2b
jmp 0x5f2d
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x2(%rax)
movq -0x160(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x4f0, %rsp            # imm = 0x4F0
popq %rbp
retq
nopw (%rax,%rax)