// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x6, %ecx
callq 0x5034
movl %eax, %ecx
testl %eax, %eax
jne 0x4ee3
movq (%rbx), %rdx
movq %r14, %rcx
subq %rdx, %rcx
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmpq $0x2, %rcx
jl 0x4ede
movq %r13, (%rsp)
leaq 0x2(%rdx), %rbp
movq %rbp, (%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movq %rdx, %r13
movq %r12, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x50ec
movb $0x1, %r12b
testl %eax, %eax
jne 0x4ed3
movq %r13, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x50ec
testl %eax, %eax
je 0x4ef4
movq (%rsp), %r13
xorl %ecx, %ecx
testb %r12b, %r12b
je 0x4ee3
movq %r13, (%rbx)
movl %eax, %ecx
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rcx
subq %rcx, %r14
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmpq $0x14, %r14
movq (%rsp), %r13
jl 0x4ed7
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 %r12d, %r12d
movb %r12b, (%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 %r12b, (%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 %r12b, (%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 %r12b, (%rsi)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
movb %r12b, (%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 0x10(%rsp), %rcx
subl %ecx, %eax
movq 0x8(%rsp), %rdx
movb %ah, (%rdx)
movl (%rbx), %eax
subl %ecx, %eax
movb %al, 0x1(%rdx)
xorl %eax, %eax
jmp 0x4ed7