// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_struct
static void _ir_struct(IRGeneratorLlvmirContext *ctx, ParserASTNode *node) {
	assert(ctx);
	assert(node);
	assert(node->type == FE_NODE_STRUCT);
	assert(node->nchilds == 2);

	ParserASTNode *node_identifier = node->childs[0];
	assert(node_identifier->type == FE_NODE_IDENTIFIER);
	ParserASTNode *node_struct_body = node->childs[1];
	if (node_struct_body->type == FE_NODE_DUMMY) {
		return;
	}
	assert(node_struct_body->type == FE_NODE_STRUCT_BODY);

	rstr_append_with_cstr(ctx->body, "%struct.");
	rstr_append_with_raw(ctx->body, node_identifier->token->content, node_identifier->token->len);
	if (FE_STRUCT_AST_NODE_GET_PACKED(node)) {
		rstr_append_with_cstr(ctx->body, " = type <{");
	} else {
		rstr_append_with_cstr(ctx->body, " = type {");
	}

	for (int i = 0; i < node_struct_body->nchilds; i++) {
		ParserASTNode *node_var = node_struct_body->childs[i];
		assert(node_var->type == FE_NODE_VAR);

		for (int j = 0; j < node_var->nchilds; j++) {
			ParserASTNode *node_var_item = node_var->childs[j];
			assert(node_var_item->type == FE_NODE_VAR_ITEM);
			assert(node_var_item->nchilds >= 2);

			ParserASTNode *node_type = node_var_item->childs[1];

			ResizableString rstr_type;
			rstr_init(&rstr_type);

			_ir_type(ctx, &rstr_type, node_type);
			rstr_append_with_rstr(ctx->body, &rstr_type);

			rstr_free(&rstr_type);

			if (i + 1 < node_struct_body->nchilds
					|| j + 1 < node_var->nchilds) {
				rstr_append_with_cstr(ctx->body, ", ");
			}
		}
	}
	
	if (FE_STRUCT_AST_NODE_GET_PACKED(node)) {
		rstr_append_with_cstr(ctx->body, "}>\n");
	} else {
		rstr_append_with_cstr(ctx->body, "}\n");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x28d79
jmp 0x28d98
leaq 0x537d6(%rip), %rdi     # 0x7c556
leaq 0x4f349(%rip), %rsi     # 0x780d0
movl $0x4a6, %edx            # imm = 0x4A6
leaq 0x50c65(%rip), %rcx     # 0x799f8
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x28da1
jmp 0x28dc0
leaq 0x4d22b(%rip), %rdi     # 0x75fd3
leaq 0x4f321(%rip), %rsi     # 0x780d0
movl $0x4a7, %edx            # imm = 0x4A7
leaq 0x50c3d(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xd00, (%rax)          # imm = 0xD00
jne 0x28dce
jmp 0x28ded
leaq 0x5597a(%rip), %rdi     # 0x7e74f
leaq 0x4f2f4(%rip), %rsi     # 0x780d0
movl $0x4a8, %edx            # imm = 0x4A8
leaq 0x50c10(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x28df9
jmp 0x28e18
leaq 0x55874(%rip), %rdi     # 0x7e674
leaq 0x4f2c9(%rip), %rsi     # 0x780d0
movl $0x4a9, %edx            # imm = 0x4A9
leaq 0x50be5(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x28e35
jmp 0x28e54
leaq 0x4b7ee(%rip), %rdi     # 0x7462a
leaq 0x4f28d(%rip), %rsi     # 0x780d0
movl $0x4ac, %edx            # imm = 0x4AC
leaq 0x50ba9(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x900, (%rax)          # imm = 0x900
jne 0x28e75
jmp 0x290b3
movq -0x20(%rbp), %rax
cmpl $0xd01, (%rax)          # imm = 0xD01
jne 0x28e83
jmp 0x28ea2
leaq 0x50bab(%rip), %rdi     # 0x79a35
leaq 0x4f23f(%rip), %rsi     # 0x780d0
movl $0x4b1, %edx            # imm = 0x4B1
leaq 0x50b5b(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x4f543(%rip), %rsi     # 0x783f4
callq 0x8d70
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %edx
callq 0x8f90
movq -0x10(%rbp), %rax
testb $0x1, 0x68(%rax)
je 0x28efa
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x50b70(%rip), %rsi     # 0x79a63
callq 0x8d70
jmp 0x28f0e
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x50b65(%rip), %rsi     # 0x79a6e
callq 0x8d70
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x2907f
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0xc00, (%rax)          # imm = 0xC00
jne 0x28f47
jmp 0x28f66
leaq 0x4d1ae(%rip), %rdi     # 0x760fc
leaq 0x4f17b(%rip), %rsi     # 0x780d0
movl $0x4bd, %edx            # imm = 0x4BD
leaq 0x50a97(%rip), %rcx     # 0x799f8
callq 0x30a0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x2906f
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0xc01, (%rax)          # imm = 0xC01
jne 0x28f9f
jmp 0x28fbe
leaq 0x4b621(%rip), %rdi     # 0x745c7
leaq 0x4f123(%rip), %rsi     # 0x780d0
movl $0x4c1, %edx            # imm = 0x4C1
leaq 0x50a3f(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x40(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jl 0x28fca
jmp 0x28fe9
leaq 0x50aa7(%rip), %rdi     # 0x79a78
leaq 0x4f0f8(%rip), %rsi     # 0x780d0
movl $0x4c2, %edx            # imm = 0x4C2
leaq 0x50a14(%rip), %rcx     # 0x799f8
callq 0x30a0
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0x299e0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9100
leaq -0x58(%rbp), %rdi
callq 0x9310
movl -0x24(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jl 0x2904b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movq -0x30(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jge 0x2905f
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x4c16f(%rip), %rsi     # 0x751c9
callq 0x8d70
jmp 0x29061
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x28f6d
jmp 0x29071
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x28f15
movq -0x10(%rbp), %rax
testb $0x1, 0x68(%rax)
je 0x2909f
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x509fc(%rip), %rsi     # 0x79a94
callq 0x8d70
jmp 0x290b3
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x4f0c9(%rip), %rsi     # 0x78177
callq 0x8d70
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)