// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %rbx
movzwl 0x8(%rsi), %eax
cmpl $0x29, %eax
je 0xb94c
cmpl $0xc, %eax
je 0xb8fa
movq %rdx, %r14
cmpl $0x1c, %eax
je 0xb904
cmpl $0x1, %eax
jne 0xb9b6
movq 0x18(%rsi), %r15
xorl %r12d, %r12d
cmpl $0x0, (%r14)
jne 0xb8de
movq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x11514
xorl %r12d, %r12d
testl %eax, %eax
setne %r12b
shll $0xc, %r12d
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x11514
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal (%r12,%rcx,4), %ebp
addl $0x6, %ebp
jmp 0xb947
movl $0x80, %ebp
jmp 0xb9b8
movq 0x18(%rsi), %r15
xorl %r12d, %r12d
cmpl $0x0, (%r14)
jne 0xb92a
movq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x1158b
xorl %r12d, %r12d
testl %eax, %eax
setne %r12b
shll $0xc, %r12d
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x1158b
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
shll $0x5, %ecx
leal (%rcx,%r12), %ebp
addl $0x30, %ebp
incl (%r14)
jmp 0xb9b8
pushq $0x8
popq %rax
movq %rsi, %rdi
movl %eax, %esi
callq 0x19d17
andl $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movl $0x100, %ebp            # imm = 0x100
testq %rax, %rax
je 0xb9b8
movq 0x8(%rax), %rsi
movzwl 0x2(%rax), %edx
movq %rsp, %r14
movq %r14, %rdi
callq 0x1a951
testq %rax, %rax
setne %cl
movzwl (%r14), %eax
testw %ax, %ax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xb9b8
movzwl %ax, %eax
cmpl $0x2, %eax
je 0xb9c7
cmpl $0x1, %eax
jne 0xb9b8
leaq 0x4(%rsp), %rsi
movq 0x20(%rbx), %rdi
callq 0x11514
jmp 0xb9d5
xorl %ebp, %ebp
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 0x1158b
xorl %ebp, %ebp
testl %eax, %eax
sete %bpl
shll $0xa, %ebp
addl $0x700, %ebp            # imm = 0x700
jmp 0xb9b8