// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_enc.c
// Function: ins_enc_mov_rxX_Ib
void ins_enc_mov_rxX_Ib(
	Instruction *ins,
	InstructionEncoderData *data
) {
	_CHECK_PARAMS(2);

	ParserASTNode *ins_node = data->ins_node;

	ParserASTNode *target = data->ins_node->childs[0];

	ParserASTNode *source = data->ins_node->childs[1];

	EncoderInstruction enc_ins;

	ins_init(data->ctx, ins, ins_node, &enc_ins);

	InsRegister *ins_target_reg = ASM_REG_AST_NODE_GET_REG(target);
	assert(ins_target_reg);

	switch (ASM_PARSER_CONTEXT_DATA_GET_ARCH(data->ctx)) {
		case ASM_ARCH_BIT16: {
			switch (ins_target_reg->type) {
				case INS_REGISTER_GENERAL_2BYTE: {
					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_4BYTE: {
					enc_ins.legacy_prefix.operand_size_override = true;

					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_8BYTE: {
					data->ctx->syntax_error_node_msg(
						data->ctx,
						ins_node,
						"instruction not supported in 64-bit mode."
					);
					break;
				}
				default: {
					assert(0);
					break;
				}
			}
			break;
		}
		case ASM_ARCH_BIT32: {
			switch (ins_target_reg->type) {
				case INS_REGISTER_GENERAL_2BYTE: {
					enc_ins.legacy_prefix.operand_size_override = true;

					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_4BYTE: {
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_8BYTE: {
					data->ctx->syntax_error_node_msg(
						data->ctx,
						ins_node,
						"instruction not supported in 64-bit mode."
					);
					break;
				}
				default: {
					assert(0);
					break;
				}
			}
			break;
		}
		case ASM_ARCH_BIT64: {
			switch (ins_target_reg->type) {
				case INS_REGISTER_GENERAL_2BYTE: {
					enc_ins.legacy_prefix.operand_size_override = true;

					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_4BYTE: {
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_REGISTER_GENERAL_8BYTE: {
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				default: {
					assert(0);
					break;
				}
			}
			break;
		}
		default: {
			assert(0);
			break;
		}
	}

	_output(data, &enc_ins);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x213ac
jmp 0x213cb
leaq 0x28753(%rip), %rdi     # 0x49b06
leaq 0x29c66(%rip), %rsi     # 0x4b020
movl $0x430, %edx            # imm = 0x430
leaq 0x2a428(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x213d4
jmp 0x213f3
leaq 0x2ec14(%rip), %rdi     # 0x4ffef
leaq 0x29c3e(%rip), %rsi     # 0x4b020
movl $0x430, %edx            # imm = 0x430
leaq 0x2a400(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x213ff
jmp 0x2141e
leaq 0x29c77(%rip), %rdi     # 0x4b07d
leaq 0x29c13(%rip), %rsi     # 0x4b020
movl $0x430, %edx            # imm = 0x430
leaq 0x2a3d5(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x2142d
jmp 0x2144c
leaq 0x29c58(%rip), %rdi     # 0x4b08c
leaq 0x29be5(%rip), %rsi     # 0x4b020
movl $0x430, %edx            # imm = 0x430
leaq 0x2a3a7(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1a9e0
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x214b3
jmp 0x214d2
leaq 0x2a375(%rip), %rdi     # 0x4b82f
leaq 0x29b5f(%rip), %rsi     # 0x4b020
movl $0x43d, %edx            # imm = 0x43D
leaq 0x2a321(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0xb0(%rax), %eax
movl %eax, -0x94(%rbp)
subl $0x1, %eax
je 0x21512
jmp 0x214ed
movl -0x94(%rbp), %eax
subl $0x2, %eax
je 0x215ca
jmp 0x214fe
movl -0x94(%rbp), %eax
subl $0x4, %eax
je 0x21682
jmp 0x21732
movq -0x90(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x98(%rbp)
subl $0x3, %eax
je 0x21543
jmp 0x21529
movl -0x98(%rbp), %eax
subl $0x4, %eax
je 0x21561
jmp 0x21536
movl -0x98(%rbp), %eax
subl $0x5, %eax
je 0x21583
jmp 0x215a6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1b950
jmp 0x215c5
movb $0x1, -0x7d(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x215c5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rsi
leaq 0x29dbc(%rip), %rdx     # 0x4b35e
callq *%rax
jmp 0x215c5
leaq 0x25eb8(%rip), %rdi     # 0x47465
leaq 0x29a6c(%rip), %rsi     # 0x4b020
movl $0x455, %edx            # imm = 0x455
leaq 0x2a22e(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
jmp 0x21751
movq -0x90(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x9c(%rbp)
subl $0x3, %eax
je 0x215fb
jmp 0x215e1
movl -0x9c(%rbp), %eax
subl $0x4, %eax
je 0x2161d
jmp 0x215ee
movl -0x9c(%rbp), %eax
subl $0x5, %eax
je 0x2163b
jmp 0x2165e
movb $0x1, -0x7d(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1b950
jmp 0x2167d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x2167d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rsi
leaq 0x29d04(%rip), %rdx     # 0x4b35e
callq *%rax
jmp 0x2167d
leaq 0x25e00(%rip), %rdi     # 0x47465
leaq 0x299b4(%rip), %rsi     # 0x4b020
movl $0x470, %edx            # imm = 0x470
leaq 0x2a176(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
jmp 0x21751
movq -0x90(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xa0(%rbp)
subl $0x3, %eax
je 0x216b3
jmp 0x21699
movl -0xa0(%rbp), %eax
subl $0x4, %eax
je 0x216d5
jmp 0x216a6
movl -0xa0(%rbp), %eax
subl $0x5, %eax
je 0x216f3
jmp 0x21711
movb $0x1, -0x7d(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1b950
jmp 0x21730
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x21730
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x21730
leaq 0x25d4d(%rip), %rdi     # 0x47465
leaq 0x29901(%rip), %rsi     # 0x4b020
movl $0x487, %edx            # imm = 0x487
leaq 0x2a0c3(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
jmp 0x21751
leaq 0x25d2c(%rip), %rdi     # 0x47465
leaq 0x298e0(%rip), %rsi     # 0x4b020
movl $0x48e, %edx            # imm = 0x48E
leaq 0x2a0a2(%rip), %rcx     # 0x4b7ee
callq 0xa0b0
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1e570
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)