// File: /workspace/github_c_makefile_star2_O2/Mithreindeir[P]ewcc/src/debug.c
// Function: node_debug
void node_debug(struct node *n)
{
	static char depth_str[256] = { 0 };
	static int di = 0;
	if (di > 250) {
		di = 0;
	}
	if (!n)
		return;
	if (di)
		printf("%.*s`--", di - 1, depth_str);
	switch (n->type) {
	case node_ident:
		printf("ident: %s\n", IDENT(n));
		break;
	case node_cnum:
		printf("cnum: %ld\n", CNUM(n));
		break;
	case node_unop:
		printf("unop \'%s\'\n", operator_str[UNOP(n)->op]);
		depth_str[di++] = ' ';
		depth_str[di++] = ' ';
		node_debug(UNOP(n)->term);
		di -= 2;
		break;
	case node_binop:
		printf("binop \'%s\':\n", operator_str[BINOP(n)->op]);
		depth_str[di++] = ' ';
		depth_str[di++] = '|';
		node_debug(BINOP(n)->lhs);
		depth_str[di - 1] = ' ';
		node_debug(BINOP(n)->rhs);
		di -= 2;
		break;
	case node_unit:
		for (int i = 0; i < UNIT(n)->num_decls; i++)
			node_debug(UNIT(n)->edecls[i]);
		break;
	case node_block:
		printf("block:\n");
		depth_str[di++] = ' ';
		depth_str[di++] = '|';
		for (int i = 0; i < BLOCK(n)->num_stmt; i++) {
			if ((i + 1) >= BLOCK(n)->num_stmt)
				depth_str[di - 1] = ' ';
			node_debug(BLOCK(n)->stmt_list[i]);
		}
		di -= 2;
		break;
	case node_cond:
		printf("conditional:\n");
		depth_str[di++] = '|';
		depth_str[di++] = ' ';
		node_debug(COND(n)->condition);
		if (!COND(n)->otherwise)
			depth_str[di - 2] = ' ';
		node_debug(COND(n)->body);
		depth_str[di - 2] = ' ';
		if (COND(n)->otherwise)
			node_debug(COND(n)->otherwise);
		di -= 2;;
		break;
	case node_loop:
		printf("loop:\n");
		depth_str[di++] = ' ';
		depth_str[di++] = '|';
		node_debug(LOOP(n)->init);
		node_debug(LOOP(n)->condition);
		if (!LOOP(n)->body)
			depth_str[di - 1] = ' ';
		node_debug(LOOP(n)->iter);
		depth_str[di - 1] = ' ';
		node_debug(LOOP(n)->body);
		di -= 2;
		break;
	case node_func:
		printf("func %s: ", FUNC(n)->ident);
		print_type(FUNC(n)->ftype);
		printf("\n");
		depth_str[di++] = ' ';
		depth_str[di++] = ' ';
		node_debug(FUNC(n)->body);
		di -= 2;
		break;
	case node_call:
		printf("call\n");
		depth_str[di++] = ' ';
		depth_str[di++] = '|';
		node_debug(CALL(n)->func);
		for (int i = 0; i < CALL(n)->argc;i++) {
			if ((i + 1) >= CALL(n)->argc)
				depth_str[di - 1] = ' ';
			node_debug(CALL(n)->argv[i]);
		}
		depth_str[di-1] = ' ';
		di -= 2;

		break;
	case node_decl:
		printf("decl:");
		print_type(DECL(n)->type);
		printf(" %s\n", DECL(n)->ident);
		depth_str[di++] = ' ';
		depth_str[di++] = ' ';
		if (DECL(n)->initializer) {
			node_debug(DECL(n)->initializer);
		}
		di -= 2;
		break;
	case node_empty:
		printf("empty\n");
		break;
	case node_break:
		printf("break\n");
		break;
	case node_continue:
		printf("continue\n");
		break;
	case node_return:
		printf("return\n");
		depth_str[di++] = ' ';
		depth_str[di++] = ' ';
		node_debug(RET(n));
		di -= 2;
		break;
	case node_cast:
		printf("cast: ");
		print_type(TYPE(n));
		printf("\n");
		depth_str[di++] = ' ';
		depth_str[di++] = ' ';
		node_debug(n->child);
		di -= 2;
		break;
	default:
		break;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0xb0a5(%rip), %esi      # 0xd710
cmpl $0xfa, %esi
jle 0x2684
andl $0x0, 0xb096(%rip)      # 0xd710
testq %rbx, %rbx
jne 0x26a8
jmp 0x2b0c
testq %rbx, %rbx
je 0x2b0c
testl %esi, %esi
je 0x26a8
decl %esi
leaq 0x5af4(%rip), %rdi      # 0x818e
leaq 0xaf6f(%rip), %rdx      # 0xd610
xorl %eax, %eax
callq 0x2080
movl (%rbx), %eax
cmpq $0xf, %rax
ja 0x2b0c
leaq 0x596d(%rip), %rcx      # 0x8028
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5b5d(%rip), %rdi      # 0x8228
jmp 0x29b2
leaq 0x6444(%rip), %rdi      # 0x8b1b
jmp 0x29b2
leaq 0x5b4b(%rip), %rdi      # 0x822e
callq 0x2060
movslq 0xb021(%rip), %rax      # 0xd710
leaq 0xaf1a(%rip), %r14      # 0xd610
movw $0x7c20, (%rax,%r14)    # imm = 0x7C20
addl $0x2, %eax
movl %eax, 0xb00a(%rip)      # 0xd710
movq 0x8(%rbx), %rax
movq (%rax), %rdi
callq 0x265d
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0x265d
movq 0x8(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jne 0x273b
movslq 0xafdf(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x265d
movslq 0xafc5(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
movq 0x8(%rbx), %rax
movq 0x18(%rax), %rdi
jmp 0x2af4
movq 0x8(%rbx), %rax
movq (%rax), %rsi
leaq 0x5a35(%rip), %rdi      # 0x81a1
jmp 0x2880
leaq 0x5a56(%rip), %rdi      # 0x81ce
xorl %eax, %eax
callq 0x2080
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0x75e7
movq 0x8(%rbx), %rax
movq (%rax), %rsi
leaq 0x5a02(%rip), %rdi      # 0x819c
xorl %eax, %eax
callq 0x2080
movslq 0xaf68(%rip), %rax      # 0xd710
leaq 0xae61(%rip), %rcx      # 0xd610
movw $0x2020, (%rax,%rcx)    # imm = 0x2020
leal 0x2(%rax), %ecx
movl %ecx, 0xaf52(%rip)      # 0xd710
movq 0x8(%rbx), %rcx
movq 0x10(%rcx), %rdi
testq %rdi, %rdi
jne 0x2a95
jmp 0x2b06
leaq 0x5a66(%rip), %rdi      # 0x8241
callq 0x2060
movslq 0xaf29(%rip), %rax      # 0xd710
leaq 0xae22(%rip), %r14      # 0xd610
movw $0x7c20, (%rax,%r14)    # imm = 0x7C20
addl $0x2, %eax
movl %eax, 0xaf12(%rip)      # 0xd710
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movslq 0x8(%rax), %rcx
cmpq %rcx, %r15
jge 0x2af9
leal 0x1(%r15), %edx
cmpl %edx, %ecx
jg 0x282b
movslq 0xaeef(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
movq 0x8(%rbx), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rdi
callq 0x265d
incq %r15
jmp 0x2801
xorl %r14d, %r14d
movq 0x8(%rbx), %rax
movslq 0x8(%rax), %rcx
cmpq %rcx, %r14
jge 0x2b0c
movq (%rax), %rax
movq (%rax,%r14,8), %rdi
callq 0x265d
incq %r14
jmp 0x283f
leaq 0x62d4(%rip), %rdi      # 0x8b3c
callq 0x2060
jmp 0x293c
movq 0x8(%rbx), %rax
movq (%rax), %rsi
leaq 0x5916(%rip), %rdi      # 0x8196
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x2080
leaq 0x60b8(%rip), %rdi      # 0x894b
callq 0x2060
movslq 0xae71(%rip), %rax      # 0xd710
leaq 0xad6a(%rip), %r14      # 0xd610
movw $0x7c20, (%rax,%r14)    # imm = 0x7C20
addl $0x2, %eax
movl %eax, 0xae5a(%rip)      # 0xd710
movq 0x8(%rbx), %rcx
addq $0x8, %rcx
xorl %r15d, %r15d
movq (%rcx), %rdi
callq 0x265d
movq 0x8(%rbx), %rax
movslq (%rax), %rcx
cmpq %rcx, %r15
jge 0x28ff
leal 0x1(%r15), %edx
cmpl %edx, %ecx
jg 0x28ee
movslq 0xae2c(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
movq 0x8(%rbx), %rax
leaq (,%r15,8), %rcx
addq 0x10(%rax), %rcx
incq %r15
jmp 0x28c1
movslq 0xae0a(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
addl $-0x2, %eax
movl %eax, 0xadfb(%rip)      # 0xd710
jmp 0x2b0c
leaq 0x58b3(%rip), %rdi      # 0x81d4
xorl %eax, %eax
callq 0x2080
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x75e7
pushq $0xa
popq %rdi
callq 0x2040
movslq 0xadcd(%rip), %rax      # 0xd710
leaq 0xacc6(%rip), %rcx      # 0xd610
movw $0x2020, (%rax,%rcx)    # imm = 0x2020
addl $0x2, %eax
movl %eax, 0xadb7(%rip)      # 0xd710
movq 0x8(%rbx), %rdi
jmp 0x2af4
movq 0x8(%rbx), %rax
movl 0x8(%rax), %eax
leaq 0xab40(%rip), %rcx      # 0xd4b0
movq (%rcx,%rax,8), %rsi
leaq 0x5831(%rip), %rdi      # 0x81ac
xorl %eax, %eax
callq 0x2080
movslq 0xad87(%rip), %rax      # 0xd710
leaq 0xac80(%rip), %rcx      # 0xd610
movw $0x2020, (%rax,%rcx)    # imm = 0x2020
addl $0x2, %eax
movl %eax, 0xad71(%rip)      # 0xd710
movq 0x8(%rbx), %rax
movq (%rax), %rdi
jmp 0x2af4
leaq 0x614b(%rip), %rdi      # 0x8afd
popq %rbx
popq %r14
popq %r15
jmp 0x2060
movq 0x8(%rbx), %rax
movl 0x10(%rax), %eax
leaq 0xaae6(%rip), %rcx      # 0xd4b0
movq (%rcx,%rax,8), %rsi
leaq 0x57e2(%rip), %rdi      # 0x81b7
xorl %eax, %eax
callq 0x2080
movslq 0xad2d(%rip), %rax      # 0xd710
leaq 0xac26(%rip), %r14      # 0xd610
movw $0x7c20, (%rax,%r14)    # imm = 0x7C20
addl $0x2, %eax
movl %eax, 0xad16(%rip)      # 0xd710
movq 0x8(%rbx), %rax
movq (%rax), %rdi
callq 0x265d
movslq 0xad03(%rip), %rax      # 0xd710
movb $0x20, -0x1(%rax,%r14)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
jmp 0x2af4
leaq 0x580d(%rip), %rdi      # 0x8234
callq 0x2060
movslq 0xacdd(%rip), %rax      # 0xd710
leaq 0xabd6(%rip), %r14      # 0xd610
movw $0x207c, (%rax,%r14)    # imm = 0x207C
addl $0x2, %eax
movl %eax, 0xacc6(%rip)      # 0xd710
movq 0x8(%rbx), %rax
movq (%rax), %rdi
callq 0x265d
movq 0x8(%rbx), %rax
cmpq $0x0, 0x10(%rax)
jne 0x2a72
movslq 0xaca8(%rip), %rax      # 0xd710
movb $0x20, -0x2(%rax,%r14)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0x265d
movslq 0xac8e(%rip), %rax      # 0xd710
movb $0x20, -0x2(%rax,%r14)
movq 0x8(%rbx), %rcx
movq 0x10(%rcx), %rdi
testq %rdi, %rdi
je 0x2b02
callq 0x265d
movl 0xac70(%rip), %eax      # 0xd710
addl $-0x2, %eax
jmp 0x2b06
movq 0x8(%rbx), %rax
movq (%rax), %rsi
leaq 0x5711(%rip), %rdi      # 0x81c4
xorl %eax, %eax
callq 0x2080
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0x75e7
pushq $0xa
popq %rdi
callq 0x2040
movslq 0xac3a(%rip), %rax      # 0xd710
leaq 0xab33(%rip), %rcx      # 0xd610
movw $0x2020, (%rax,%rcx)    # imm = 0x2020
addl $0x2, %eax
movl %eax, 0xac24(%rip)      # 0xd710
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x265d
addl $-0x2, 0xac10(%rip)     # 0xd710
jmp 0x2b0c
addq $-0x2, %rax
movl %eax, 0xac04(%rip)      # 0xd710
popq %rbx
popq %r14
popq %r15
retq
nop