// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: get_rr_flags
static int get_rr_flags(channel_chndoh_t* ctx, ns_rr_t* rr, int *index)
{
	if (rr->type == NS_QTYPE_A) {
		struct in_addr* addr = (struct in_addr*)rr->rdata;
		int flags = 0;
		/* Only the first IP needs to detect the blacklist */
		if ((*index) == 0 && chnroute_test4(ctx->blacklist, addr)) {
			flags |= FLG_BLACKLIST;
		}
		if (chnroute_test4(ctx->chnr, addr)) {
			flags |= (FLG_A | FLG_A_CHN);
		}
		else {
			flags |= (FLG_A | FLG_A_FRN);
		}
		(*index)++;
		return flags;
	}
	else if (rr->type == NS_QTYPE_AAAA) {
		struct in6_addr* addr = (struct in6_addr*)rr->rdata;
		int flags = 0;
		/* Only the first IP needs to detect the blacklist */
		if ((*index) == 0 && chnroute_test6(ctx->blacklist, addr)) {
			flags |= FLG_BLACKLIST;
		}
		if (chnroute_test6(ctx->chnr, addr)) {
			flags |= (FLG_AAAA | FLG_AAAA_CHN);
		}
		else {
			flags |= (FLG_AAAA | FLG_AAAA_FRN);
		}
		(*index)++;
		return flags;
	}
	else if (rr->type == NS_QTYPE_PTR) {
		return FLG_PTR;
	}
	else if (rr->type == NS_QTYPE_OPT) {
		ns_opt_t* ecsopt = ns_optrr_find_ecs(rr);
		ns_ecs_t ecs = { 0 };
		if (ecsopt && ns_parse_ect(&ecs, ecsopt->data, ecsopt->length) && ecs.family) {
			if (ecs.family == ADDR_FAMILY_NUM_IP) {
				struct in_addr* addr = (struct in_addr*)ecs.subnet;
				if (chnroute_test4(ctx->chnr, addr)) {
					return (FLG_OPT | FLG_ECS | FLG_ECS_CHN);
				}
				else {
					return (FLG_OPT | FLG_ECS | FLG_ECS_FRN);
				}
			}
			else if (ecs.family == ADDR_FAMILY_NUM_IP6) {
				struct in6_addr* addr = (struct in6_addr*)ecs.subnet;
				if (chnroute_test6(ctx->chnr, addr)) {
					return (FLG_OPT | FLG_ECS | FLG_ECS_CHN);
				}
				else {
					return (FLG_OPT | FLG_ECS | FLG_ECS_FRN);
				}
			}
		}
		return FLG_OPT;
	}
	return FLG_NONE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %eax
cmpl $0x1, %eax
jne 0x112ae
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1126e
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x1b740
cmpl $0x0, %eax
je 0x1126e
movl -0x2c(%rbp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x1b740
cmpl $0x0, %eax
je 0x1128f
movl -0x2c(%rbp), %eax
orl $0x6, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11298
movl -0x2c(%rbp), %eax
orl $0xa, %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1144f
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %eax
cmpl $0x1c, %eax
jne 0x11338
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x112f8
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x1b8a0
cmpl $0x0, %eax
je 0x112f8
movl -0x3c(%rbp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x1b8a0
cmpl $0x0, %eax
je 0x11319
movl -0x3c(%rbp), %eax
orl $0x30, %eax
movl %eax, -0x3c(%rbp)
jmp 0x11322
movl -0x3c(%rbp), %eax
orl $0x50, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1144f
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %eax
cmpl $0xc, %eax
jne 0x11351
movl $0x80, -0x4(%rbp)
jmp 0x1144f
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %eax
cmpl $0x29, %eax
jne 0x11442
movq -0x18(%rbp), %rdi
movl $0x8, %esi
callq 0x29440
movq %rax, -0x48(%rbp)
leaq -0x5c(%rbp), %rdi
xorl %esi, %esi
movl $0x14, %edx
callq 0x3200
cmpq $0x0, -0x48(%rbp)
je 0x11439
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq -0x5c(%rbp), %rdi
callq 0x2a4f0
cmpq $0x0, %rax
je 0x11439
movzwl -0x5c(%rbp), %eax
cmpl $0x0, %eax
je 0x11439
movzwl -0x5c(%rbp), %eax
cmpl $0x1, %eax
jne 0x113f8
leaq -0x5c(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x1b740
cmpl $0x0, %eax
je 0x113ef
movl $0x700, -0x4(%rbp)      # imm = 0x700
jmp 0x1144f
movl $0xb00, -0x4(%rbp)      # imm = 0xB00
jmp 0x1144f
movzwl -0x5c(%rbp), %eax
cmpl $0x2, %eax
jne 0x11435
leaq -0x5c(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x1b8a0
cmpl $0x0, %eax
je 0x1142c
movl $0x700, -0x4(%rbp)      # imm = 0x700
jmp 0x1144f
movl $0xb00, -0x4(%rbp)      # imm = 0xB00
jmp 0x1144f
jmp 0x11437
jmp 0x11439
movl $0x100, -0x4(%rbp)      # imm = 0x100
jmp 0x1144f
jmp 0x11444
jmp 0x11446
jmp 0x11448
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)