// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/preprocessor/gen.c
// Function: gen_define
static void _gen_define(
	PPGeneratorContext *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == PP_NODE_DIRECTIVE_DEFINE);

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

	char cmd[] = "#define";
	ResizableString *key = rstr_new();
	ResizableString *value = rstr_new();
	int idx = sizeof(cmd);

	#define	_GET_CHAR(i) ((i) >= len ? -1 : content[(i)])
	#define	_IGNORE_SPACE	\
		while (isspace(_GET_CHAR(idx))) {	\
			idx++;	\
		}

	_IGNORE_SPACE

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

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

	if (_is_macro_defined(ctx, key)) {
		_SYNERR_NODE(ctx, node, "macro is defined.");
	}

	if (_GET_CHAR(idx) == '(') {
		idx++;

		PPGeneratorFuncMacro *macro = _new_gen_func_macro();

		for (;;) {
			_IGNORE_SPACE

			if (_GET_CHAR(idx) == ')') {
				idx++;
				break;
			}

			ResizableString *param = rstr_new();
			while (util_is_identifier_item(_GET_CHAR(idx))) {
				rstr_append_with_char(param, _GET_CHAR(idx));
				idx++;
			}
			if (RSTR_LEN(param) == 0) {
				_SYNERR_NODE(ctx, node, "expect identifier.");
			}
			llst_append(&(macro->params), param);

			_IGNORE_SPACE

			if (_GET_CHAR(idx) == ')') {
				idx++;
				break;
			}

			if (_GET_CHAR(idx) == ',') {
				idx++;
			} else {
				_SYNERR_NODE(ctx, node, "expect ','.");
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1100, %rsp           # imm = 0x1100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x3ddac
jmp 0x3ddcb
leaq 0xfdae(%rip), %rdi      # 0x4db61
leaq 0x1113b(%rip), %rsi     # 0x4eef5
movl $0x131, %edx            # imm = 0x131
leaq 0x115ca(%rip), %rcx     # 0x4f390
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x3ddd4
jmp 0x3ddf3
leaq 0xd2ac(%rip), %rdi      # 0x4b087
leaq 0x11113(%rip), %rsi     # 0x4eef5
movl $0x132, %edx            # imm = 0x132
leaq 0x115a2(%rip), %rcx     # 0x4f390
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpl $0x201, (%rax)          # imm = 0x201
jne 0x3de01
jmp 0x3de20
leaq 0x115c0(%rip), %rdi     # 0x4f3c8
leaq 0x110e6(%rip), %rsi     # 0x4eef5
movl $0x133, %edx            # imm = 0x133
leaq 0x11575(%rip), %rcx     # 0x4f390
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)
movq 0x115aa(%rip), %rax     # 0x4f3ef
movq %rax, -0x24(%rbp)
callq 0x101f0
movq %rax, -0x30(%rbp)
callq 0x101f0
movq %rax, -0x38(%rbp)
movl $0x8, -0x3c(%rbp)
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x1058(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3de86
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x105c(%rbp)
jmp 0x3de98
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x105c(%rbp)
movq -0x1058(%rbp), %rax
movl -0x105c(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3dec1
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3de62
jmp 0x3dec3
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3ded8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1060(%rbp)
jmp 0x3deea
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1060(%rbp)
movl -0x1060(%rbp), %ecx
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x1061(%rbp)
je 0x3df38
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3df12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1068(%rbp)
jmp 0x3df24
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1068(%rbp)
movl -0x1068(%rbp), %eax
movsbl %al, %edi
callq 0x12b20
movb %al, -0x1061(%rbp)
movb -0x1061(%rbp), %al
testb $0x1, %al
jne 0x3df44
jmp 0x3df99
movq -0x30(%rbp), %rax
movq %rax, -0x1070(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3df64
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1074(%rbp)
jmp 0x3df76
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1074(%rbp)
movq -0x1070(%rbp), %rdi
movl -0x1074(%rbp), %eax
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3dec3
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x3dfd7
leaq -0x440(%rbp), %rdi
leaq 0x11446(%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 -0x440(%rbp), %rdx
callq *%rax
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3fb80
testb $0x1, %al
jne 0x3dfea
jmp 0x3e01e
leaq -0x840(%rbp), %rdi
leaq 0x1140b(%rip), %rsi     # 0x4f403
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 -0x840(%rbp), %rdx
callq *%rax
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e033
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1078(%rbp)
jmp 0x3e045
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1078(%rbp)
movl -0x1078(%rbp), %eax
cmpl $0x28, %eax
jne 0x3e422
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
callq 0x3fc20
movq %rax, -0x848(%rbp)
jmp 0x3e06b
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x1080(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e08f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1084(%rbp)
jmp 0x3e0a1
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1084(%rbp)
movq -0x1080(%rbp), %rax
movl -0x1084(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3e0ca
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e06b
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e0df
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1088(%rbp)
jmp 0x3e0f1
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1088(%rbp)
movl -0x1088(%rbp), %eax
cmpl $0x29, %eax
jne 0x3e10a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e30f
callq 0x101f0
movq %rax, -0x850(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e12b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x108c(%rbp)
jmp 0x3e13d
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x108c(%rbp)
movl -0x108c(%rbp), %eax
movsbl %al, %edi
callq 0x12b20
testb $0x1, %al
jne 0x3e151
jmp 0x3e1a9
movq -0x850(%rbp), %rax
movq %rax, -0x1098(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e174
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x109c(%rbp)
jmp 0x3e186
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x109c(%rbp)
movq -0x1098(%rbp), %rdi
movl -0x109c(%rbp), %eax
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e116
movq -0x850(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x3e1ea
leaq -0xc50(%rbp), %rdi
leaq 0x11251(%rip), %rsi     # 0x4f415
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 -0xc50(%rbp), %rdx
callq *%rax
movq -0x848(%rbp), %rdi
movq -0x850(%rbp), %rsi
callq 0xc920
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x10a8(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e221
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10ac(%rbp)
jmp 0x3e233
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10ac(%rbp)
movq -0x10a8(%rbp), %rax
movl -0x10ac(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3e25c
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e1fd
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e271
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10b0(%rbp)
jmp 0x3e283
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10b0(%rbp)
movl -0x10b0(%rbp), %eax
cmpl $0x29, %eax
jne 0x3e299
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e30f
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e2ae
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10b4(%rbp)
jmp 0x3e2c0
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10b4(%rbp)
movl -0x10b4(%rbp), %eax
cmpl $0x2c, %eax
jne 0x3e2d6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e30a
leaq -0x1050(%rbp), %rdi
leaq 0x11144(%rip), %rsi     # 0x4f428
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 -0x1050(%rbp), %rdx
callq *%rax
jmp 0x3e069
jmp 0x3e311
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x10c0(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e335
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10c4(%rbp)
jmp 0x3e347
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10c4(%rbp)
movq -0x10c0(%rbp), %rax
movl -0x10c4(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3e370
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e311
jmp 0x3e372
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e387
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10c8(%rbp)
jmp 0x3e399
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10c8(%rbp)
movl -0x10c8(%rbp), %eax
cmpl $-0x1, %eax
je 0x3e400
movq -0x848(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x10d0(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e3cb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10d4(%rbp)
jmp 0x3e3dd
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10d4(%rbp)
movq -0x10d0(%rbp), %rdi
movl -0x10d4(%rbp), %eax
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e372
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x848(%rbp), %rdx
movl $0x1, %ecx
callq 0xd460
jmp 0x3e526
jmp 0x3e424
callq 0xa1a0
movq (%rax), %rax
movq %rax, -0x10e0(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e448
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10e4(%rbp)
jmp 0x3e45a
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10e4(%rbp)
movq -0x10e0(%rbp), %rax
movl -0x10e4(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3e483
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e424
jmp 0x3e485
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e49a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10e8(%rbp)
jmp 0x3e4ac
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10e8(%rbp)
movl -0x10e8(%rbp), %eax
cmpl $-0x1, %eax
je 0x3e50c
movq -0x38(%rbp), %rax
movq %rax, -0x10f0(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x3e4d7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10f4(%rbp)
jmp 0x3e4e9
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10f4(%rbp)
movq -0x10f0(%rbp), %rdi
movl -0x10f4(%rbp), %eax
movsbl %al, %esi
callq 0xfeb0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3e485
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0xd460
addq $0x1100, %rsp           # imm = 0x1100
popq %rbp
retq
nop