// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: asm_stat_cbr
static void _asm_stat_cbr(
	ASMGeneratorGas32Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_CBR);
	assert(node->nchilds == 3);

	ParserASTNode *node_cond = node->childs[0];

	ParserASTNode *node_label_true = node->childs[1];
	assert(node_label_true->type == BE_NODE_IDENTIFIER);
	ResizableString rstr_label_true;
	rstr_init(&rstr_label_true);
	_out_label(ctx, &rstr_label_true, NULL, node_label_true);

	ParserASTNode *node_label_false = node->childs[2];
	assert(node_label_false->type == BE_NODE_IDENTIFIER);
	ResizableString rstr_label_false;
	rstr_init(&rstr_label_false);
	_out_label(ctx, &rstr_label_false, NULL, node_label_false);

	if (node_cond->type == BE_NODE_IDENTIFIER) {
		ParserSymbol *symbol_cond = _get_symbol_by_id_node(ctx, node_cond);
		if (symbol_cond->type == BE_SYM_VAR) {
			uint8_t cond_type = BE_VAR_SYMBOL_GET_TYPE(symbol_cond);
			if (cond_type == BE_TYPE_UINT64 || cond_type == BE_TYPE_INT64) {
				ParserSymbol *symbol_cond_l = _instantiate_varsym(ctx, symbol_cond, 0);
				ParserSymbol *symbol_cond_h = _instantiate_varsym(ctx, symbol_cond, 4);

				_asm_inst_mov_x_sym(
					ctx,
					ctx->body,
					_ASM_REG_NAME_EAX,
					symbol_cond_l
				);

				_asm_inst_mov_x_sym(
					ctx,
					ctx->body,
					_ASM_REG_NAME_EBX,
					symbol_cond_h
				);

				_asm_inst_or_x_x(
					ctx,
					ctx->body,
					BE_TYPE_UINT32,
					_ASM_REG_NAME_EAX,
					_ASM_REG_NAME_EBX
				);

				_free_varsym(ctx, symbol_cond_l);
				_free_varsym(ctx, symbol_cond_h);
			} else {
				ParserSymbol *symbol_cond_l = _instantiate_varsym(ctx, symbol_cond, 0);

				_asm_inst_cmp_sym_x(
					ctx,
					ctx->body,
					symbol_cond_l,
					_ASM_CONST_0
				);

				_free_varsym(ctx, symbol_cond_l);			
			}
		} else if (symbol_cond->type == BE_SYM_FUNC) {
			_asm_inst_mov_x_fsym(
				ctx,
				ctx->body,
				_ASM_REG_NAME_EAX,
				symbol_cond
			);

			_asm_inst_cmp_x_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT32,
				_ASM_REG_NAME_EAX,
				_ASM_CONST_0
			);
		} else {
			assert(0);
		}
	} else if (node_cond->type == BE_NODE_EXPR) {
		uint8_t cond_type = _move_id_or_constexpr_to_reg(
			ctx,
			_ASM_REG_AX,
			_ASM_REG_BX,
			node_cond
		);

		if (cond_type == BE_TYPE_UINT64 || cond_type == BE_TYPE_INT64) {
			_asm_inst_or_x_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT32,
				_ASM_REG_NAME_EAX,
				_ASM_REG_NAME_EBX
			);
		} else {
			_asm_inst_cmp_x_x(
				ctx,
				ctx->body,
				cond_type,
				_asm_inst_reg(ctx, cond_type, _ASM_REG_AX),
				_ASM_CONST_0
			);
		}
	} else {
		assert(0);
	}

	_asm_inst_jz_x(ctx, ctx->body, RSTR_CSTR(&rstr_label_false));
	_asm_inst_jnz_x(ctx, ctx->body, RSTR_CSTR(&rstr_label_true));

	rstr_free(&rstr_label_true);
	rstr_free(&rstr_label_false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x12ddc
jmp 0x12dfb
leaq 0x6d37e(%rip), %rdi     # 0x80161
leaq 0x62b0e(%rip), %rsi     # 0x758f8
movl $0x11dd, %edx           # imm = 0x11DD
leaq 0x642e9(%rip), %rcx     # 0x770df
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x12e04
jmp 0x12e23
leaq 0x63751(%rip), %rdi     # 0x7655c
leaq 0x62ae6(%rip), %rsi     # 0x758f8
movl $0x11de, %edx           # imm = 0x11DE
leaq 0x642c1(%rip), %rcx     # 0x770df
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xba0, (%rax)          # imm = 0xBA0
jne 0x12e31
jmp 0x12e50
leaq 0x642e7(%rip), %rdi     # 0x7711f
leaq 0x62ab9(%rip), %rsi     # 0x758f8
movl $0x11df, %edx           # imm = 0x11DF
leaq 0x64294(%rip), %rcx     # 0x770df
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x3, 0x44(%rax)
jne 0x12e5c
jmp 0x12e7b
leaq 0x642db(%rip), %rdi     # 0x7713e
leaq 0x62a8e(%rip), %rsi     # 0x758f8
movl $0x11e0, %edx           # imm = 0x11E0
leaq 0x64269(%rip), %rcx     # 0x770df
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x12ea8
jmp 0x12ec7
leaq 0x642a2(%rip), %rdi     # 0x77151
leaq 0x62a42(%rip), %rsi     # 0x758f8
movl $0x11e5, %edx           # imm = 0x11E5
leaq 0x6421d(%rip), %rcx     # 0x770df
callq 0x30a0
leaq -0x30(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x224b0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x12f03
jmp 0x12f22
leaq 0x64273(%rip), %rdi     # 0x7717d
leaq 0x629e7(%rip), %rsi     # 0x758f8
movl $0x11eb, %edx           # imm = 0x11EB
leaq 0x641c2(%rip), %rcx     # 0x770df
callq 0x30a0
leaq -0x48(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rcx
leaq -0x48(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x224b0
movq -0x18(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x130de
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1f800
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1306d
movq -0x50(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x51(%rbp)
movzbl -0x51(%rbp), %eax
cmpl $0x9, %eax
je 0x12f8e
movzbl -0x51(%rbp), %eax
cmpl $0x5, %eax
jne 0x1302f
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl $0x4, %edx
callq 0x1f8e0
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x60(%rbp), %rcx
leaq 0x63417(%rip), %rdx     # 0x763e5
callq 0x21250
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x68(%rbp), %rcx
leaq 0x63400(%rip), %rdx     # 0x763ea
callq 0x21250
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x633de(%rip), %rcx     # 0x763e5
leaq 0x633dc(%rip), %r8      # 0x763ea
callq 0x22680
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x1fd10
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1fd10
jmp 0x1306b
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
xorl %edx, %edx
callq 0x1f8e0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x70(%rbp), %rdx
leaq 0x63a12(%rip), %rcx     # 0x76a6b
callq 0x227c0
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1fd10
jmp 0x130d9
movq -0x50(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x130b8
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x50(%rbp), %rcx
leaq 0x63358(%rip), %rdx     # 0x763e5
callq 0x1fd90
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x6333b(%rip), %rcx     # 0x763e5
leaq 0x639ba(%rip), %r8      # 0x76a6b
callq 0x228e0
jmp 0x130d7
leaq 0x6039b(%rip), %rdi     # 0x7345a
leaq 0x62832(%rip), %rsi     # 0x758f8
movl $0x122c, %edx           # imm = 0x122C
leaq 0x6400d(%rip), %rcx     # 0x770df
callq 0x30a0
jmp 0x130d9
jmp 0x131b9
movq -0x18(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x13198
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
callq 0x22a20
movb %al, -0x71(%rbp)
movzbl -0x71(%rbp), %eax
cmpl $0x9, %eax
je 0x13117
movzbl -0x71(%rbp), %eax
cmpl $0x5, %eax
jne 0x1313d
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x632b6(%rip), %rcx     # 0x763e5
leaq 0x632b4(%rip), %r8      # 0x763ea
callq 0x22680
jmp 0x13196
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movb -0x71(%rbp), %al
movb %al, -0x72(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
leaq 0x62791(%rip), %rcx     # 0x758f8
movl $0x1243, %r8d           # imm = 0x1243
movzbl -0x71(%rbp), %esi
callq 0x20d10
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rcx
movb -0x72(%rbp), %al
leaq 0x638dd(%rip), %r8      # 0x76a6b
movzbl %al, %edx
callq 0x228e0
jmp 0x131b7
leaq 0x602bb(%rip), %rdi     # 0x7345a
leaq 0x62752(%rip), %rsi     # 0x758f8
movl $0x1248, %edx           # imm = 0x1248
leaq 0x63f2d(%rip), %rcx     # 0x770df
callq 0x30a0
jmp 0x131b9
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x131ea
leaq 0x62d5e(%rip), %rax     # 0x75f3f
movq %rax, -0xa0(%rbp)
jmp 0x131f5
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rdx
callq 0x22a60
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x13240
leaq 0x62d08(%rip), %rax     # 0x75f3f
movq %rax, -0xb8(%rbp)
jmp 0x1324b
movq -0x28(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
callq 0x22b20
leaq -0x30(%rbp), %rdi
callq 0x9310
leaq -0x48(%rbp), %rdi
callq 0x9310
addq $0xc0, %rsp
popq %rbp
retq