// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/assembler/parser.c
// Function: print_ast
static void _print_ast(
	ParserASTNode *node,
	FILE *file,
	int level,
	char padchr
) {
	assert(node);
	assert(file);
	assert(level >= 0);

	for (int i = 0; i < level; i++) {
		fputc(padchr, file);
	}

	fprintf(
		file,
		"@%s#%x#%p#%p",
		node->type_name != NULL ? node->type_name : "N/A",
		node->type,
		node->parent,
		node
	);
	if (node->token != NULL) {
		fputc('(', file);
		for (int i = 0; i < node->token->len; i++) {
			fputc(*(node->token->content + i), file);
		}
		fprintf(file, "#%x)", node->token->type);
	}
	fputc('\n', file);

	if (node->type == ASM_NODE_MEM) {
		for (int i = 0; i < level; i++) {
			fputc(padchr, file);
		}
		fputs("|MemAddrSize: ", file);
		switch (ASM_MEM_AST_NODE_GET_ADDR_SIZE(node)) {
			case ASM_MEM_ADDR_SIZE_16: {
				fputs("ADDR16", file);
				break;
			}
			case ASM_MEM_ADDR_SIZE_32: {
				fputs("ADDR32", file);
				break;
			}
			case ASM_MEM_ADDR_SIZE_64: {
				fputs("ADDR64", file);
				break;
			}
			default: {
				assert(0);
				break;
			}
		}
		fputc('\n', file);

		for (int i = 0; i < level; i++) {
			fputc(padchr, file);
		}
		fputs("|MemSize: ", file);
		switch (ASM_MEM_AST_NODE_GET_TYPE(node)) {
			case ASM_MEM_TYPE_BYTE: {
				fputs("BYTE", file);
				break;
			}
			case ASM_MEM_TYPE_WORD: {
				fputs("WORD", file);
				break;
			}
			case ASM_MEM_TYPE_DWORD: {
				fputs("DWORD", file);
				break;
			}
			case ASM_MEM_TYPE_QWORD: {
				fputs("QWORD", file);
				break;
			}
			case ASM_MEM_TYPE_UNKNOWN: {
				fputs("UNKNOWN", file);
				break;
			}
			default: {
				assert(0);
				break;
			}
		}
		fputc('\n', file);
	}

	for (int i = 0; i < node->nchilds; i++) {
		_print_ast(node->childs[i], file, level + 1, padchr);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x205fa
movl %edx, %ebx
testl %edx, %edx
js 0x20619
movq %rsi, %r14
movq %rdi, %r15
je 0x20476
movl %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x20464
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x1509c(%rip), %rdx     # 0x35520
cmovneq %rax, %rdx
movl (%r15), %ecx
movq 0x30(%r15), %r8
leaq 0x1507d(%rip), %rsi     # 0x35513
movq %r14, %rdi
movq %r15, %r9
xorl %eax, %eax
callq 0xa100
cmpq $0x0, 0x10(%r15)
je 0x204f8
movl $0x28, %edi
movq %r14, %rsi
callq 0xa0d0
movq 0x10(%r15), %rax
cmpl $0x0, 0x4(%rax)
jle 0x204e5
xorl %r12d, %r12d
movq 0x8(%rax), %rax
movsbl (%rax,%r12), %edi
movq %r14, %rsi
callq 0xa0d0
incq %r12
movq 0x10(%r15), %rax
movslq 0x4(%rax), %rcx
cmpq %rcx, %r12
jl 0x204c4
movl (%rax), %edx
leaq 0x15036(%rip), %rsi     # 0x35524
movq %r14, %rdi
xorl %eax, %eax
callq 0xa100
movl $0xa, %edi
movq %r14, %rsi
callq 0xa0d0
cmpl $0x600, (%r15)          # imm = 0x600
jne 0x205c7
testl %ebx, %ebx
je 0x2052b
movl %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x20519
leaq 0x14ff7(%rip), %rdi     # 0x35529
movq %r14, %rsi
callq 0xa0c0
movl 0x60(%r15), %eax
decl %eax
cmpl $0x3, %eax
jae 0x20638
movl %eax, %eax
leaq 0x13f02(%rip), %rcx     # 0x34454
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
movq %r14, %rsi
callq 0xa0c0
movl $0xa, %edi
movq %r14, %rsi
callq 0xa0d0
testl %ebx, %ebx
je 0x20587
movl %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x20575
leaq 0x14faa(%rip), %rdi     # 0x35538
movq %r14, %rsi
callq 0xa0c0
movl 0x64(%r15), %eax
cmpq $0x5, %rax
jae 0x20657
leaq 0x13eb5(%rip), %rcx     # 0x34460
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
movq %r14, %rsi
callq 0xa0c0
movl $0xa, %edi
movq %r14, %rsi
callq 0xa0d0
cmpl $0x0, 0x44(%r15)
jle 0x205f1
incl %ebx
xorl %r12d, %r12d
movq 0x48(%r15), %rax
movq (%rax,%r12,8), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x2043b
incq %r12
movslq 0x44(%r15), %rax
cmpq %rax, %r12
jl 0x205d3
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x116aa(%rip), %rdi     # 0x31cab
leaq 0x13e6c(%rip), %rsi     # 0x34474
leaq 0x14ec5(%rip), %rcx     # 0x354d4
movl $0x9c4, %edx            # imm = 0x9C4
callq 0xa0b0
leaq 0x14ee8(%rip), %rdi     # 0x35508
leaq 0x13e4d(%rip), %rsi     # 0x34474
leaq 0x14ea6(%rip), %rcx     # 0x354d4
movl $0x9c6, %edx            # imm = 0x9C6
callq 0xa0b0
leaq 0xdd31(%rip), %rdi      # 0x2e370
leaq 0x13e2e(%rip), %rsi     # 0x34474
leaq 0x14e87(%rip), %rcx     # 0x354d4
movl $0x9f0, %edx            # imm = 0x9F0
callq 0xa0b0
leaq 0xdd12(%rip), %rdi      # 0x2e370
leaq 0x13e0f(%rip), %rsi     # 0x34474
leaq 0x14e68(%rip), %rcx     # 0x354d4
movl $0xa10, %edx            # imm = 0xA10
callq 0xa0b0