// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/backend/asmgen_gas64.c
// Function: asm_stat_uitofp
static void _asm_stat_uitofp(
	ASMGeneratorGas64Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_UITOFP);
	assert(node->nchilds == 2);

	ParserASTNode *node_target = node->childs[0];
	assert(node_target->type == BE_NODE_IDENTIFIER);
	ParserSymbol *symbol_target = _get_var_symbol_by_id_node(ctx, node_target);
	uint8_t type_target = BE_VAR_SYMBOL_GET_TYPE(symbol_target);

	ParserASTNode *node_source = node->childs[1];
	uint8_t type_source = _zero_extend64(ctx, _ASM_REG_AX, node_source);

	if (type_source == BE_TYPE_UINT8
			|| type_source == BE_TYPE_UINT16
			|| type_source == BE_TYPE_UINT32) {
		if (type_target == BE_TYPE_FLOAT) {
			_asm_inst_cvtsi2ss_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_movss_sym_x(
				ctx,
				ctx->body,
				symbol_target,
				_ASM_REG_NAME_XMM0
			);
		} else if (type_target == BE_TYPE_DOUBLE) {
			_asm_inst_cvtsi2sd_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_movsd_sym_x(
				ctx,
				ctx->body,
				symbol_target,
				_ASM_REG_NAME_XMM0
			);
		} else {
			assert(0);
		}
	} else if (type_source == BE_TYPE_UINT64) {
		_asm_inst_test_x_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT64,
			_ASM_REG_NAME_RAX,
			_ASM_REG_NAME_RAX
		);

		ResizableString rstr_tmp_label1;
		rstr_init(&rstr_tmp_label1);
		_out_func_tmp_label(ctx, &rstr_tmp_label1);

		ResizableString rstr_tmp_label2;
		rstr_init(&rstr_tmp_label2);
		_out_func_tmp_label(ctx, &rstr_tmp_label2);

		_asm_inst_js_x(ctx, ctx->body, RSTR_CSTR(&rstr_tmp_label1));

		if (type_target == BE_TYPE_FLOAT) {

			_asm_inst_cvtsi2ss_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_jmp_x(ctx, ctx->body, RSTR_CSTR(&rstr_tmp_label2));

			rstr_append_with_rstr(ctx->body, &rstr_tmp_label1);
			rstr_append_with_cstr(ctx->body, ":\n");

			_asm_inst_shr_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT64,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_cvtsi2ss_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_addss_x_x(
				ctx,
				ctx->body,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_XMM0
			);

			rstr_append_with_rstr(ctx->body, &rstr_tmp_label2);
			rstr_append_with_cstr(ctx->body, ":\n");

			_asm_inst_movss_sym_x(
				ctx,
				ctx->body,
				symbol_target,
				_ASM_REG_NAME_XMM0
			);
		} else if (type_target == BE_TYPE_DOUBLE) {

			_asm_inst_cvtsi2sd_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_jmp_x(ctx, ctx->body, RSTR_CSTR(&rstr_tmp_label2));

			rstr_append_with_rstr(ctx->body, &rstr_tmp_label1);
			rstr_append_with_cstr(ctx->body, ":\n");

			_asm_inst_shr_x(
				ctx,
				ctx->body,
				BE_TYPE_UINT64,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_cvtsi2sd_x_x(
				ctx,
				ctx->body,
				BE_TYPE_INT64,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_RAX
			);

			_asm_inst_addsd_x_x(
				ctx,
				ctx->body,
				_ASM_REG_NAME_XMM0,
				_ASM_REG_NAME_XMM0
			);

			rstr_append_with_rstr(ctx->body, &rstr_tmp_label2);
			rstr_append_with_cstr(ctx->body, ":\n");

			_asm_inst_movsd_sym_x(
				ctx,
				ctx->body,
				symbol_target,
				_ASM_REG_NAME_XMM0
			);
		} else {
			assert(0);
		}

		rstr_free(&rstr_tmp_label1);
		rstr_free(&rstr_tmp_label2);
	} else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2c53c
jmp 0x2c55b
leaq 0x53c1e(%rip), %rdi     # 0x80161
leaq 0x4e5ba(%rip), %rsi     # 0x7ab04
movl $0x1091, %edx           # imm = 0x1091
leaq 0x4fd26(%rip), %rcx     # 0x7c27c
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x2c564
jmp 0x2c583
leaq 0x49ff1(%rip), %rdi     # 0x7655c
leaq 0x4e592(%rip), %rsi     # 0x7ab04
movl $0x1092, %edx           # imm = 0x1092
leaq 0x4fcfe(%rip), %rcx     # 0x7c27c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbc5, (%rax)          # imm = 0xBC5
jne 0x2c591
jmp 0x2c5b0
leaq 0x4b887(%rip), %rdi     # 0x77e1f
leaq 0x4e565(%rip), %rsi     # 0x7ab04
movl $0x1093, %edx           # imm = 0x1093
leaq 0x4fcd1(%rip), %rcx     # 0x7c27c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x2c5bc
jmp 0x2c5db
leaq 0x56781(%rip), %rdi     # 0x82d44
leaq 0x4e53a(%rip), %rsi     # 0x7ab04
movl $0x1094, %edx           # imm = 0x1094
leaq 0x4fca6(%rip), %rcx     # 0x7c27c
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 0x2c5f8
jmp 0x2c617
leaq 0x49dbe(%rip), %rdi     # 0x763bd
leaq 0x4e4fe(%rip), %rsi     # 0x7ab04
movl $0x1097, %edx           # imm = 0x1097
leaq 0x4fc6a(%rip), %rcx     # 0x7c27c
callq 0x30a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x32820
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movb 0x30(%rax), %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
xorl %esi, %esi
callq 0x359d0
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0x6, %eax
je 0x2c673
movzbl -0x31(%rbp), %eax
cmpl $0x7, %eax
je 0x2c673
movzbl -0x31(%rbp), %eax
cmpl $0x8, %eax
jne 0x2c72f
movzbl -0x21(%rbp), %eax
cmpl $0xa, %eax
jne 0x2c6be
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b272(%rip), %rcx     # 0x77906
leaq 0x4ea1f(%rip), %r8      # 0x7b0ba
callq 0x352f0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4b24f(%rip), %rcx     # 0x77906
callq 0x35460
jmp 0x2c72a
movzbl -0x21(%rbp), %eax
cmpl $0xb, %eax
jne 0x2c709
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b227(%rip), %rcx     # 0x77906
leaq 0x4e9d4(%rip), %r8      # 0x7b0ba
callq 0x35570
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4b204(%rip), %rcx     # 0x77906
callq 0x356e0
jmp 0x2c728
leaq 0x46d4a(%rip), %rdi     # 0x7345a
leaq 0x4e3ed(%rip), %rsi     # 0x7ab04
movl $0x10c0, %edx           # imm = 0x10C0
leaq 0x4fb59(%rip), %rcx     # 0x7c27c
callq 0x30a0
jmp 0x2c72a
jmp 0x2caac
movzbl -0x31(%rbp), %eax
cmpl $0x9, %eax
jne 0x2ca8b
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x9, %edx
leaq 0x4e966(%rip), %r8      # 0x7b0ba
movq %r8, %rcx
callq 0x35a50
leaq -0x48(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x35b90
leaq -0x58(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x35b90
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2c7b0
leaq 0x49795(%rip), %rax     # 0x75f3f
movq %rax, -0x70(%rbp)
jmp 0x2c7b8
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rdx
callq 0x35cb0
movzbl -0x21(%rbp), %eax
cmpl $0xa, %eax
jne 0x2c90b
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b118(%rip), %rcx     # 0x77906
leaq 0x4e8c5(%rip), %r8      # 0x7b0ba
callq 0x352f0
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x2c825
leaq 0x49723(%rip), %rax     # 0x75f3f
movq %rax, -0x88(%rbp)
jmp 0x2c830
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rdx
callq 0x34b60
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x499bc(%rip), %rsi     # 0x76220
callq 0x8d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x9, %edx
leaq 0x4e839(%rip), %rcx     # 0x7b0ba
callq 0x35d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4b068(%rip), %rcx     # 0x77906
leaq 0x4e815(%rip), %r8      # 0x7b0ba
callq 0x352f0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x4b049(%rip), %rcx     # 0x77906
movq %rcx, %rdx
callq 0x35e80
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x4993b(%rip), %rsi     # 0x76220
callq 0x8d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4b005(%rip), %rcx     # 0x77906
callq 0x35460
jmp 0x2ca77
movzbl -0x21(%rbp), %eax
cmpl $0xb, %eax
jne 0x2ca56
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4afd6(%rip), %rcx     # 0x77906
leaq 0x4e783(%rip), %r8      # 0x7b0ba
callq 0x35570
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x2c96d
leaq 0x495db(%rip), %rax     # 0x75f3f
movq %rax, -0xa0(%rbp)
jmp 0x2c978
movq -0x50(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rdx
callq 0x34b60
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x4986e(%rip), %rsi     # 0x76220
callq 0x8d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x9, %edx
leaq 0x4e6eb(%rip), %rcx     # 0x7b0ba
callq 0x35d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x5, %edx
leaq 0x4af1a(%rip), %rcx     # 0x77906
leaq 0x4e6c7(%rip), %r8      # 0x7b0ba
callq 0x35570
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x4aefb(%rip), %rcx     # 0x77906
movq %rcx, %rdx
callq 0x35f70
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x497ed(%rip), %rsi     # 0x76220
callq 0x8d70
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
leaq 0x4aeb7(%rip), %rcx     # 0x77906
callq 0x356e0
jmp 0x2ca75
leaq 0x469fd(%rip), %rdi     # 0x7345a
leaq 0x4e0a0(%rip), %rsi     # 0x7ab04
movl $0x1132, %edx           # imm = 0x1132
leaq 0x4f80c(%rip), %rcx     # 0x7c27c
callq 0x30a0
jmp 0x2ca77
leaq -0x48(%rbp), %rdi
callq 0x9310
leaq -0x58(%rbp), %rdi
callq 0x9310
jmp 0x2caaa
leaq 0x469c8(%rip), %rdi     # 0x7345a
leaq 0x4e06b(%rip), %rsi     # 0x7ab04
movl $0x1138, %edx           # imm = 0x1138
leaq 0x4f7d7(%rip), %rcx     # 0x7c27c
callq 0x30a0
jmp 0x2caac
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)