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

	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, "addr") == 0) {
            p = v;
            if (*p == '[') {
                p++;
                v = strchr(p, ']');
                if (v) {
                    *v = '\0';
                    v++;
                    if (*v == ':') {
                        v++;
                    }
                }
            }
            else {
                v = strchr(p, ':');
                if (v) {
                    *v = '\0';
                    v++;
                }
            }

            if (!try_parse_as_ip( &ctx->http_addr, p, (v && (*v)) ? v : "443") ) {
                loge("parse address failed: %s:%s\n",
                        p,
                        (v && (*v)) ? v : "443"
                    );
                free(cpy);
                return -1;
            }
        }
        else if (strcmp(p, "host") == 0) {
            ctx->host = strdup(v);
        }
        else if (strcmp(p, "path") == 0) {
            ctx->path = strdup(v);
        }
		else if (strcmp(p, "post") == 0) {
			ctx->post = strcmp(v, "0");
		}
		else if (strcmp(p, "keep-alive") == 0) {
            ctx->keep_alive = atoi(v);
        }
		else if (strcmp(p, "proxy") == 0) {
            ctx->use_proxy = strcmp(v, "0");
        }
        else if (strcmp(p, "ecs") == 0) {
            ctx->ecs = strcmp(v, "0");
        }
        else if (strcmp(p, "timeout") == 0) {
            ctx->timeout = atoi(v);
        }
        else if (strcmp(p, "china-ip4") == 0) {
            if (v && *v && parse_subnet(&ctx->china_net, v)) {
                loge("parse \"china-ip4\" failed: %s\n", v);
                free(cpy);
                return -1;
            }
        }
        else if (strcmp(p, "china-ip6") == 0) {
            if (v && *v && parse_subnet(&ctx->china_net6, v)) {
                loge("parse \"china-ip6\" failed: %s\n", v);
                free(cpy);
                return -1;
            }
        }
        else if (strcmp(p, "foreign-ip4") == 0) {
            if (v && *v && parse_subnet(&ctx->foreign_net, v)) {
                loge("parse \"foreign-ip4\" failed: %s\n", v);
                free(cpy);
                return -1;
            }
        }
        else if (strcmp(p, "foreign-ip6") == 0) {
            if (v && *v && parse_subnet(&ctx->foreign_net6, v)) {
                loge("parse \"foreign-ip6\" failed: %s\n", v);
                free(cpy);
                return -1;
            }
        }
        else {
            logw("unknown argument: %s=%s\n", p, v);
        }
    }

	free(cpy);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1249b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
movq -0x18(%rbp), %rdi
callq 0x3620
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x23b54(%rip), %rsi     # 0x36007
leaq -0x38(%rbp), %rdx
callq 0x3610
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x39(%rbp)
je 0x124dc
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x124e8
jmp 0x12ae8
movq -0x28(%rbp), %rdi
movl $0x3d, %esi
callq 0x3160
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x12506
jmp 0x12acb
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x23aec(%rip), %rsi     # 0x36010
callq 0x3500
cmpl $0x0, %eax
jne 0x126b0
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x1259a
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x5d, %esi
callq 0x3160
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x12598
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x12596
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x12598
jmp 0x125c8
movq -0x28(%rbp), %rdi
movl $0x3a, %esi
callq 0x3160
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x125c6
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x125c8
movq -0x10(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x125fb
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x125fb
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x12608
leaq 0x23a1f(%rip), %rax     # 0x36021
movq %rax, -0x58(%rbp)
jmp 0x12608
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rdx
callq 0x24ce0
cmpl $0x0, %eax
jne 0x126ab
jmp 0x12624
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x12694
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x12655
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x12655
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x12662
leaq 0x239c5(%rip), %rax     # 0x36021
movq %rax, -0x68(%rbp)
jmp 0x12662
movq -0x60(%rbp), %r9
movq -0x68(%rbp), %rax
movl $0x3, %edi
leaq 0x23f8d(%rip), %rsi     # 0x36603
leaq 0x239ab(%rip), %rdx     # 0x36028
movl $0x3a8, %ecx            # imm = 0x3A8
leaq 0x239aa(%rip), %r8      # 0x36033
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x12696
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
jmp 0x12ac9
movq -0x28(%rbp), %rdi
leaq 0x23199(%rip), %rsi     # 0x35854
callq 0x3500
cmpl $0x0, %eax
jne 0x126e1
movq -0x30(%rbp), %rdi
callq 0x3620
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x120(%rax)
jmp 0x12ac7
movq -0x28(%rbp), %rdi
leaq 0x231a4(%rip), %rsi     # 0x35890
callq 0x3500
cmpl $0x0, %eax
jne 0x12712
movq -0x30(%rbp), %rdi
callq 0x3620
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x128(%rax)
jmp 0x12ac5
movq -0x28(%rbp), %rdi
leaq 0x239a6(%rip), %rsi     # 0x360c3
callq 0x3500
cmpl $0x0, %eax
jne 0x12748
movq -0x30(%rbp), %rdi
leaq 0x226c4(%rip), %rsi     # 0x34df6
callq 0x3500
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x88(%rax)
jmp 0x12ac3
movq -0x28(%rbp), %rdi
leaq 0x2394c(%rip), %rsi     # 0x3609f
callq 0x3500
cmpl $0x0, %eax
jne 0x12777
movq -0x30(%rbp), %rdi
callq 0x3580
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x130(%rax)
jmp 0x12ac1
movq -0x28(%rbp), %rdi
leaq 0x23959(%rip), %rsi     # 0x360db
callq 0x3500
cmpl $0x0, %eax
jne 0x127ad
movq -0x30(%rbp), %rdi
leaq 0x2265f(%rip), %rsi     # 0x34df6
callq 0x3500
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x134(%rax)
jmp 0x12abf
movq -0x28(%rbp), %rdi
leaq 0x2393d(%rip), %rsi     # 0x360f5
callq 0x3500
cmpl $0x0, %eax
jne 0x127e3
movq -0x30(%rbp), %rdi
leaq 0x22629(%rip), %rsi     # 0x34df6
callq 0x3500
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x138(%rax)
jmp 0x12abd
movq -0x28(%rbp), %rdi
leaq 0x2495b(%rip), %rsi     # 0x37149
callq 0x3500
cmpl $0x0, %eax
jne 0x12812
movq -0x30(%rbp), %rdi
callq 0x3580
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x13c(%rax)
jmp 0x12abb
movq -0x28(%rbp), %rdi
leaq 0x23e0b(%rip), %rsi     # 0x36628
callq 0x3500
cmpl $0x0, %eax
jne 0x128ab
cmpq $0x0, -0x30(%rbp)
je 0x128a6
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x128a6
movq -0x10(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movq -0x30(%rbp), %rsi
callq 0x12f40
cmpl $0x0, %eax
je 0x128a6
jmp 0x12859
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1288f
movq -0x30(%rbp), %r9
movl $0x3, %edi
leaq 0x23d8e(%rip), %rsi     # 0x36603
leaq 0x237ac(%rip), %rdx     # 0x36028
movl $0x3c4, %ecx            # imm = 0x3C4
leaq 0x23daa(%rip), %r8      # 0x36632
movb $0x0, %al
callq 0x243b0
jmp 0x12891
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
jmp 0x12ab9
movq -0x28(%rbp), %rdi
leaq 0x23d9a(%rip), %rsi     # 0x36650
callq 0x3500
cmpl $0x0, %eax
jne 0x12944
cmpq $0x0, -0x30(%rbp)
je 0x1293f
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1293f
movq -0x10(%rbp), %rdi
addq $0x270, %rdi            # imm = 0x270
movq -0x30(%rbp), %rsi
callq 0x12f40
cmpl $0x0, %eax
je 0x1293f
jmp 0x128f2
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x12928
movq -0x30(%rbp), %r9
movl $0x3, %edi
leaq 0x23cf5(%rip), %rsi     # 0x36603
leaq 0x23713(%rip), %rdx     # 0x36028
movl $0x3cb, %ecx            # imm = 0x3CB
leaq 0x23d39(%rip), %r8      # 0x3665a
movb $0x0, %al
callq 0x243b0
jmp 0x1292a
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
jmp 0x12ab7
movq -0x28(%rbp), %rdi
leaq 0x23d29(%rip), %rsi     # 0x36678
callq 0x3500
cmpl $0x0, %eax
jne 0x129dd
cmpq $0x0, -0x30(%rbp)
je 0x129d8
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x129d8
movq -0x10(%rbp), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
movq -0x30(%rbp), %rsi
callq 0x12f40
cmpl $0x0, %eax
je 0x129d8
jmp 0x1298b
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x129c1
movq -0x30(%rbp), %r9
movl $0x3, %edi
leaq 0x23c5c(%rip), %rsi     # 0x36603
leaq 0x2367a(%rip), %rdx     # 0x36028
movl $0x3d2, %ecx            # imm = 0x3D2
leaq 0x23cca(%rip), %r8      # 0x36684
movb $0x0, %al
callq 0x243b0
jmp 0x129c3
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
jmp 0x12ab5
movq -0x28(%rbp), %rdi
leaq 0x23cbc(%rip), %rsi     # 0x366a4
callq 0x3500
cmpl $0x0, %eax
jne 0x12a6f
cmpq $0x0, -0x30(%rbp)
je 0x12a6d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x12a6d
movq -0x10(%rbp), %rdi
addq $0x308, %rdi            # imm = 0x308
movq -0x30(%rbp), %rsi
callq 0x12f40
cmpl $0x0, %eax
je 0x12a6d
jmp 0x12a20
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x12a56
movq -0x30(%rbp), %r9
movl $0x3, %edi
leaq 0x23bc7(%rip), %rsi     # 0x36603
leaq 0x235e5(%rip), %rdx     # 0x36028
movl $0x3d9, %ecx            # imm = 0x3D9
leaq 0x23c61(%rip), %r8      # 0x366b0
movb $0x0, %al
callq 0x243b0
jmp 0x12a58
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x12af8
jmp 0x12ab3
jmp 0x12a71
movb $0x0, %al
callq 0x242d0
cmpl $0x4, (%rax)
jl 0x12aaf
movq -0x28(%rbp), %r9
movq -0x30(%rbp), %rax
movl $0x4, %edi
leaq 0x23b72(%rip), %rsi     # 0x36603
leaq 0x23590(%rip), %rdx     # 0x36028
movl $0x3df, %ecx            # imm = 0x3DF
leaq 0x23726(%rip), %r8      # 0x361ca
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x12ab1
jmp 0x12ab3
jmp 0x12ab5
jmp 0x12ab7
jmp 0x12ab9
jmp 0x12abb
jmp 0x12abd
jmp 0x12abf
jmp 0x12ac1
jmp 0x12ac3
jmp 0x12ac5
jmp 0x12ac7
jmp 0x12ac9
jmp 0x12acb
xorl %eax, %eax
movl %eax, %edi
leaq 0x23531(%rip), %rsi     # 0x36007
leaq -0x38(%rbp), %rdx
callq 0x3610
movq %rax, -0x28(%rbp)
jmp 0x124c0
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)