// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %r9, %r15
movq %r8, %r12
movl %ecx, %r8d
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r13
movl $0x6, %ecx
callq 0x4f60
movl %eax, %ebp
testl %eax, %eax
jne 0x4e1c
movq (%rbx), %rcx
movq %r14, %rax
subq %rcx, %rax
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
cmpq $0x2, %rax
jl 0x4e19
leaq 0x2(%rcx), %rax
movq %rax, (%rsp)
movq %rax, (%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rcx, %r12
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x5018
testl %eax, %eax
jne 0x4e17
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x5018
testl %eax, %eax
je 0x4e2d
movl %eax, %ebp
movq %r13, (%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rcx
subq %rcx, %r14
cmpq $0x14, %r14
jl 0x4e19
movl 0x40(%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
movq (%rsp), %rdx
subl %edx, %eax
movq %r12, %rcx
movb %ah, (%rcx)
movl (%rbx), %eax
subl %edx, %eax
movb %al, 0x1(%r12)
jmp 0x4e1c