// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/frontend/irgen_c.c
// Function: ir_var
static void _ir_var(IRGeneratorCContext *ctx, ParserASTNode *node) {
	assert(ctx);
	assert(node);
	assert(node->type == FE_NODE_VAR);
	assert(node->nchilds > 0);

	int align = FE_VAR_AST_NODE_GET_ALIGN(node);

	for (int i = 0; i < node->nchilds; i++) {
		ParserASTNode *node_var_item = node->childs[i];
		assert(node_var_item->type == FE_NODE_VAR_ITEM);
		assert(node_var_item->nchilds == 2 || node_var_item->nchilds == 3);

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

		ResizableString rstr_type;
		rstr_init(&rstr_type);

		if (node_var_item->nchilds == 2) {
			rstr_append_with_raw(&rstr_type, node_identifier->token->content, node_identifier->token->len);

			_ir_type(ctx, &rstr_type, node_type);

			if (align > 0) {
				rstr_prependf(&rstr_type, "__attribute__((aligned(%d)))", align);
			}

			_OUT_STR(ctx, rstr_type.buffer, rstr_type.len);
		} else {
			ParserASTNode *node_expr = node_var_item->childs[2];
			
			rstr_append_with_raw(&rstr_type, node_identifier->token->content, node_identifier->token->len);

			_ir_type(ctx, &rstr_type, node_type);

			if (align > 0) {
				rstr_prependf(&rstr_type, "__attribute__((aligned(%d)))", align);
			}

			_OUT_STR(ctx, rstr_type.buffer, rstr_type.len);

			_OUT_CSTR(ctx, " = ");

			ResizableString rstr_expr;
			rstr_init(&rstr_expr);
			_ir_expr_wrapper(ctx, &rstr_expr, node_expr);
			_OUT_STR(ctx, rstr_expr.buffer, rstr_expr.len);
			rstr_free(&rstr_expr);
		}

		rstr_free(&rstr_type);

		_OUT_CSTR(ctx, "; ");
	}
	_OUT_CSTR(ctx, "\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rsi, %rsi
je 0x148a4
cmpl $0xc00, (%rsi)          # imm = 0xC00
jne 0x148c3
cmpl $0x0, 0x44(%rsi)
jle 0x148e2
movq %rdi, %rbx
movl 0x70(%rsi), %r14d
xorl %ecx, %ecx
movq %rsi, -0x58(%rbp)
movl %r14d, -0x2c(%rbp)
movq 0x48(%rsi), %rax
movq (%rax,%rcx,8), %r13
cmpl $0xc01, (%r13)          # imm = 0xC01
jne 0x14885
movl 0x44(%r13), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x14866
movq %rcx, -0x60(%rbp)
movq 0x48(%r13), %rax
movq (%rax), %r14
cmpl $0x200, (%r14)          # imm = 0x200
jne 0x14847
movq 0x8(%rax), %r15
leaq -0x40(%rbp), %r12
movq %r12, %rdi
callq 0x7354
cmpl $0x2, 0x44(%r13)
jne 0x1471a
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
movq %r12, %rdi
callq 0x7577
movq %r12, %rdi
movq %r15, %rsi
callq 0x14901
movl -0x2c(%rbp), %r14d
testl %r14d, %r14d
jle 0x146ea
movq %r12, %rdi
leaq 0x2f30f(%rip), %rsi     # 0x439ef
movl %r14d, %edx
xorl %eax, %eax
callq 0x7dfc
cmpl $0x0, -0x3c(%rbp)
jle 0x147ee
xorl %r15d, %r15d
movq -0x38(%rbp), %rax
movsbl (%rax,%r15), %edi
movq 0x8(%rbx), %rsi
callq 0x30c0
incq %r15
movslq -0x3c(%rbp), %rax
cmpq %rax, %r15
jl 0x146f7
jmp 0x147ee
movq 0x48(%r13), %rax
movq 0x10(%rax), %r13
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
movq %r12, %rdi
callq 0x7577
movq %r12, %rdi
movq %r15, %rsi
callq 0x14901
movl -0x2c(%rbp), %edx
testl %edx, %edx
jle 0x14758
movq %r12, %rdi
leaq 0x2f29e(%rip), %rsi     # 0x439ef
xorl %eax, %eax
callq 0x7dfc
cmpl $0x0, -0x3c(%rbp)
jle 0x1477f
xorl %r15d, %r15d
movq -0x38(%rbp), %rax
movsbl (%rax,%r15), %edi
movq 0x8(%rbx), %rsi
callq 0x30c0
incq %r15
movslq -0x3c(%rbp), %rax
cmpq %rax, %r15
jl 0x14761
xorl %r14d, %r14d
leaq 0x30b8e(%rip), %r15     # 0x45317
movsbl (%r14,%r15), %edi
movq 0x8(%rbx), %rsi
callq 0x30c0
incq %r14
cmpq $0x3, %r14
jne 0x14789
leaq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x7354
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x14cf9
cmpl $0x0, -0x4c(%rbp)
jle 0x147e1
xorl %r15d, %r15d
movq -0x48(%rbp), %rax
movsbl (%rax,%r15), %edi
movq 0x8(%rbx), %rsi
callq 0x30c0
incq %r15
movslq -0x4c(%rbp), %rax
cmpq %rax, %r15
jl 0x147c3
leaq -0x50(%rbp), %rdi
callq 0x7852
leaq -0x40(%rbp), %r12
movq %r12, %rdi
callq 0x7852
movq 0x8(%rbx), %rsi
movl $0x3b, %edi
callq 0x30c0
movq 0x8(%rbx), %rsi
movl $0x20, %edi
callq 0x30c0
movq -0x60(%rbp), %rcx
incq %rcx
movq -0x58(%rbp), %rsi
movslq 0x44(%rsi), %rax
cmpq %rax, %rcx
jl 0x1465a
movq 0x8(%rbx), %rsi
movl $0xa, %edi
callq 0x30c0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2cdac(%rip), %rdi     # 0x415fa
leaq 0x2f037(%rip), %rsi     # 0x4388c
leaq 0x2f15e(%rip), %rcx     # 0x439ba
movl $0x4c7, %edx            # imm = 0x4C7
callq 0x30a0
leaq 0x2cd52(%rip), %rdi     # 0x415bf
leaq 0x2f018(%rip), %rsi     # 0x4388c
leaq 0x2f13f(%rip), %rcx     # 0x439ba
movl $0x4c4, %edx            # imm = 0x4C4
callq 0x30a0
leaq 0x2cd0b(%rip), %rdi     # 0x41597
leaq 0x2eff9(%rip), %rsi     # 0x4388c
leaq 0x2f120(%rip), %rcx     # 0x439ba
movl $0x4c3, %edx            # imm = 0x4C3
callq 0x30a0
leaq 0x2e537(%rip), %rdi     # 0x42de2
leaq 0x2efda(%rip), %rsi     # 0x4388c
leaq 0x2f101(%rip), %rcx     # 0x439ba
movl $0x4bb, %edx            # imm = 0x4BB
callq 0x30a0
leaq 0x3658d(%rip), %rdi     # 0x4ae57
leaq 0x2efbb(%rip), %rsi     # 0x4388c
leaq 0x2f0e2(%rip), %rcx     # 0x439ba
movl $0x4bc, %edx            # imm = 0x4BC
callq 0x30a0
leaq 0x2cc9c(%rip), %rdi     # 0x41585
leaq 0x2ef9c(%rip), %rsi     # 0x4388c
leaq 0x2f0c3(%rip), %rcx     # 0x439ba
movl $0x4bd, %edx            # imm = 0x4BD
callq 0x30a0