// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_ecs_parse_subnet
int ns_ecs_parse_subnet(struct sockaddr *addr /*out*/, int *pmask /*out*/, const char *str /*in*/)
{
	char buf[INET6_ADDRSTRLEN], *sp_pos;
	int mask = -1;
	int is_ipv6;

	strncpy(buf, str, INET6_ADDRSTRLEN);
	buf[INET6_ADDRSTRLEN - 1] = '\0';

	sp_pos = strrchr(buf, '/');
	if (sp_pos) {
		*sp_pos = 0;
		mask = atoi(sp_pos + 1);
	}

	is_ipv6 = buf[0] =='[' || strchr(buf, ':');

	if (is_ipv6) {
		struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
		struct in6_addr *ip = &(addr6->sin6_addr);
		if (inet_pton(AF_INET6, buf, ip) != 1) {
			loge("invalid addr %s: errno=%d, %s\n",
				str, errno, strerror(errno));
			return -1;
		}
		addr6->sin6_family = AF_INET6;
		if (mask == -1) mask = 128;
	}
	else {
		struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
		struct in_addr *ip = &(addr4->sin_addr);
		if (inet_pton(AF_INET, buf, ip) != 1) {
			loge("invalid addr %s: errno=%d, %s\n",
				str, errno, strerror(errno));
			return -1;
		}
		addr4->sin_family = AF_INET;
		if (mask == -1) mask = 32;
	}

	*pmask = mask;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x2e, %edx
callq 0x31f0
movb $0x0, -0x23(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x2f, %esi
callq 0x3400
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x29824
movq -0x58(%rbp), %rax
movb $0x0, (%rax)
movq -0x58(%rbp), %rdi
addq $0x1, %rdi
callq 0x3580
movl %eax, -0x5c(%rbp)
movsbl -0x50(%rbp), %ecx
movb $0x1, %al
cmpl $0x5b, %ecx
movb %al, -0x81(%rbp)
je 0x29850
leaq -0x50(%rbp), %rdi
movl $0x3a, %esi
callq 0x3160
cmpq $0x0, %rax
setne %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
je 0x2992b
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x70(%rbp)
leaq -0x50(%rbp), %rsi
movq -0x70(%rbp), %rdx
movl $0xa, %edi
callq 0x3640
cmpl $0x1, %eax
je 0x29910
jmp 0x29895
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x29902
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x3040
movl (%rax), %eax
movl %eax, -0x88(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x3150
movq -0x90(%rbp), %r9
movl -0x88(%rbp), %r10d
movl $0x3, %edi
leaq 0xeb35(%rip), %rsi      # 0x38414
leaq 0xebf9(%rip), %rdx      # 0x384df
movl $0x4a7, %ecx            # imm = 0x4A7
leaq 0xec01(%rip), %r8       # 0x384f3
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x29904
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x299f8
movq -0x68(%rbp), %rax
movw $0xa, (%rax)
cmpl $-0x1, -0x5c(%rbp)
jne 0x29926
movl $0x80, -0x5c(%rbp)
jmp 0x299e8
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
leaq -0x50(%rbp), %rsi
movq -0x80(%rbp), %rdx
movl $0x2, %edi
callq 0x3640
cmpl $0x1, %eax
je 0x299d0
jmp 0x29958
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x299c5
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
callq 0x3040
movl (%rax), %eax
movl %eax, -0x94(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x3150
movq -0xa0(%rbp), %r9
movl -0x94(%rbp), %r10d
movl $0x3, %edi
leaq 0xea72(%rip), %rsi      # 0x38414
leaq 0xeb36(%rip), %rdx      # 0x384df
movl $0x4b2, %ecx            # imm = 0x4B2
leaq 0xeb3e(%rip), %r8       # 0x384f3
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x299c7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x299f8
movq -0x78(%rbp), %rax
movw $0x2, (%rax)
cmpl $-0x1, -0x5c(%rbp)
jne 0x299e6
movl $0x20, -0x5c(%rbp)
jmp 0x299e8
movl -0x5c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)