// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_enc.c
// Function: ins_enc_XXX_rAX_Iz
void ins_enc_XXX_rAX_Iz(
	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);

	int arch = ASM_PARSER_CONTEXT_DATA_GET_ARCH(data->ctx);

	InsRegister *target_reg = ASM_REG_AST_NODE_GET_REG(target);

	switch (arch) {
		case ASM_ARCH_BIT16: {
			switch (target_reg->id) {
				case INS_AM_AX: {
					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_EAX: {
					enc_ins.legacy_prefix.operand_size_override = true;
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_RAX: {
					data->ctx->syntax_error_node_msg(
						data->ctx,
						ins_node,
						"instruction not supported in 16-bit mode."
					);
					break;
				}
				default: {
					assert(0);
					break;
				}
			}
			break;
		}
		case ASM_ARCH_BIT32: {
			switch (target_reg->id) {
				case INS_AM_AX: {
					enc_ins.legacy_prefix.operand_size_override = true;
					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_EAX: {
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_RAX: {
					data->ctx->syntax_error_node_msg(
						data->ctx,
						ins_node,
						"instruction not supported in 32-bit mode."
					);
					break;
				}
				default: {
					assert(0);
					break;
				}
			}
			break;
		}
		case ASM_ARCH_BIT64: {
			switch (target_reg->id) {
				case INS_AM_AX: {
					enc_ins.legacy_prefix.operand_size_override = true;
					ins_fill_imm16(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_EAX: {
					ins_fill_imm32(data->ctx, ins, source, &enc_ins);
					break;
				}
				case INS_AM_RAX: {
					enc_ins.rex_prefix_used = true;
					enc_ins.rex_prefix.w = 1;
					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 $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1ee1c
jmp 0x1ee3b
leaq 0x2ace3(%rip), %rdi     # 0x49b06
leaq 0x2c1f6(%rip), %rsi     # 0x4b020
movl $0xb7, %edx
leaq 0x2c3b5(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1ee44
jmp 0x1ee63
leaq 0x311a4(%rip), %rdi     # 0x4ffef
leaq 0x2c1ce(%rip), %rsi     # 0x4b020
movl $0xb7, %edx
leaq 0x2c38d(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1ee6f
jmp 0x1ee8e
leaq 0x2c207(%rip), %rdi     # 0x4b07d
leaq 0x2c1a3(%rip), %rsi     # 0x4b020
movl $0xb7, %edx
leaq 0x2c362(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x2, 0x44(%rax)
jne 0x1ee9d
jmp 0x1eebc
leaq 0x2c1e8(%rip), %rdi     # 0x4b08c
leaq 0x2c175(%rip), %rsi     # 0x4b020
movl $0xb7, %edx
leaq 0x2c334(%rip), %rcx     # 0x4b1eb
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 -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0xb0(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x98(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x9c(%rbp)
subl $0x1, %eax
je 0x1ef63
jmp 0x1ef3e
movl -0x9c(%rbp), %eax
subl $0x2, %eax
je 0x1f021
jmp 0x1ef4f
movl -0x9c(%rbp), %eax
subl $0x4, %eax
je 0x1f0df
jmp 0x1f19d
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa0(%rbp)
subl $0x8800, %eax           # imm = 0x8800
je 0x1ef9a
jmp 0x1ef7c
movl -0xa0(%rbp), %eax
subl $0x8900, %eax           # imm = 0x8900
je 0x1efb8
jmp 0x1ef8b
movl -0xa0(%rbp), %eax
subl $0x8a00, %eax           # imm = 0x8A00
je 0x1efda
jmp 0x1effd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1b950
jmp 0x1f01c
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 0x1f01c
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 0x2c233(%rip), %rdx     # 0x4b22c
callq *%rax
jmp 0x1f01c
leaq 0x28461(%rip), %rdi     # 0x47465
leaq 0x2c015(%rip), %rsi     # 0x4b020
movl $0xdc, %edx
leaq 0x2c1d4(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
jmp 0x1f1bc
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa4(%rbp)
subl $0x8800, %eax           # imm = 0x8800
je 0x1f058
jmp 0x1f03a
movl -0xa4(%rbp), %eax
subl $0x8900, %eax           # imm = 0x8900
je 0x1f07a
jmp 0x1f049
movl -0xa4(%rbp), %eax
subl $0x8a00, %eax           # imm = 0x8A00
je 0x1f098
jmp 0x1f0bb
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 0x1f0da
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x1f0da
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 0x2c19f(%rip), %rdx     # 0x4b256
callq *%rax
jmp 0x1f0da
leaq 0x283a3(%rip), %rdi     # 0x47465
leaq 0x2bf57(%rip), %rsi     # 0x4b020
movl $0xf6, %edx
leaq 0x2c116(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
jmp 0x1f1bc
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa8(%rbp)
subl $0x8800, %eax           # imm = 0x8800
je 0x1f116
jmp 0x1f0f8
movl -0xa8(%rbp), %eax
subl $0x8900, %eax           # imm = 0x8900
je 0x1f138
jmp 0x1f107
movl -0xa8(%rbp), %eax
subl $0x8a00, %eax           # imm = 0x8A00
je 0x1f156
jmp 0x1f17c
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 0x1f19b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x1f19b
movb $0x1, -0x7b(%rbp)
movb $0x1, -0x7a(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1baa0
jmp 0x1f19b
leaq 0x282e2(%rip), %rdi     # 0x47465
leaq 0x2be96(%rip), %rsi     # 0x4b020
movl $0x10e, %edx            # imm = 0x10E
leaq 0x2c055(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
jmp 0x1f1bc
leaq 0x282c1(%rip), %rdi     # 0x47465
leaq 0x2be75(%rip), %rsi     # 0x4b020
movl $0x115, %edx            # imm = 0x115
leaq 0x2c034(%rip), %rcx     # 0x4b1eb
callq 0xa0b0
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1e570
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)