// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movzwl 0x8(%rsi), %eax
cmpl $0x1b, %eax
jg 0xc23b
cmpl $0x1, %eax
je 0xc2d4
movl $0x80, %ebp
cmpl $0xc, %eax
je 0xc35c
jmp 0xc2cd
cmpl $0x1c, %eax
je 0xc316
cmpl $0x29, %eax
jne 0xc2cd
movq %rsi, %rdi
movl $0x8, %esi
callq 0x1b7ce
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movl $0x0, 0x10(%rsp)
movl $0x100, %ebp            # imm = 0x100
testq %rax, %rax
je 0xc35c
movq 0x8(%rax), %rsi
movzwl 0x2(%rax), %edx
movq %rsp, %r14
movq %r14, %rdi
callq 0x1c564
testq %rax, %rax
setne %cl
movzwl (%r14), %eax
testw %ax, %ax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xc35c
movzwl %ax, %eax
cmpl $0x2, %eax
je 0xc36b
cmpl $0x1, %eax
jne 0xc35c
leaq 0x4(%rsp), %rsi
movq 0x20(%rbx), %rdi
callq 0x12540
jmp 0xc379
xorl %ebp, %ebp
jmp 0xc35c
movq 0x18(%rsi), %r15
xorl %r12d, %r12d
cmpl $0x0, (%r14)
jne 0xc2fa
movq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x12540
xorl %r12d, %r12d
testl %eax, %eax
setne %r12b
shll $0xc, %r12d
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x12540
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal (%r12,%rcx,4), %ebp
addl $0x6, %ebp
jmp 0xc359
movq 0x18(%rsi), %r15
xorl %r12d, %r12d
cmpl $0x0, (%r14)
jne 0xc33c
movq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x125be
xorl %r12d, %r12d
testl %eax, %eax
setne %r12b
shll $0xc, %r12d
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x125be
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
shll $0x5, %ecx
leal (%rcx,%r12), %ebp
addl $0x30, %ebp
incl (%r14)
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4(%rsp), %rsi
movq 0x20(%rbx), %rdi
callq 0x125be
xorl %ebp, %ebp
testl %eax, %eax
sete %bpl
shll $0xa, %ebp
addl $0x700, %ebp            # imm = 0x700
jmp 0xc35c