// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_stat_while
static void _ir_stat_while(
	IRGeneratorLlvmirContext *ctx,
	ParserASTNode *node_stat_while
) {
	assert(ctx);
	assert(node_stat_while);
	assert(node_stat_while->type == FE_NODE_STAT_WHILE);

	_TMP_LABEL_DEF(ctx, while_repeat)

	_TMP_LABEL_DEF(ctx, while_true)
	_TMP_LABEL_DEF(ctx, while_false)

	rstr_append_with_rstr(
		FE_LOOP_AST_NODE_GET_LABEL_REPEAT(node_stat_while),
		&_TMP_LABEL(while_repeat)
	);
	rstr_append_with_rstr(
		FE_LOOP_AST_NODE_GET_LABEL_END(node_stat_while),
		&_TMP_LABEL(while_false)
	);

	ParserASTNode *node_while_expr = node_stat_while->childs[0];
	ParserASTNode *node_while_body = node_stat_while->childs[1];

	_ExprResult result_while_expr;
	_expr_result_init(&result_while_expr);

	rstr_appendf(
		ctx->body,
		"br label %s\n%s:\n",
		_TMP_LABEL_CSTR(while_repeat),
		_TMP_LABEL_NAME_CSTR(while_repeat)
	);

	_ir_expr_wrapper_val(ctx, ctx->body, &result_while_expr, node_while_expr);

	ResizableString rstr_label_while_cond_expr;
	rstr_init(&rstr_label_while_cond_expr);
	_ir_cond_expr(ctx, &rstr_label_while_cond_expr, &result_while_expr, node_while_expr);

	rstr_appendf(
		ctx->body,
		"br i1 %s, label %s, label %s\n",
		RSTR_CSTR(&rstr_label_while_cond_expr),
		_TMP_LABEL_CSTR(while_true),
		_TMP_LABEL_CSTR(while_false)
	);

	rstr_appendf(
		ctx->body,
		"br label %s\n%s:\n",
		_TMP_LABEL_CSTR(while_true),
		_TMP_LABEL_NAME_CSTR(while_true)
	);

	_ir_stats_block(ctx, node_while_body);

	rstr_appendf(
		ctx->body,
		"br label %s\n",
		_TMP_LABEL_CSTR(while_repeat)
	);

	rstr_appendf(
		ctx->body,
		"br label %s\n%s:\n",
		_TMP_LABEL_CSTR(while_false),
		_TMP_LABEL_NAME_CSTR(while_false)
	);

	_TMP_LABEL_FREE(while_repeat)

	_TMP_LABEL_FREE(while_true)
	_TMP_LABEL_FREE(while_false)

	_expr_result_free(&result_while_expr);

	rstr_free(&rstr_label_while_cond_expr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x3a5ac
jmp 0x3a5cb
leaq 0x41fa3(%rip), %rdi     # 0x7c556
leaq 0x3db16(%rip), %rsi     # 0x780d0
movl $0x5cd, %edx            # imm = 0x5CD
leaq 0x3f63b(%rip), %rcx     # 0x79c01
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x3a5d4
jmp 0x3a5f3
leaq 0x3bdd4(%rip), %rdi     # 0x763af
leaq 0x3daee(%rip), %rsi     # 0x780d0
movl $0x5ce, %edx            # imm = 0x5CE
leaq 0x3f613(%rip), %rcx     # 0x79c01
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xb20, (%rax)          # imm = 0xB20
jne 0x3a601
jmp 0x3a620
leaq 0x3bdb7(%rip), %rdi     # 0x763bf
leaq 0x3dac1(%rip), %rsi     # 0x780d0
movl $0x5cf, %edx            # imm = 0x5CF
leaq 0x3f5e6(%rip), %rcx     # 0x79c01
callq 0x30a0
leaq -0x20(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x20(%rbp), %rdx
callq 0x35980
leaq -0x30(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x30(%rbp), %rdx
callq 0x35980
leaq -0x40(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x40(%rbp), %rdx
callq 0x35980
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
leaq -0x20(%rbp), %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
addq $0x60, %rdi
addq $0x10, %rdi
leaq -0x40(%rbp), %rsi
callq 0x9100
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x2a260
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3a6f1
leaq 0x3d1cd(%rip), %rax     # 0x778b5
movq %rax, -0xf0(%rbp)
jmp 0x3a6fc
movq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3a721
leaq 0x3d19d(%rip), %rax     # 0x778b5
movq %rax, -0x100(%rbp)
jmp 0x3a72c
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdx
movq -0xe8(%rbp), %rdi
movq -0x100(%rbp), %rcx
addq $0x1, %rcx
leaq 0x3ef04(%rip), %rsi     # 0x79650
movb $0x0, %al
callq 0x94d0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x48(%rbp), %rcx
leaq -0xd0(%rbp), %rdx
callq 0x2a300
leaq -0xe0(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rcx
leaq -0xe0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x3c6f0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0x3a7bf
leaq 0x3d0ff(%rip), %rax     # 0x778b5
movq %rax, -0x110(%rbp)
jmp 0x3a7cd
movq -0xd8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3a7f2
leaq 0x3d0cc(%rip), %rax     # 0x778b5
movq %rax, -0x120(%rbp)
jmp 0x3a7fd
movq -0x28(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3a822
leaq 0x3d09c(%rip), %rax     # 0x778b5
movq %rax, -0x130(%rbp)
jmp 0x3a82d
movq -0x38(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rcx
movq -0x118(%rbp), %rdx
movq -0x108(%rbp), %rdi
movq -0x130(%rbp), %r8
leaq 0x3ee11(%rip), %rsi     # 0x79661
movb $0x0, %al
callq 0x94d0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3a87d
leaq 0x3d041(%rip), %rax     # 0x778b5
movq %rax, -0x140(%rbp)
jmp 0x3a888
movq -0x28(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3a8ad
leaq 0x3d011(%rip), %rax     # 0x778b5
movq %rax, -0x150(%rbp)
jmp 0x3a8b8
movq -0x28(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rdx
movq -0x138(%rbp), %rdi
movq -0x150(%rbp), %rcx
addq $0x1, %rcx
leaq 0x3ed78(%rip), %rsi     # 0x79650
movb $0x0, %al
callq 0x94d0
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x39800
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3a912
leaq 0x3cfac(%rip), %rax     # 0x778b5
movq %rax, -0x160(%rbp)
jmp 0x3a91d
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x158(%rbp), %rdi
movq -0x160(%rbp), %rdx
leaq 0x3eea7(%rip), %rsi     # 0x797d9
movb $0x0, %al
callq 0x94d0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3a95f
leaq 0x3cf5f(%rip), %rax     # 0x778b5
movq %rax, -0x170(%rbp)
jmp 0x3a96a
movq -0x38(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x178(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3a98f
leaq 0x3cf2f(%rip), %rax     # 0x778b5
movq %rax, -0x180(%rbp)
jmp 0x3a99a
movq -0x38(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x178(%rbp), %rdx
movq -0x168(%rbp), %rdi
movq -0x180(%rbp), %rcx
addq $0x1, %rcx
leaq 0x3ec96(%rip), %rsi     # 0x79650
movb $0x0, %al
callq 0x94d0
leaq -0x20(%rbp), %rdi
callq 0x9310
leaq -0x30(%rbp), %rdi
callq 0x9310
leaq -0x40(%rbp), %rdi
callq 0x9310
leaq -0xd0(%rbp), %rdi
callq 0x2c6a0
leaq -0xe0(%rbp), %rdi
callq 0x9310
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopl (%rax)