// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1f95d
movl %edx, %ebx
testl %edx, %edx
js 0x1f97c
movq %rsi, %r14
movq %rdi, %r15
pushq $0x9
popq %r12
movl %ebx, %r13d
subl $0x1, %r13d
jb 0x1f7e6
movl %r12d, %edi
movq %r14, %rsi
callq 0xa0d0
jmp 0x1f7d3
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x14dbb(%rip), %rdx     # 0x345af
cmovneq %rax, %rdx
movl (%r15), %ecx
movq 0x30(%r15), %r8
leaq 0x14d9c(%rip), %rsi     # 0x345a2
movq %r14, %rdi
movq %r15, %r9
xorl %eax, %eax
callq 0xa0f0
cmpq $0x0, 0x10(%r15)
je 0x1f85e
pushq $0x28
popq %rdi
movq %r14, %rsi
callq 0xa0d0
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movslq 0x4(%rax), %rcx
cmpq %rcx, %r12
jge 0x1f84b
movq 0x8(%rax), %rax
movsbl (%rax,%r12), %edi
movq %r14, %rsi
callq 0xa0d0
incq %r12
jmp 0x1f828
movl (%rax), %edx
leaq 0x14d5f(%rip), %rsi     # 0x345b3
movq %r14, %rdi
xorl %eax, %eax
callq 0xa0f0
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0xa0d0
cmpl $0x600, (%r15)          # imm = 0x600
jne 0x1f929
pushq $0x9
popq %r12
movl %ebx, %r13d
subl $0x1, %r13d
jb 0x1f890
movl %r12d, %edi
movq %r14, %rsi
callq 0xa0d0
jmp 0x1f87d
leaq 0x14d21(%rip), %rdi     # 0x345b8
movq %r14, %rsi
callq 0xa0c0
movl 0x60(%r15), %eax
decl %eax
cmpl $0x3, %eax
jae 0x1f99b
movl %eax, %eax
leaq 0x13bd9(%rip), %rcx     # 0x33490
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
movq %r14, %rsi
callq 0xa0c0
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0xa0d0
pushq $0x9
popq %r12
movl %ebx, %r13d
subl $0x1, %r13d
jb 0x1f8eb
movl %r12d, %edi
movq %r14, %rsi
callq 0xa0d0
jmp 0x1f8d8
leaq 0x14cd5(%rip), %rdi     # 0x345c7
movq %r14, %rsi
callq 0xa0c0
movl 0x64(%r15), %eax
cmpq $0x5, %rax
jae 0x1f9ba
leaq 0x13b8d(%rip), %rcx     # 0x3349c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
movq %r14, %rsi
callq 0xa0c0
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0xa0d0
incl %ebx
xorl %r12d, %r12d
movslq 0x44(%r15), %rax
cmpq %rax, %r12
jge 0x1f94e
movq 0x48(%r15), %rax
movq (%rax,%r12,8), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x1f7a5
incq %r12
jmp 0x1f92e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11357(%rip), %rdi     # 0x30cbb
leaq 0x13b45(%rip), %rsi     # 0x334b0
leaq 0x14bf1(%rip), %rcx     # 0x34563
movl $0x9c4, %edx            # imm = 0x9C4
callq 0xa0b0
leaq 0x14c14(%rip), %rdi     # 0x34597
leaq 0x13b26(%rip), %rsi     # 0x334b0
leaq 0x14bd2(%rip), %rcx     # 0x34563
movl $0x9c6, %edx            # imm = 0x9C6
callq 0xa0b0
leaq 0xd9ce(%rip), %rdi      # 0x2d370
leaq 0x13b07(%rip), %rsi     # 0x334b0
leaq 0x14bb3(%rip), %rcx     # 0x34563
movl $0x9f0, %edx            # imm = 0x9F0
callq 0xa0b0
leaq 0xd9af(%rip), %rdi      # 0x2d370
leaq 0x13ae8(%rip), %rsi     # 0x334b0
leaq 0x14b94(%rip), %rcx     # 0x34563
movl $0xa10, %edx            # imm = 0xA10
callq 0xa0b0