// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/preprocessor/gen.c
// Function: gen_ifxdef
static void _gen_ifxdef(
	PPGeneratorContext *ctx,
	ParserASTNode *node,
	bool not
) {
	assert(ctx);
	assert(node);
	if (not) {
		assert(node->type == PP_NODE_DIRECTIVE_IFNDEF);
	} else {
		assert(node->type == PP_NODE_DIRECTIVE_IFDEF);
	}
	assert(node->nchilds >= 1);

	const char *content = node->token->content;
	int len = node->token->len;

	ResizableString key;
	rstr_init(&key);
	int idx;
	if (not) {
		char cmd[] = "#ifndef";
		idx = sizeof(cmd);
	} else {
		char cmd[] = "#ifdef";
		idx = sizeof(cmd);
	}

	#define	_GET_CHAR(i) ((i) >= len ? -1 : content[(i)])

	while (isspace(_GET_CHAR(idx))) {
		idx++;
	}

	while (_GET_CHAR(idx) != -1 && !isspace(_GET_CHAR(idx))) {
		rstr_append_with_char(&key, _GET_CHAR(idx));
		idx++;
	}

	if (RSTR_LEN(&key) == 0) {
		_SYNERR_NODE(ctx, node, "expect key.");
	}

	bool cond;
	if (not) {
		cond = !map_exists_key(ctx->map_kv, &key);
	} else {
		cond = map_exists_key(ctx->map_kv, &key);
	}

	if (cond) {
		ParserASTNode *node_block = node->childs[0];
		assert(node_block->type == PP_NODE_BLOCK);

		_gen_if_block(ctx, node_block);
	} else {
		for (int i = 1; i < node->nchilds; i++) {
			ParserASTNode *child = node->childs[i];
			if (_gen_elifxxx_and_else(ctx, child)) {
				break;
			}
		}
	}

	rstr_free(&key);

	#undef	_GET_CHAR
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x40833
jmp 0x40852
leaq 0xd327(%rip), %rdi      # 0x4db61
leaq 0xe6b4(%rip), %rsi      # 0x4eef5
movl $0x2ad, %edx            # imm = 0x2AD
leaq 0xeff7(%rip), %rcx      # 0x4f844
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x4085b
jmp 0x4087a
leaq 0xa825(%rip), %rdi      # 0x4b087
leaq 0xe68c(%rip), %rsi      # 0x4eef5
movl $0x2ae, %edx            # imm = 0x2AE
leaq 0xefcf(%rip), %rcx      # 0x4f844
callq 0xa0b0
testb $0x1, -0x11(%rbp)
je 0x408af
movq -0x10(%rbp), %rax
cmpl $0x205, (%rax)          # imm = 0x205
jne 0x4088e
jmp 0x408ad
leaq 0xefee(%rip), %rdi      # 0x4f883
leaq 0xe659(%rip), %rsi      # 0x4eef5
movl $0x2b0, %edx            # imm = 0x2B0
leaq 0xef9c(%rip), %rcx      # 0x4f844
callq 0xa0b0
jmp 0x408de
movq -0x10(%rbp), %rax
cmpl $0x204, (%rax)          # imm = 0x204
jne 0x408bd
jmp 0x408dc
leaq 0xef5a(%rip), %rdi      # 0x4f81e
leaq 0xe62a(%rip), %rsi      # 0x4eef5
movl $0x2b2, %edx            # imm = 0x2B2
leaq 0xef6d(%rip), %rcx      # 0x4f844
callq 0xa0b0
jmp 0x408de
movq -0x10(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jl 0x408ea
jmp 0x40909
leaq 0xec7b(%rip), %rdi      # 0x4f56c
leaq 0xe5fd(%rip), %rsi      # 0x4eef5
movl $0x2b4, %edx            # imm = 0x2B4
leaq 0xef40(%rip), %rcx      # 0x4f844
callq 0xa0b0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xfca0
testb $0x1, -0x11(%rbp)
je 0x4094a
movq 0xef6d(%rip), %rax      # 0x4f8aa
movq %rax, -0x44(%rbp)
movl $0x8, -0x3c(%rbp)
jmp 0x4096e
movl 0xef62(%rip), %eax      # 0x4f8b2
movl %eax, -0x4b(%rbp)
movw 0xef5c(%rip), %ax       # 0x4f8b6
movw %ax, -0x47(%rbp)
movb 0xef54(%rip), %al       # 0x4f8b8
movb %al, -0x45(%rbp)
movl $0x7, -0x3c(%rbp)
jmp 0x40970
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x478(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x40994
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x47c(%rbp)
jmp 0x409a6
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x47c(%rbp)
movq -0x478(%rbp), %rax
movl -0x47c(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x409cf
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x40970
jmp 0x409d1
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x409e6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x480(%rbp)
jmp 0x409f8
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x480(%rbp)
movl -0x480(%rbp), %ecx
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x481(%rbp)
je 0x40a68
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x490(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x40a2f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x494(%rbp)
jmp 0x40a41
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x494(%rbp)
movq -0x490(%rbp), %rax
movl -0x494(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x481(%rbp)
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0x40a74
jmp 0x40abb
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x40a89
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x498(%rbp)
jmp 0x40a9b
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x498(%rbp)
movl -0x498(%rbp), %eax
leaq -0x38(%rbp), %rdi
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x409d1
cmpl $0x0, -0x34(%rbp)
jne 0x40af5
leaq -0x450(%rbp), %rdi
leaq 0xe928(%rip), %rsi      # 0x4f3f7
movb $0x0, %al
callq 0xa170
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rdi
movq -0x10(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq *%rax
testb $0x1, -0x11(%rbp)
je 0x40b18
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0xd8f0
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x451(%rbp)
jmp 0x40b31
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0xd8f0
andb $0x1, %al
movb %al, -0x451(%rbp)
testb $0x1, -0x451(%rbp)
je 0x40b8e
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x460(%rbp)
movq -0x460(%rbp), %rax
cmpl $0x300, (%rax)          # imm = 0x300
jne 0x40b5d
jmp 0x40b7c
leaq 0xea3b(%rip), %rdi      # 0x4f59f
leaq 0xe38a(%rip), %rsi      # 0x4eef5
movl $0x2dc, %edx            # imm = 0x2DC
leaq 0xeccd(%rip), %rcx      # 0x4f844
callq 0xa0b0
movq -0x8(%rbp), %rdi
movq -0x460(%rbp), %rsi
callq 0x3fd40
jmp 0x40bee
movl $0x1, -0x464(%rbp)
movl -0x464(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x40bec
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x464(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x470(%rbp)
movq -0x8(%rbp), %rdi
movq -0x470(%rbp), %rsi
callq 0x3fe80
testb $0x1, %al
jne 0x40bd7
jmp 0x40bd9
jmp 0x40bec
jmp 0x40bdb
movl -0x464(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x464(%rbp)
jmp 0x40b98
jmp 0x40bee
leaq -0x38(%rbp), %rdi
callq 0x10320
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq