// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movb %al, -0x15(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2a261
jmp 0x2a280
leaq 0x20e1f(%rip), %rdi     # 0x4b087
leaq 0x23449(%rip), %rsi     # 0x4d6b8
movl $0x9c4, %edx            # imm = 0x9C4
leaq 0x24514(%rip), %rcx     # 0x4e78f
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x2a289
jmp 0x2a2a8
leaq 0x1c7de(%rip), %rdi     # 0x46a6e
leaq 0x23421(%rip), %rsi     # 0x4d6b8
movl $0x9c5, %edx            # imm = 0x9C5
leaq 0x244ec(%rip), %rcx     # 0x4e78f
callq 0xa0b0
cmpl $0x0, -0x14(%rbp)
jl 0x2a2b0
jmp 0x2a2cf
leaq 0x2450c(%rip), %rdi     # 0x4e7c3
leaq 0x233fa(%rip), %rsi     # 0x4d6b8
movl $0x9c6, %edx            # imm = 0x9C6
leaq 0x244c5(%rip), %rcx     # 0x4e78f
callq 0xa0b0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2a2f6
movsbl -0x15(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xa0e0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2a2d6
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2a317
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x2a324
leaq 0x244bd(%rip), %rax     # 0x4e7db
movq %rax, -0x40(%rbp)
jmp 0x2a324
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %r9
leaq 0x24489(%rip), %rsi     # 0x4e7ce
movb $0x0, %al
callq 0xa100
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2a3c0
movq -0x10(%rbp), %rsi
movl $0x28, %edi
callq 0xa0e0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x2a3a4
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %edi
movq -0x10(%rbp), %rsi
callq 0xa0e0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2a36c
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %edx
leaq 0x24426(%rip), %rsi     # 0x4e7df
movb $0x0, %al
callq 0xa100
movq -0x10(%rbp), %rsi
movl $0xa, %edi
callq 0xa0e0
movq -0x8(%rbp), %rax
cmpl $0x600, (%rax)          # imm = 0x600
jne 0x2a580
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2a405
movsbl -0x15(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xa0e0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a3e5
movq -0x10(%rbp), %rsi
leaq 0x243d4(%rip), %rdi     # 0x4e7e4
callq 0xa0c0
movq -0x8(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, -0x44(%rbp)
subl $0x1, %eax
je 0x2a43a
jmp 0x2a426
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0x2a44c
jmp 0x2a430
movl -0x44(%rbp), %eax
subl $0x3, %eax
je 0x2a45e
jmp 0x2a470
movq -0x10(%rbp), %rsi
leaq 0x227ab(%rip), %rdi     # 0x4cbf0
callq 0xa0c0
jmp 0x2a48f
movq -0x10(%rbp), %rsi
leaq 0x227a0(%rip), %rdi     # 0x4cbf7
callq 0xa0c0
jmp 0x2a48f
movq -0x10(%rbp), %rsi
leaq 0x22795(%rip), %rdi     # 0x4cbfe
callq 0xa0c0
jmp 0x2a48f
leaq 0x1cfee(%rip), %rdi     # 0x47465
leaq 0x2323a(%rip), %rsi     # 0x4d6b8
movl $0x9f0, %edx            # imm = 0x9F0
leaq 0x24305(%rip), %rcx     # 0x4e78f
callq 0xa0b0
movq -0x10(%rbp), %rsi
movl $0xa, %edi
callq 0xa0e0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2a4c4
movsbl -0x15(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xa0e0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2a4a4
movq -0x10(%rbp), %rsi
leaq 0x24324(%rip), %rdi     # 0x4e7f3
callq 0xa0c0
movq -0x8(%rbp), %rax
movl 0x64(%rax), %eax
movq %rax, -0x50(%rbp)
subq $0x4, %rax
ja 0x2a553
movq -0x50(%rbp), %rax
leaq 0x231b4(%rip), %rcx     # 0x4d6a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rsi
leaq 0x226db(%rip), %rdi     # 0x4cbdf
callq 0xa0c0
jmp 0x2a572
movq -0x10(%rbp), %rsi
leaq 0x226cf(%rip), %rdi     # 0x4cbe5
callq 0xa0c0
jmp 0x2a572
movq -0x10(%rbp), %rsi
leaq 0x226bc(%rip), %rdi     # 0x4cbe4
callq 0xa0c0
jmp 0x2a572
movq -0x10(%rbp), %rsi
leaq 0x226b0(%rip), %rdi     # 0x4cbea
callq 0xa0c0
jmp 0x2a572
movq -0x10(%rbp), %rsi
leaq 0x242b2(%rip), %rdi     # 0x4e7fe
callq 0xa0c0
jmp 0x2a572
leaq 0x1cf0b(%rip), %rdi     # 0x47465
leaq 0x23157(%rip), %rsi     # 0x4d6b8
movl $0xa10, %edx            # imm = 0xA10
leaq 0x24222(%rip), %rcx     # 0x4e78f
callq 0xa0b0
movq -0x10(%rbp), %rsi
movl $0xa, %edi
callq 0xa0e0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x2a5c1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
addl $0x1, %edx
movsbl -0x15(%rbp), %ecx
callq 0x2a240
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2a587
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)