user: Translate the below assembly code into C programming language:

```asm
<gen_move>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  sar    $0x9,%r12d
  mov    %esi,%ebp
  push   %rbx
  and    $0x7,%r12d
  sub    $0xf8,%rsp
  movdqa D127(%rip),%xmm0
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  mov    %esi,%eax
  sar    $0xc,%eax
  movaps %xmm0,(%rsp)
  and    $0x3,%eax
  mov    (%rsp,%rax,4),%r13d
  mov    %esi,%eax
  sar    $0x3,%eax
  and    $0x38,%eax
  or     %eax,%r12d
  mov    %r12d,%edi
  call   <ea_alterable@plt>
  cmp    $0x3,%r13d
  je     L176
  test   %eax,%eax
  je     L176
  mov    %ebp,%edi
  call   <ea_mode@plt>
  test   %r13d,%r13d
  jne    L184
  cmp    $0x1,%eax
  je     L176
L184:
  mov    %ebp,%edi
  call   <ea_mode@plt>
  test   %eax,%eax
  js     L176
  lea    0x10(%rsp),%r15
  mov    %ebp,%ecx
  mov    %r14,%rdx
  xor    %eax,%eax
  lea    D105(%rip),%rsi
  mov    %r15,%rdi
  call   <sprintf@plt>
  mov    %r15,%rdi
  call   <begin_function@plt>
  mov    $0x1,%ecx
  mov    %r13d,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  mov    %eax,%ebx
  call   <get_ea@plt>
  test   %rax,%rax
  js     L159
  mov    %ebp,%edi
  call   <ea_address@plt>
  test   %rax,%rax
  je     L44
  test   %r13d,%r13d
  jne    L38
L61:
  mov    %r13d,%ecx
  mov    %r14,%rdx
  lea    D195(%rip),%rsi
  mov    %r15,%rdi
  shl    $0x6,%ecx
  xor    %eax,%eax
  or     %r12d,%ecx
  call   <sprintf@plt>
  mov    %r13d,%r8d
  mov    %r15,%rdi
  lea    D238(%rip),%rcx
  lea    D91(%rip),%rdx
  lea    D50(%rip),%rsi
  call   <print_bus_read_@plt>
  test   %rax,%rax
  js     L238
L44:
  mov    %r13d,%ecx
  mov    $0x8,%ebp
  lea    D109(%rip),%rdi
  xor    %eax,%eax
  shl    %cl,%ebp
  mov    %ebp,%esi
  call   <printf@plt>
  mov    %r12d,%edi
  call   <ea_mode@plt>
  cmp    $0x1,%eax
  jne    L160
L193:
  mov    %r12d,%edi
  call   <ea_mode@plt>
  test   %eax,%eax
  jne    L147
  mov    %r12d,%edx
  lea    D227(%rip),%rdi
  mov    %ebp,%esi
  and    $0xf,%edx
  call   <printf@plt>
  lea    D136(%rip),%rdi
  call   <puts@plt>
L238:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L25
  add    $0xf8,%rsp
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L176:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L25
  add    $0xf8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1190 <invalid@plt>
  nop
L147:
  mov    %r12d,%edi
  call   <ea_mode@plt>
  cmp    $0x1,%eax
  je     L103
  lea    0x80(%rsp),%rbp
  mov    %r15,%rdx
  lea    D157(%rip),%rsi
  xor    %eax,%eax
  mov    %rbp,%rdi
  call   <sprintf@plt>
  lea    D140(%rip),%rdi
  call   <puts@plt>
  xor    %ecx,%ecx
  mov    %r13d,%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <get_ea@plt>
  test   %rax,%rax
  js     L159
  cmp    $0x1,%r13d
  je     L70
  cmp    $0x2,%r13d
  je     L151
  test   %r13d,%r13d
  jne    L238
  lea    D142(%rip),%rsi
  lea    D68(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L238
  nopl   0x0(%rax,%rax,1)
L160:
  mov    %ebp,%esi
  lea    D100(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebp,%esi
  lea    D92(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D78(%rip),%rdi
  call   <puts@plt>
  lea    D207(%rip),%rdi
  call   <puts@plt>
  jmp    L193
  nopl   (%rax)
L38:
  lea    D137(%rip),%rdi
  call   <puts@plt>
  jmp    L61
  nopl   0x0(%rax)
L151:
  lea    D34(%rip),%rsi
  lea    D65(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L238
  nopl   0x0(%rax,%rax,1)
L70:
  lea    D26(%rip),%rsi
  lea    D187(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L238
  nopl   0x0(%rax,%rax,1)
L103:
  mov    %r12d,%esi
  mov    %ebp,%edx
  lea    D210(%rip),%rdi
  xor    %eax,%eax
  and    $0xf,%esi
  call   <printf@plt>
  lea    D136(%rip),%rdi
  call   <puts@plt>
  jmp    L238
L159:
  mov    $0xffffffff,%ebx
  jmp    L238
L25:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D127
datatype: byte[16]
name: disassemble_data
arguments: data_label: D105
datatype: string
name: disassemble_data
arguments: data_label: D195
datatype: string
name: disassemble_data
arguments: data_label: D238
datatype: string
name: disassemble_data
arguments: data_label: D91
datatype: string
name: disassemble_data
arguments: data_label: D50
datatype: string
name: disassemble_data
arguments: data_label: D109
datatype: string
name: disassemble_data
arguments: data_label: D227
datatype: string
name: disassemble_data
arguments: data_label: D136
datatype: string
name: disassemble_data
arguments: data_label: D157
datatype: string
name: disassemble_data
arguments: data_label: D140
datatype: string
name: disassemble_data
arguments: data_label: D142
datatype: string
name: disassemble_data
arguments: data_label: D68
datatype: string
name: disassemble_data
arguments: data_label: D100
datatype: string
name: disassemble_data
arguments: data_label: D92
datatype: string
name: disassemble_data
arguments: data_label: D78
datatype: string
name: disassemble_data
arguments: data_label: D207
datatype: string
name: disassemble_data
arguments: data_label: D137
datatype: string
name: disassemble_data
arguments: data_label: D34
datatype: string
name: disassemble_data
arguments: data_label: D65
datatype: string
name: disassemble_data
arguments: data_label: D26
datatype: string
name: disassemble_data
arguments: data_label: D187
datatype: string
name: disassemble_data
arguments: data_label: D210
datatype: string

tool: {"D127": [0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00]}

tool: D105: %s_%04X

tool: D195: %s_common_%02X

tool: D238: EV

tool: D91: EA

tool: 

tool: D109: 	{
		uint%d_t result = EV;


tool: D227: 		SET_DN_REG%d(%d, result);
	}


tool: D136: 	FETCH_OPCODE;
}


tool: D157: %s_dest

tool: D140: 		EV = result;
	}

tool: D142: done_write_wb

tool: D68: done_wait_wb

tool: D100: 		SET_N_FLAG%d(result);


tool: D92: 		SET_Z_FLAG%d(result);


tool: D78: 		SET_V_FLAG(0);

tool: D207: 		SET_C_FLAG(0);

tool: D137: 	if (EA&1) ADDRESS_EXCEPTION;

tool: D34: done_write_wl

tool: D65: done_wait_wl

tool: D26: done_write_ww

tool: D187: done_wait_ww

tool: D210: 		REG_D(%d) = (uint32_t)(int%d_t)result;
	}


assistant: ```c
int gen_move(const char *mnemonic, int opcode) {
  char func_name[(100)];
  char access_name[(100)];
  int func_id;
  int op_size;
  int op_dest;
  int sizes[4] = {3, 0, 2, 1};
  op_size = (opcode >> 12) & 3;
  op_size = sizes[op_size];
  op_dest = ((opcode >> 9) & 7) | ((opcode >> 3) & 0x38);
  if (!ea_alterable(op_dest) || op_size == 3 || (ea_mode(opcode) == 1 && op_size == 0) || ea_mode(opcode) < 0)
    return invalid();
  sprintf(func_name, "%s_%04X", mnemonic, opcode);
  func_id = begin_function(func_name);
  if (get_ea(func_name, opcode, op_size, 1) < 0)
    return -1;
  if (ea_address(opcode)) {
    if (op_size)
      printf("\tif (EA&1) ADDRESS_EXCEPTION;\n");
    sprintf(func_name, "%s_common_%02X", mnemonic, (op_size << 6) | op_dest);
    if (print_bus_read_(func_name, "", "EA", "EV", op_size) < 0)
      return func_id;
  }
  printf("\t{\n\t\tuint%d_t result = EV;\n", 8 << op_size);
  if (ea_mode(op_dest) != 1) {
    printf("\t\tSET_N_FLAG%d(result);\n", 8 << op_size);
    printf("\t\tSET_Z_FLAG%d(result);\n", 8 << op_size);
    printf("\t\tSET_V_FLAG(0);\n");
    printf("\t\tSET_C_FLAG(0);\n");
  }
  if (ea_mode(op_dest) == 0) {
    printf("\t\tSET_DN_REG%d(%d, result);\n\t}\n", 8 << op_size, op_dest & 0xF);
    printf("\tFETCH_OPCODE;\n}\n\n");
  } else if (ea_mode(op_dest) == 1) {
    printf("\t\tREG_D(%d) = (uint32_t)(int%d_t)result;\n\t}\n", op_dest & 0xF, 8 << op_size);
    printf("\tFETCH_OPCODE;\n}\n\n");
  } else {
    sprintf(access_name, "%s_dest", func_name);
    printf("\t\tEV = result;\n\t}\n");
    if (get_ea(access_name, op_dest, op_size, 0) < 0)
      return -1;
    switch (op_size) {
    case 0:
      print_bus_wait("done_wait_wb", "done_write_wb");
      break;
    case 1:
      print_bus_wait("done_wait_ww", "done_write_ww");
      break;
    case 2:
      print_bus_wait("done_wait_wl", "done_write_wl");
      break;
    }
  }
  return func_id;
}
```