// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_soa_push
int dns_soa_push(struct dns_packet *P, struct dns_soa *soa) {
	void *dn[]	= { soa->mname, soa->rname };
	unsigned ts[]	= { (0xffffffff & soa->serial),
			    (0x7fffffff & soa->refresh),
			    (0x7fffffff & soa->retry),
			    (0x7fffffff & soa->expire),
			    (0xffffffff & soa->minimum) };
	unsigned i, j;
	size_t end, len;
	int error;

	end	= P->end;

	if ((P->end += 2) >= P->size)
		goto toolong;

	/* MNAME / RNAME */
	for (i = 0; i < lengthof(dn); i++) {
		if ((error = dns_d_push(P, dn[i], strlen(dn[i]))))
			goto error;
	}

	/* SERIAL / REFRESH / RETRY / EXPIRE / MINIMUM */
	for (i = 0; i < lengthof(ts); i++) {
		if ((P->end += 4) >= P->size)
			goto toolong;

		for (j = 1; j <= 4; j++) {
			P->data[P->end - j]	= (0xff & ts[i]);
			ts[i]			>>= 8;
		}
	}

	len			= P->end - end - 2;
	P->data[end + 0]	= (0xff & (len >> 8));
	P->data[end + 1]	= (0xff & (len >> 0));

	return 0;
toolong:
	error	= DNS_ENOBUFS;

	/* FALL THROUGH */
error:
	P->end	= end;

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x200(%rax), %eax
andl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl 0x204(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movl 0x208(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x20c(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl 0x210(%rax), %eax
andl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rax
addq $0x2, %rax
movq %rax, 0x50(%rcx)
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jb 0x3704e
jmp 0x37184
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpq $0x2, %rax
jae 0x370a9
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x54(%rbp), %eax
movq -0x30(%rbp,%rax,8), %rax
movq %rax, -0x78(%rbp)
movl -0x54(%rbp), %eax
movq -0x30(%rbp,%rax,8), %rdi
callq 0xf5c0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq %rax, %rdx
callq 0xf3d0
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
je 0x3709c
jmp 0x3718b
jmp 0x3709e
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x37055
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpq $0x5, %rax
jae 0x3712f
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rax
addq $0x4, %rax
movq %rax, 0x50(%rcx)
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jb 0x370d8
jmp 0x37184
movl $0x1, -0x58(%rbp)
cmpl $0x4, -0x58(%rbp)
ja 0x37122
movl -0x54(%rbp), %eax
movl -0x50(%rbp,%rax,4), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl -0x58(%rbp), %esi
subq %rsi, %rcx
movb %dl, 0x5c(%rax,%rcx)
movl -0x54(%rbp), %eax
movl -0x50(%rbp,%rax,4), %ecx
shrl $0x8, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x370df
jmp 0x37124
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x370b0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
subq -0x60(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x60(%rbp), %rcx
movb %dl, 0x5c(%rax,%rcx)
movq -0x68(%rbp), %rax
shrq $0x0, %rax
andq $0xff, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x60(%rbp), %rcx
movb %dl, 0x5d(%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x3719d
movl $0x9b918cc0, -0x6c(%rbp) # imm = 0x9B918CC0
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x6c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)