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
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  movq   $0x3,(%rsp)
  movabs $0x100000002,%rax
  mov    %rax,0x8(%rsp)
  mov    %esi,%eax
  sar    $0xc,%eax
  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     L138
  test   %eax,%eax
  je     L138
  mov    %ebp,%edi
  call   <ea_mode@plt>
  test   %r13d,%r13d
  jne    L142
  cmp    $0x1,%eax
  je     L138
L142:
  mov    %ebp,%edi
  call   <ea_mode@plt>
  test   %eax,%eax
  js     L138
  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     L215
  mov    %ebp,%edi
  call   <ea_address@plt>
  test   %rax,%rax
  je     L18
  test   %r13d,%r13d
  jne    L103
L189:
  mov    %r13d,%ecx
  mov    %r14,%rdx
  lea    D139(%rip),%rsi
  mov    %r15,%rdi
  shl    $0x6,%ecx
  xor    %eax,%eax
  or     %r12d,%ecx
  call   <sprintf@plt>
  mov    %r13d,%r8d
  mov    %r15,%rdi
  lea    D12(%rip),%rcx
  lea    D155(%rip),%rdx
  lea    D76(%rip),%rsi
  call   <print_bus_read_@plt>
  test   %rax,%rax
  js     L248
L18:
  mov    %r13d,%ecx
  mov    $0x8,%ebp
  lea    D59(%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    L133
L94:
  mov    %r12d,%edi
  call   <ea_mode@plt>
  test   %eax,%eax
  jne    L137
  mov    %r12d,%edx
  lea    D163(%rip),%rdi
  mov    %ebp,%esi
  and    $0xf,%edx
  call   <printf@plt>
  lea    D120(%rip),%rdi
  call   <puts@plt>
L248:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L88
  add    $0xf8,%rsp
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L138:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L88
  add    $0xf8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1190 <invalid@plt>
  nop
L137:
  mov    %r12d,%edi
  call   <ea_mode@plt>
  cmp    $0x1,%eax
  je     L53
  lea    0x80(%rsp),%rbp
  mov    %r15,%rdx
  lea    D153(%rip),%rsi
  xor    %eax,%eax
  mov    %rbp,%rdi
  call   <sprintf@plt>
  lea    D141(%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     L215
  cmp    $0x1,%r13d
  je     L35
  cmp    $0x2,%r13d
  je     L166
  test   %r13d,%r13d
  jne    L248
  lea    D26(%rip),%rsi
  lea    D51(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L248
  nopl   0x0(%rax,%rax,1)
L133:
  mov    %ebp,%esi
  lea    D66(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebp,%esi
  lea    D113(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D11(%rip),%rdi
  call   <puts@plt>
  lea    D56(%rip),%rdi
  call   <puts@plt>
  jmp    L94
  nopl   (%rax)
L103:
  lea    D159(%rip),%rdi
  call   <puts@plt>
  jmp    L189
  nopl   0x0(%rax)
L166:
  lea    D199(%rip),%rsi
  lea    D178(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L248
  nopl   0x0(%rax,%rax,1)
L35:
  lea    D206(%rip),%rsi
  lea    D22(%rip),%rdi
  call   <print_bus_wait@plt>
  jmp    L248
  nopl   0x0(%rax,%rax,1)
L53:
  mov    %r12d,%esi
  mov    %ebp,%edx
  lea    D183(%rip),%rdi
  xor    %eax,%eax
  and    $0xf,%esi
  call   <printf@plt>
  lea    D120(%rip),%rdi
  call   <puts@plt>
  jmp    L248
L215:
  mov    $0xffffffff,%ebx
  jmp    L248
L88:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D105
type: string
name: extract_symbolic_data
arguments: data_tag: D139
type: string
name: extract_symbolic_data
arguments: data_tag: D12
type: string
name: extract_symbolic_data
arguments: data_tag: D155
type: string
name: extract_symbolic_data
arguments: data_tag: D76
type: string
name: extract_symbolic_data
arguments: data_tag: D59
type: string
name: extract_symbolic_data
arguments: data_tag: D163
type: string
name: extract_symbolic_data
arguments: data_tag: D120
type: string
name: extract_symbolic_data
arguments: data_tag: D153
type: string
name: extract_symbolic_data
arguments: data_tag: D141
type: string
name: extract_symbolic_data
arguments: data_tag: D26
type: string
name: extract_symbolic_data
arguments: data_tag: D51
type: string
name: extract_symbolic_data
arguments: data_tag: D66
type: string
name: extract_symbolic_data
arguments: data_tag: D113
type: string
name: extract_symbolic_data
arguments: data_tag: D11
type: string
name: extract_symbolic_data
arguments: data_tag: D56
type: string
name: extract_symbolic_data
arguments: data_tag: D159
type: string
name: extract_symbolic_data
arguments: data_tag: D199
type: string
name: extract_symbolic_data
arguments: data_tag: D178
type: string
name: extract_symbolic_data
arguments: data_tag: D206
type: string
name: extract_symbolic_data
arguments: data_tag: D22
type: string
name: extract_symbolic_data
arguments: data_tag: D183
type: string

tool: D105: %s_%04X

tool: D139: %s_common_%02X

tool: D12: EV

tool: D155: EA

tool: 

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


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


tool: D120: 	FETCH_OPCODE;
}


tool: D153: %s_dest

tool: D141: 		EV = result;
	}

tool: D26: done_write_wb

tool: D51: done_wait_wb

tool: D66: 		SET_N_FLAG%d(result);


tool: D113: 		SET_Z_FLAG%d(result);


tool: D11: 		SET_V_FLAG(0);

tool: D56: 		SET_C_FLAG(0);

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

tool: D199: done_write_wl

tool: D178: done_wait_wl

tool: D206: done_write_ww

tool: D22: done_wait_ww

tool: D183: 		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;
}
```