// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/frontend/irgen_c.c
// Function: ir_type
static void _ir_type(
	IRGeneratorCContext *ctx,
	ResizableString *rstr,
	ParserASTNode *node_type
) {
	assert(ctx);
	assert(rstr);
	assert(node_type);

	switch (node_type->type) {
		case FE_NODE_TYPE_CHAR: {
			rstr_prepend_with_cstr(rstr, "char ");
			break;
		}
		case FE_NODE_TYPE_INT8: {
			rstr_prepend_with_cstr(rstr, "int8_t ");
			break;
		}
		case FE_NODE_TYPE_UINT8: {
			rstr_prepend_with_cstr(rstr, "uint8_t ");
			break;
		}
		case FE_NODE_TYPE_INT16: {
			rstr_prepend_with_cstr(rstr, "int16_t ");
			break;
		}
		case FE_NODE_TYPE_UINT16: {
			rstr_prepend_with_cstr(rstr, "uint16_t ");
			break;
		}
		case FE_NODE_TYPE_INT32: {
			rstr_prepend_with_cstr(rstr, "int32_t ");
			break;
		}
		case FE_NODE_TYPE_UINT32: {
			rstr_prepend_with_cstr(rstr, "uint32_t ");
			break;
		}
		case FE_NODE_TYPE_INT64: {
			rstr_prepend_with_cstr(rstr, "int64_t ");
			break;
		}
		case FE_NODE_TYPE_UINT64: {
			rstr_prepend_with_cstr(rstr, "uint64_t ");
			break;
		}
		case FE_NODE_TYPE_FLOAT: {
			rstr_prepend_with_cstr(rstr, "float ");
			break;
		}
		case FE_NODE_TYPE_DOUBLE: {
			rstr_prepend_with_cstr(rstr, "double ");
			break;
		}
		case FE_NODE_TYPE_VA_LIST: {
			rstr_prepend_with_cstr(rstr, "va_list ");
			break;
		}
		case FE_NODE_TYPE_STRUCT: {
			assert(node_type->nchilds == 1);

			ParserASTNode *node_id = node_type->childs[0];
			assert(node_id->type == FE_NODE_IDENTIFIER);

			rstr_prepend_with_cstr(rstr, " ");
			rstr_prepend_with_raw(rstr, node_id->token->content, node_id->token->len);
			rstr_prepend_with_cstr(rstr, "struct ");
			break;
		}
		case FE_NODE_TYPE_ARRAY: {
			assert(node_type->nchilds == 2);
			ParserASTNode *node_array_dims = node_type->childs[0];
			assert(node_array_dims->type == FE_NODE_TYPE_ARRAY_DIMS);
			ParserASTNode *node_t = node_type->childs[1];

			rstr_prepend_with_cstr(rstr, "(");
			for (int i = 0; i < node_array_dims->nchilds; i++) {
				ParserASTNode *node_array_dim = node_array_dims->childs[i];
				assert(node_array_dim->type == FE_NODE_LITERAL_UINT);
				rstr_append_with_cstr(rstr, "[");
				rstr_append_with_raw(rstr, node_array_dim->token->content, node_array_dim->token->len);
				rstr_append_with_cstr(rstr, "]");
			}
			rstr_append_with_cstr(rstr, ")");

			_ir_type(ctx, rstr, node_t);
			break;
		}
		case FE_NODE_TYPE_FUNC: {
			assert(node_type->nchilds == 1 || node_type->nchilds == 2);
			ParserASTNode *node_params = NULL;
			ParserASTNode *node_t = NULL;

			node_params = node_type->childs[0];
			if (node_type->nchilds == 2) {
				node_t = node_type->childs[1];
			}

			rstr_prepend_with_cstr(rstr, "(");
			rstr_append_with_cstr(rstr, ")(");
			_ir_func_params(ctx, rstr, node_params);
			rstr_append_with_cstr(rstr, ")");

			if (node_t != NULL) {
				_ir_type(ctx, rstr, node_t);
			} else {
				rstr_prepend_with_cstr(rstr, "void(");
				rstr_append_with_cstr(rstr, ")");
			}
			break;
		}
		case FE_NODE_TYPE_POINTER: {
			assert(node_type->nchilds == 1);
			ParserASTNode *node_t = node_type->childs[0];
			
			rstr_prepend_with_cstr(rstr, "(*");
			rstr_append_with_cstr(rstr, ")");

			_ir_type(ctx, rstr, node_t);
			break;
		}
		case FE_NODE_TYPE_VOID: {
			rstr_prepend_with_cstr(rstr, "void ");
			break;
		}
		default: {
			assert(0);
			break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x307bd(%rip), %r15     # 0x45379
leaq 0x2fd77(%rip), %r12     # 0x4493a
testq %rbx, %rbx
je 0x14e85
testq %r14, %r14
je 0x14ea4
movl (%r14), %eax
cmpl $0x42f, %eax            # imm = 0x42F
jle 0x14c23
cmpl $0x430, %eax            # imm = 0x430
je 0x14cec
cmpl $0x440, %eax            # imm = 0x440
jne 0x14d76
cmpl $0x1, 0x44(%r14)
jne 0x14f01
movq 0x48(%r14), %rax
movq (%rax), %r14
movq %rbx, %rdi
leaq 0x2fdc5(%rip), %rsi     # 0x449d6
callq 0x7f99
movq %rbx, %rdi
movq %r12, %rsi
callq 0x75cf
jmp 0x14bc3
addl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0x20, %eax
ja 0x14f3f
leaq 0x2fa38(%rip), %rcx     # 0x44670
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, 0x44(%r14)
jne 0x14ec3
movq 0x48(%r14), %rax
movq (%rax), %r13
cmpl $0x421, (%r13)          # imm = 0x421
jne 0x14ee2
movq 0x8(%rax), %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7f99
cmpl $0x0, 0x44(%r13)
jle 0x14cce
xorl %r15d, %r15d
movq 0x48(%r13), %rax
movq (%rax,%r15,8), %r12
cmpl $0x300, (%r12)          # imm = 0x300
jne 0x14e66
movq %rbx, %rdi
leaq 0x2db15(%rip), %rsi     # 0x427af
callq 0x75cf
movq 0x10(%r12), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
movq %rbx, %rdi
callq 0x7768
movq %rbx, %rdi
leaq 0x37a60(%rip), %rsi     # 0x4c71d
callq 0x75cf
incq %r15
movslq 0x44(%r13), %rax
cmpq %rax, %r15
jl 0x14c7a
movq %rbx, %rdi
leaq 0x2fc62(%rip), %r12     # 0x4493a
movq %r12, %rsi
callq 0x75cf
leaq 0x30692(%rip), %r15     # 0x45379
jmp 0x14bc3
movl 0x44(%r14), %ecx
leal -0x1(%rcx), %eax
cmpl $0x2, %eax
jae 0x14f20
movq 0x48(%r14), %rax
cmpl $0x2, %ecx
jne 0x14d0b
movq 0x8(%rax), %r14
jmp 0x14d0e
xorl %r14d, %r14d
movq (%rax), %r13
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7f99
movq %rbx, %rdi
leaq 0x2fca7(%rip), %rsi     # 0x449cd
callq 0x75cf
movq %rbx, %rdi
movq %r13, %rsi
callq 0x15083
movq %rbx, %rdi
movq %r12, %rsi
callq 0x75cf
testq %r14, %r14
jne 0x14bc3
leaq 0x2fc7f(%rip), %rsi     # 0x449d0
movq %rbx, %rdi
callq 0x7f99
leaq 0x2fbda(%rip), %rsi     # 0x4493a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x75cf
cmpl $0x4ff, %eax            # imm = 0x4FF
jne 0x14f3f
leaq 0x2fc51(%rip), %rsi     # 0x449d9
jmp 0x14e50
leaq 0x2fc21(%rip), %rsi     # 0x449b5
jmp 0x14e50
leaq 0x2fc01(%rip), %rsi     # 0x449a1
jmp 0x14e50
leaq 0x2fc18(%rip), %rsi     # 0x449c4
jmp 0x14e50
leaq 0x2fbe0(%rip), %rsi     # 0x44998
jmp 0x14e50
leaq 0x2fbd3(%rip), %rsi     # 0x44997
jmp 0x14e50
leaq 0x2fbd2(%rip), %rsi     # 0x449a2
jmp 0x14e50
leaq 0x2fbd3(%rip), %rsi     # 0x449ac
jmp 0x14e50
leaq 0x2fba6(%rip), %rsi     # 0x44988
jmp 0x14e50
leaq 0x2fba4(%rip), %rsi     # 0x4498f
jmp 0x14e50
leaq 0x2fb9a(%rip), %rsi     # 0x4498e
jmp 0x14e50
cmpl $0x1, 0x44(%r14)
jne 0x14f5e
movq 0x48(%r14), %rax
movq (%rax), %r14
cmpl $0x200, (%r14)          # imm = 0x200
jne 0x14f7d
leaq 0x2c57a(%rip), %rsi     # 0x41396
movq %rbx, %rdi
callq 0x7f99
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
movq %rbx, %rdi
callq 0x7fc9
leaq 0x2f06c(%rip), %rsi     # 0x43eaa
jmp 0x14e50
leaq 0x2fb75(%rip), %rsi     # 0x449bc
jmp 0x14e50
leaq 0x2fb5b(%rip), %rsi     # 0x449ab
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7f99
leaq 0x2d915(%rip), %rdi     # 0x42782
leaq 0x2f948(%rip), %rsi     # 0x447bc
leaq 0x2fac4(%rip), %rcx     # 0x4493f
movl $0x70, %edx
callq 0x30a0
leaq 0x2bbc4(%rip), %rdi     # 0x40a50
leaq 0x2f929(%rip), %rsi     # 0x447bc
leaq 0x2faa5(%rip), %rcx     # 0x4493f
movl $0x28, %edx
callq 0x30a0
leaq 0x2d80c(%rip), %rdi     # 0x426b7
leaq 0x2f90a(%rip), %rsi     # 0x447bc
leaq 0x2fa86(%rip), %rcx     # 0x4493f
movl $0x29, %edx
callq 0x30a0
leaq 0x2d902(%rip), %rdi     # 0x427cc
leaq 0x2f8eb(%rip), %rsi     # 0x447bc
leaq 0x2fa67(%rip), %rcx     # 0x4493f
movl $0x68, %edx
callq 0x30a0
leaq 0x2d84b(%rip), %rdi     # 0x42734
leaq 0x2f8cc(%rip), %rsi     # 0x447bc
leaq 0x2fa48(%rip), %rcx     # 0x4493f
movl $0x6a, %edx
callq 0x30a0
leaq 0x2d7f0(%rip), %rdi     # 0x426f8
leaq 0x2f8ad(%rip), %rsi     # 0x447bc
leaq 0x2fa29(%rip), %rcx     # 0x4493f
movl $0x92, %edx
callq 0x30a0
leaq 0x2d88a(%rip), %rdi     # 0x427b1
leaq 0x2f88e(%rip), %rsi     # 0x447bc
leaq 0x2fa0a(%rip), %rcx     # 0x4493f
movl $0x7b, %edx
callq 0x30a0
leaq 0x2b43e(%rip), %rdi     # 0x40384
leaq 0x2f86f(%rip), %rsi     # 0x447bc
leaq 0x2f9eb(%rip), %rcx     # 0x4493f
movl $0xa0, %edx
callq 0x30a0
leaq 0x2d793(%rip), %rdi     # 0x426f8
leaq 0x2f850(%rip), %rsi     # 0x447bc
leaq 0x2f9cc(%rip), %rcx     # 0x4493f
movl $0x5d, %edx
callq 0x30a0
leaq 0x2d78c(%rip), %rdi     # 0x42710
leaq 0x2f831(%rip), %rsi     # 0x447bc
leaq 0x2f9ad(%rip), %rcx     # 0x4493f
movl $0x60, %edx
callq 0x30a0