// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/preprocessor/gen.c
// Function: gen_elif
static bool _gen_elif(
	PPGeneratorContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == PP_NODE_DIRECTIVE_ELIF);
	assert(node->nchilds == 1);

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

	char cmd[] = "#elif";
	ResizableString temp;
	rstr_init(&temp);
	int idx = sizeof(cmd);

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

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

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

	ResizableString expr;
	rstr_init(&expr);

	rstr_rtrim_ex(&expr, &temp, RSTR_SPACE_CHAR_COMPARER);

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

	bool cond = pp_eval(ctx, RSTR_CSTR(&expr), RSTR_LEN(&expr)) != 0;

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

		_gen_if_block(ctx, node_block);
	}

	rstr_free(&expr);

	rstr_free(&temp);

	#undef	_GET_CHAR

	return cond;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x4018c
jmp 0x401ab
leaq 0xd9ce(%rip), %rdi      # 0x4db61
leaq 0xed5b(%rip), %rsi      # 0x4eef5
movl $0x1b7, %edx            # imm = 0x1B7
leaq 0xf4de(%rip), %rcx      # 0x4f684
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x401b4
jmp 0x401d3
leaq 0xaecc(%rip), %rdi      # 0x4b087
leaq 0xed33(%rip), %rsi      # 0x4eef5
movl $0x1b8, %edx            # imm = 0x1B8
leaq 0xf4b6(%rip), %rcx      # 0x4f684
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpl $0x206, (%rax)          # imm = 0x206
jne 0x401e1
jmp 0x40200
leaq 0xf4d3(%rip), %rdi      # 0x4f6bb
leaq 0xed06(%rip), %rsi      # 0x4eef5
movl $0x1b9, %edx            # imm = 0x1B9
leaq 0xf489(%rip), %rcx      # 0x4f684
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jne 0x4020c
jmp 0x4022b
leaq 0xa863(%rip), %rdi      # 0x4aa76
leaq 0xecdb(%rip), %rsi      # 0x4eef5
movl $0x1ba, %edx            # imm = 0x1BA
leaq 0xf45e(%rip), %rcx      # 0x4f684
callq 0xa0b0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movl 0xf491(%rip), %eax      # 0x4f6e0
movl %eax, -0x22(%rbp)
movw 0xf48b(%rip), %ax       # 0x4f6e4
movw %ax, -0x1e(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xfca0
movl $0x6, -0x3c(%rbp)
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x468(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x40291
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x46c(%rbp)
jmp 0x402a3
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x46c(%rbp)
movq -0x468(%rbp), %rax
movl -0x46c(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x402cc
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4026d
jmp 0x402ce
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x402e3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x470(%rbp)
jmp 0x402f5
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x470(%rbp)
movl -0x470(%rbp), %eax
cmpl $-0x1, %eax
je 0x40344
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x40315
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x474(%rbp)
jmp 0x40327
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x474(%rbp)
movl -0x474(%rbp), %eax
leaq -0x38(%rbp), %rdi
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x402ce
leaq -0x50(%rbp), %rdi
callq 0xfca0
leaq -0x50(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x2ef4c(%rip), %rdx    # 0x11410
callq 0x115c0
cmpl $0x0, -0x4c(%rbp)
jne 0x4039b
leaq -0x450(%rbp), %rdi
leaq 0xf20e(%rip), %rsi      # 0x4f583
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
movq -0x8(%rbp), %rax
movq %rax, -0x480(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x403bd
leaq 0x74d3(%rip), %rax      # 0x47887
movq %rax, -0x488(%rbp)
jmp 0x403c8
movq -0x48(%rbp), %rax
movq %rax, -0x488(%rbp)
movq -0x480(%rbp), %rdi
movq -0x488(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x36380
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x451(%rbp)
testb $0x1, -0x451(%rbp)
je 0x40447
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 0x40418
jmp 0x40437
leaq 0xf180(%rip), %rdi      # 0x4f59f
leaq 0xeacf(%rip), %rsi      # 0x4eef5
movl $0x1dc, %edx            # imm = 0x1DC
leaq 0xf252(%rip), %rcx      # 0x4f684
callq 0xa0b0
movq -0x8(%rbp), %rdi
movq -0x460(%rbp), %rsi
callq 0x3fd40
leaq -0x50(%rbp), %rdi
callq 0x10320
leaq -0x38(%rbp), %rdi
callq 0x10320
movb -0x451(%rbp), %al
andb $0x1, %al
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
nopw (%rax,%rax)