// File: /workspace/github_cpp_makefile_star2_O2/CoinBlack[P]blackcoin-seeder/dns.cpp
// Function: write_record_soa(unsigned char**, unsigned char const*, char const*, int, dns_class, int, char const*, char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
int static write_record_soa(unsigned char** outpos, const unsigned char *outend, const char *name, int offset, dns_class cls, int ttl, const char* mname, const char *rname,
                     uint32_t serial, uint32_t refresh, uint32_t retry, uint32_t expire, uint32_t minimum) {
  unsigned char *oldpos = *outpos;
  int ret = write_record(outpos, outend, name, offset, TYPE_SOA, cls, ttl);
  if (ret) return ret;
  int error = 0;
  if (outend - *outpos < 2) {
    error = -5;
  } else {
    (*outpos) += 2;
    unsigned char *curpos = *outpos;
    ret = write_name(outpos, outend, mname, -1);
    if (ret) {
      error = ret;
    } else {
      ret = write_name(outpos, outend, rname, -1);
      if (ret) {
        error = ret;
      } else {
        if (outend - *outpos < 20) {
          error = -5;
        } else {
          *((*outpos)++) = (serial  >> 24) & 0xFF; *((*outpos)++) = (serial  >> 16) & 0xFF; *((*outpos)++) = (serial  >> 8) & 0xFF; *((*outpos)++) = serial  & 0xFF;
          *((*outpos)++) = (refresh >> 24) & 0xFF; *((*outpos)++) = (refresh >> 16) & 0xFF; *((*outpos)++) = (refresh >> 8) & 0xFF; *((*outpos)++) = refresh & 0xFF;
          *((*outpos)++) = (retry   >> 24) & 0xFF; *((*outpos)++) = (retry   >> 16) & 0xFF; *((*outpos)++) = (retry   >> 8) & 0xFF; *((*outpos)++) = retry   & 0xFF;
          *((*outpos)++) = (expire  >> 24) & 0xFF; *((*outpos)++) = (expire  >> 16) & 0xFF; *((*outpos)++) = (expire  >> 8) & 0xFF; *((*outpos)++) = expire  & 0xFF;
          *((*outpos)++) = (minimum >> 24) & 0xFF; *((*outpos)++) = (minimum >> 16) & 0xFF; *((*outpos)++) = (minimum >> 8) & 0xFF; *((*outpos)++) = minimum & 0xFF;
          curpos[-2] = (*outpos - curpos) >> 8;
          curpos[-1] = (*outpos - curpos) & 0xFF;
          return 0;
        }
      }
    }
  }
  *outpos = oldpos;
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r15
movq %r8, %r12
movl %ecx, %r8d
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r13
pushq $0x6
popq %rcx
callq 0x46e8
movl %eax, %ebp
testl %eax, %eax
jne 0x45a6
movq (%rbx), %rcx
movq %r14, %rax
subq %rcx, %rax
pushq $-0x5
popq %rbp
cmpq $0x2, %rax
jl 0x45a3
leaq 0x2(%rcx), %rax
movq %rax, 0x10(%rsp)
movq %rax, (%rbx)
movq %rcx, 0x8(%rsp)
pushq $-0x1
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x479e
testl %eax, %eax
jne 0x45a1
movq 0x10(%rsp), %r12
pushq $-0x1
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x479e
testl %eax, %eax
je 0x45b7
movl %eax, %ebp
movq %r13, (%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rcx
subq %rcx, %r14
cmpq $0x14, %r14
jl 0x45a3
movl 0x50(%rsp), %eax
movl %eax, %edx
shrl $0x18, %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movb %dl, (%rcx)
movl %eax, %ecx
shrl $0x10, %ecx
movq (%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movb %cl, (%rdx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movb %ah, (%rcx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movb %al, (%rcx)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
xorl %ebp, %ebp
movb %bpl, (%rax)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rax
movq %rax, (%rbx)
movb $0x9, %al
movb %al, (%rcx)
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%rbx)
movb $0x3a, %cl
movb %cl, (%rdx)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdx
movq %rdx, (%rbx)
movb $-0x80, %dl
movb %dl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %bpl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb $0x1, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb $0x51, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %dl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %bpl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb $0x27, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb $-0x73, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %bpl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %bpl, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %al, (%rsi)
movq (%rbx), %rax
leaq 0x1(%rax), %rsi
movq %rsi, (%rbx)
movb %cl, (%rax)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb %dl, (%rax)
movl (%rbx), %eax
subl %r12d, %eax
movq 0x8(%rsp), %rcx
movb %ah, (%rcx)
movl (%rbx), %eax
subl %r12d, %eax
movb %al, 0x1(%rcx)
jmp 0x45a6