// File: /workspace/github_c_makefile_star2_O1/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 0x1eec0
movl %edx, %ebx
testl %edx, %edx
js 0x1eedf
movq %rsi, %r14
movq %rdi, %r15
je 0x1ed28
movl %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x1ed16
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x1783a(%rip), %rdx     # 0x36570
cmovneq %rax, %rdx
movl (%r15), %ecx
movq 0x30(%r15), %r8
leaq 0x1781b(%rip), %rsi     # 0x36563
movq %r14, %rdi
movq %r15, %r9
xorl %eax, %eax
callq 0xa0f0
cmpq $0x0, 0x10(%r15)
je 0x1edaa
movl $0x28, %edi
movq %r14, %rsi
callq 0xa0d0
movq 0x10(%r15), %rax
cmpl $0x0, 0x4(%rax)
jle 0x1ed97
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 0x1ed76
movl (%rax), %edx
leaq 0x177d4(%rip), %rsi     # 0x36574
movq %r14, %rdi
xorl %eax, %eax
callq 0xa0f0
movl $0xa, %edi
movq %r14, %rsi
callq 0xa0d0
cmpl $0x600, (%r15)          # imm = 0x600
jne 0x1ee8d
testl %ebx, %ebx
je 0x1ede7
cmpl $0x2, %ebx
movl $0x1, %r12d
cmovgel %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x1edd5
leaq 0x1778b(%rip), %rdi     # 0x36579
movq %r14, %rsi
callq 0xa0c0
movl 0x60(%r15), %eax
decl %eax
cmpl $0x3, %eax
jae 0x1eefe
movl %eax, %eax
leaq 0x16696(%rip), %rcx     # 0x354a4
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 0x1ee4d
cmpl $0x2, %ebx
movl $0x1, %r12d
cmovgel %ebx, %r12d
movl $0x9, %edi
movq %r14, %rsi
callq 0xa0d0
decl %r12d
jne 0x1ee3b
leaq 0x17734(%rip), %rdi     # 0x36588
movq %r14, %rsi
callq 0xa0c0
movl 0x64(%r15), %eax
cmpq $0x5, %rax
jae 0x1ef1d
leaq 0x1663f(%rip), %rcx     # 0x354b0
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 0x1eeb7
incl %ebx
xorl %r12d, %r12d
movq 0x48(%r15), %rax
movq (%rax,%r12,8), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x1eced
incq %r12
movslq 0x44(%r15), %rax
cmpq %rax, %r12
jl 0x1ee99
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13e34(%rip), %rdi     # 0x32cfb
leaq 0x165f6(%rip), %rsi     # 0x354c4
leaq 0x1764f(%rip), %rcx     # 0x36524
movl $0x9c4, %edx            # imm = 0x9C4
callq 0xa0b0
leaq 0x17672(%rip), %rdi     # 0x36558
leaq 0x165d7(%rip), %rsi     # 0x354c4
leaq 0x17630(%rip), %rcx     # 0x36524
movl $0x9c6, %edx            # imm = 0x9C6
callq 0xa0b0
leaq 0x1048f(%rip), %rdi     # 0x2f394
leaq 0x165b8(%rip), %rsi     # 0x354c4
leaq 0x17611(%rip), %rcx     # 0x36524
movl $0x9f0, %edx            # imm = 0x9F0
callq 0xa0b0
leaq 0x10470(%rip), %rdi     # 0x2f394
leaq 0x16599(%rip), %rsi     # 0x354c4
leaq 0x175f2(%rip), %rcx     # 0x36524
movl $0xa10, %edx            # imm = 0xA10
callq 0xa0b0