// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_srv_push
int dns_srv_push(struct dns_packet *P, struct dns_srv *srv) {
	size_t end, len;
	int error;

	end	= P->end;

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

	P->end	+= 2;

	if (P->size - P->end < 6)
		goto toolong;

	P->data[P->end++]	= 0xff & (srv->priority >> 8);
	P->data[P->end++]	= 0xff & (srv->priority >> 0);

	P->data[P->end++]	= 0xff & (srv->weight >> 8);
	P->data[P->end++]	= 0xff & (srv->weight >> 0);

	P->data[P->end++]	= 0xff & (srv->port >> 8);
	P->data[P->end++]	= 0xff & (srv->port >> 0);

	if (0 == (len = dns_d_comp(&P->data[P->end], P->size - P->end, srv->target, strlen(srv->target), P, &error)))
		goto error;
	else if (P->size - P->end < len)
		goto toolong;

	P->end	+= len;

	if (P->end > 65535)
		goto toolong;

	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 $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x50(%rcx), %rax
cmpq $0x2, %rax
jae 0x37687
jmp 0x378bd
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x50(%rcx), %rax
cmpq $0x6, %rax
jae 0x376b2
jmp 0x378bd
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x18(%rbp), %rax
movzwl 0x4(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x18(%rbp), %rax
movzwl 0x4(%rax), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movb %dl, 0x5c(%rax,%rcx)
movq -0x10(%rbp), %rax
addq $0x5c, %rax
movq -0x10(%rbp), %rcx
addq 0x50(%rcx), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x50(%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x6, %rdi
callq 0xf5c0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq %rax, %rcx
movq -0x10(%rbp), %r8
leaq -0x2c(%rbp), %r9
callq 0xff10
movq %rax, %rcx
movq %rcx, -0x28(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x3782e
jmp 0x378c4
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x50(%rcx), %rax
cmpq -0x28(%rbp), %rax
jae 0x37846
jmp 0x378bd
jmp 0x37848
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0xffff, 0x50(%rax)     # imm = 0xFFFF
jbe 0x37868
jmp 0x378bd
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
subq -0x20(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movb %dl, 0x5c(%rax,%rcx)
movq -0x28(%rbp), %rax
shrq $0x0, %rax
andq $0xff, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movb %dl, 0x5d(%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x378d6
movl $0x9b918cc0, -0x2c(%rbp) # imm = 0x9B918CC0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop