// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_tcp.c
// Function: parse_args
static int parse_args(channel_tcp_t* ctx, const char* args)
{
	char* cpy, *saveptr = NULL;
	char* p;
	char* v;

	if (!args) return -1;

	cpy = strdup(args);

	for (p = strtok_r(cpy, "&", &saveptr);
		p && *p;
		p = strtok_r(NULL, "&", &saveptr)) {

		v = strchr(p, '=');
		if (!v) continue;

		*v = '\0';
		v++;

		if (strcmp(p, "upstream") == 0) {
			int n = str2addrs(v, &ctx->upstreams[0], MAX_UPSTREAM,
					sizeof(sockaddr_t), "53");
			if (n <= 0) {
				loge("parse address failed: %s:%s\n",
					p,
					(v && (*v)) ? v : "53"
				);
				free(cpy);
				return -1;
			}
			ctx->upstream_num = n;
		}
		else if (strcmp(p, "proxy") == 0) {
			ctx->use_proxy = strcmp(v, "0");
		}
		else if (strcmp(p, "timeout") == 0) {
			if (*v) {
				ctx->timeout = atoi(v);
			}
		}
		else {
			logw("unknown argument: %s=%s\n", p, v);
		}
	}

	free(cpy);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x15f1b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1615b
movq -0x18(%rbp), %rdi
callq 0x3620
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x200d4(%rip), %rsi     # 0x36007
leaq -0x28(%rbp), %rdx
callq 0x3610
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x3d(%rbp)
je 0x15f5c
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x15f68
jmp 0x1614b
movq -0x30(%rbp), %rdi
movl $0x3d, %esi
callq 0x3160
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x15f86
jmp 0x1612e
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x20b8a(%rip), %rsi     # 0x36b2e
callq 0x3500
cmpl $0x0, %eax
jne 0x1607c
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x70, %rsi
movl $0x8, %edx
movl $0x88, %ecx
leaq 0x20056(%rip), %r8      # 0x36025
callq 0x25580
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jg 0x1606a
jmp 0x15fe3
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x16053
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x16014
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x16014
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x16021
leaq 0x2000a(%rip), %rax     # 0x36025
movq %rax, -0x50(%rbp)
jmp 0x16021
movq -0x48(%rbp), %r9
movq -0x50(%rbp), %rax
movl $0x3, %edi
leaq 0x207fb(%rip), %rsi     # 0x36830
leaq 0x1ffec(%rip), %rdx     # 0x36028
movl $0x3d3, %ecx            # imm = 0x3D3
leaq 0x1ffeb(%rip), %r8      # 0x36033
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x16055
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1615b
movl -0x3c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4b0(%rax)
jmp 0x1612c
movq -0x30(%rbp), %rdi
leaq 0x20054(%rip), %rsi     # 0x360db
callq 0x3500
cmpl $0x0, %eax
jne 0x160af
movq -0x38(%rbp), %rdi
leaq 0x1ed5a(%rip), %rsi     # 0x34df6
callq 0x3500
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4b4(%rax)
jmp 0x1612a
movq -0x30(%rbp), %rdi
leaq 0x2108f(%rip), %rsi     # 0x37149
callq 0x3500
cmpl $0x0, %eax
jne 0x160e4
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x160e2
movq -0x38(%rbp), %rdi
callq 0x3580
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4b8(%rax)
jmp 0x16128
jmp 0x160e6
movb $0x0, %al
callq 0x242d0
cmpl $0x4, (%rax)
jl 0x16124
movq -0x30(%rbp), %r9
movq -0x38(%rbp), %rax
movl $0x4, %edi
leaq 0x2072a(%rip), %rsi     # 0x36830
leaq 0x1ff1b(%rip), %rdx     # 0x36028
movl $0x3e2, %ecx            # imm = 0x3E2
leaq 0x200b1(%rip), %r8      # 0x361ca
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x16126
jmp 0x16128
jmp 0x1612a
jmp 0x1612c
jmp 0x1612e
xorl %eax, %eax
movl %eax, %edi
leaq 0x1fece(%rip), %rsi     # 0x36007
leaq -0x28(%rbp), %rdx
callq 0x3610
movq %rax, -0x30(%rbp)
jmp 0x15f40
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)