// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_write_domainname
static int ns_write_domainname(serialize_ctx *ctx, stream_t *s, char *name)
{
	if (name != NULL && strlen(name) > 0) {
		if (ctx && ctx->compression) {
			return ns_write_domainname_comp(ctx, s, name);
		}
		else {
			return ns_write_domainname_nocomp(ctx, s, name);
		}
	}
	else {

		if (stream_writei8(s, 0) != 1)
			return -1;

		return 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2018, %rsp           # imm = 0x2018
movq %rsi, %rbx
testq %rdx, %rdx
je 0x1c126
movq %rdx, %r15
cmpb $0x0, (%rdx)
je 0x1c126
testq %rdi, %rdi
je 0x1c0a7
cmpl $0x0, (%rdi)
je 0x1c0a7
xorl %edx, %edx
movzbl (%r15,%rdx), %ecx
testl %ecx, %ecx
je 0x1c154
cmpl $0x2e, %ecx
je 0x1c154
incq %rdx
jmp 0x1c08c
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
testl %ecx, %ecx
je 0x1c0bc
cmpl $0x2e, %ecx
je 0x1c0bc
incq %rax
jmp 0x1c0a9
xorl %r14d, %r14d
cmpb $0x1, %cl
sbbl %r14d, %r14d
orl %eax, %r14d
jle 0x1c126
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x1d916
cmpl $0x1, %eax
jne 0x1c140
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x1d7ad
cmpl %r14d, %eax
jne 0x1c140
movl %r14d, %eax
addq %rax, %r15
incq %r15
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
testl %ecx, %ecx
je 0x1c115
cmpl $0x2e, %ecx
je 0x1c115
incq %rax
jmp 0x1c102
cmpb $0x1, %cl
movl $0x0, %r14d
sbbl %r14d, %r14d
orl %eax, %r14d
jg 0x1c0cf
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1d916
xorl %ebp, %ebp
cmpl $0x1, %eax
setne %bpl
negl %ebp
movl %ebp, %eax
addq $0x2018, %rsp           # imm = 0x2018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpb $0x1, %cl
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %edx, %ecx
jle 0x1c1b3
xorl %eax, %eax
cmpq $0x200, %rax            # imm = 0x200
je 0x1c1ae
movq %rax, %rdx
shlq $0x4, %rdx
movq %r15, 0x10(%rsp,%rdx)
movl %ecx, 0x18(%rsp,%rdx)
incq %rax
movl %ecx, %ecx
addq %rcx, %r15
incq %r15
xorl %edx, %edx
movzbl (%r15,%rdx), %ecx
testl %ecx, %ecx
je 0x1c19e
cmpl $0x2e, %ecx
je 0x1c19e
incq %rdx
jmp 0x1c18b
cmpb $0x1, %cl
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %edx, %ecx
jg 0x1c166
jmp 0x1c1b3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rbx, 0x8(%rsp)
testl %eax, %eax
movq %rdi, (%rsp)
jle 0x1c25b
leaq 0x8(%rdi), %r14
movl %eax, %r13d
leaq -0x1(%r13), %rbp
movq %rbp, %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %rbx
addq $0x10, %rbx
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x1c202
movq (%rbx), %r12
movq (%r15), %rsi
movq %r12, %rdi
callq 0x34e0
testl %eax, %eax
je 0x1c202
movq 0x28(%r15), %r15
testq %r15, %r15
jne 0x1c1ea
testq %r15, %r15
jne 0x1c249
movl $0x30, %edi
callq 0x34b0
testq %rax, %rax
je 0x1c241
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movq %r14, 0x18(%rax)
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x1c23b
movq %rax, 0x28(%r15)
movq %r15, 0x20(%r14)
jmp 0x1c244
xorl %r15d, %r15d
testq %r15, %r15
je 0x1c25b
movq %r15, %r14
cmpq $0x1, %r13
movq %rbp, %r13
jg 0x1c1cb
jmp 0x1c25e
xorl %r15d, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r15, %r15
je 0x1c140
movq 0x8(%rsp), %rbx
movq (%rsp), %r14
movl 0x10(%r15), %esi
testl %esi, %esi
jg 0x1c2c6
movl 0xc(%rbx), %eax
subl 0x4(%r14), %eax
movl %eax, 0x10(%r15)
movl 0x8(%r15), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1d916
cmpl $0x1, %eax
jne 0x1c140
movq (%r15), %rsi
movl 0x8(%r15), %edx
movq %rbx, %rdi
callq 0x1d7ad
cmpl 0x8(%r15), %eax
jne 0x1c140
movq 0x18(%r15), %r15
testq %r15, %r15
jne 0x1c275
jmp 0x1c2e2
orl $0xc000, %esi           # imm = 0xC000
movq %rbx, %rdi
movl $0x2, %edx
callq 0x1d916
cmpl $0x2, %eax
jne 0x1c140
xorl %ebp, %ebp
jmp 0x1c140