user: Please show me the C implementation that matches the assembly code listed below:

```asm
<gen_move_from_sr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x90,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %esi,-0x8c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x1,-0x78(%rbp)
  mov    -0x8c(%rbp),%eax
  mov    %eax,%edi
  call   <ea_alterable@plt>
  test   %eax,%eax
  je     L99
  mov    -0x8c(%rbp),%eax
  mov    %eax,%edi
  call   <ea_mode@plt>
  cmp    $0x1,%eax
  jne    L40
L99:
  mov    $0x0,%eax
  call   <invalid@plt>
  jmp    L1
L40:
  mov    -0x8c(%rbp),%ecx
  mov    -0x88(%rbp),%rdx
  lea    -0x70(%rbp),%rax
  lea    D82(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <begin_function@plt>
  mov    %eax,-0x74(%rbp)
  mov    -0x8c(%rbp),%eax
  mov    %eax,%edi
  call   <ea_address@plt>
  test   %rax,%rax
  je     L119
  mov    -0x78(%rbp),%edx
  mov    -0x8c(%rbp),%esi
  lea    -0x70(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  call   <get_ea@plt>
  test   %rax,%rax
  jns    L119
  mov    $0xffffffff,%eax
  jmp    L1
L119:
  mov    -0x8c(%rbp),%eax
  mov    %eax,%edi
  call   <ea_address@plt>
  test   %rax,%rax
  je     L8
  cmpl   $0x0,-0x78(%rbp)
  je     L61
  lea    D65(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L61:
  mov    -0x88(%rbp),%rdx
  lea    -0x70(%rbp),%rax
  lea    D24(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x78(%rbp),%edx
  lea    -0x70(%rbp),%rax
  mov    %edx,%r8d
  lea    D98(%rip),%rdx
  mov    %rdx,%rcx
  lea    D47(%rip),%rdx
  lea    D116(%rip),%rsi
  mov    %rax,%rdi
  call   <print_bus_read_@plt>
  test   %rax,%rax
  jns    L8
  mov    -0x74(%rbp),%eax
  jmp    L1
L8:
  mov    -0x8c(%rbp),%eax
  mov    %eax,%edi
  call   <ea_mode@plt>
  cmp    $0x1,%eax
  jg     L173
  mov    -0x8c(%rbp),%eax
  and    $0xf,%eax
  mov    %eax,%edx
  mov    -0x78(%rbp),%eax
  mov    $0x8,%esi
  mov    %eax,%ecx
  shl    %cl,%esi
  mov    %esi,%eax
  mov    %eax,%esi
  lea    D122(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D76(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L74
L173:
  lea    D44(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  cmpl   $0x2,-0x78(%rbp)
  je     L14
  cmpl   $0x2,-0x78(%rbp)
  jg     L74
  cmpl   $0x0,-0x78(%rbp)
  je     L134
  cmpl   $0x1,-0x78(%rbp)
  je     L118
  jmp    L74
L134:
  lea    D125(%rip),%rax
  mov    %rax,%rsi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <print_bus_wait@plt>
  jmp    L74
L118:
  lea    D128(%rip),%rax
  mov    %rax,%rsi
  lea    D133(%rip),%rax
  mov    %rax,%rdi
  call   <print_bus_wait@plt>
  jmp    L74
L14:
  lea    D21(%rip),%rax
  mov    %rax,%rsi
  lea    D114(%rip),%rax
  mov    %rax,%rdi
  call   <print_bus_wait@plt>
  nop
L74:
  mov    -0x74(%rbp),%eax
L1:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L136
  call   <__stack_chk_fail@plt>
L136:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D82
data_type: string
name: read_data
arguments: tag: D65
data_type: string
name: read_data
arguments: tag: D24
data_type: string
name: read_data
arguments: tag: D98
data_type: string
name: read_data
arguments: tag: D47
data_type: string
name: read_data
arguments: tag: D116
data_type: string
name: read_data
arguments: tag: D122
data_type: string
name: read_data
arguments: tag: D76
data_type: string
name: read_data
arguments: tag: D44
data_type: string
name: read_data
arguments: tag: D125
data_type: string
name: read_data
arguments: tag: D19
data_type: string
name: read_data
arguments: tag: D128
data_type: string
name: read_data
arguments: tag: D133
data_type: string
name: read_data
arguments: tag: D21
data_type: string
name: read_data
arguments: tag: D114
data_type: string

tool: D82: %s_%04X

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

tool: D24: %s_fsr_common

tool: D98: EV

tool: D47: EA

tool: 

tool: D122: 	SET_DN_REG%d(%d, SR);


tool: D76: 	FETCH_OPCODE;
}


tool: D44: 	EV = SR;

tool: D125: done_write_wb

tool: D19: done_wait_wb

tool: D128: done_write_ww

tool: D133: done_wait_ww

tool: D21: done_write_wl

tool: D114: done_wait_wl

assistant: ```c
int gen_move_from_sr(const char *mnemonic, int opcode) {
  char func_name[(100)];
  int func_id;
  int op_size;
  op_size = 1;
  if (!ea_alterable(opcode) || ea_mode(opcode) == 1)
    return invalid();
  sprintf(func_name, "%s_%04X", mnemonic, opcode);
  func_id = begin_function(func_name);
  if (ea_address(opcode)) {
    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_fsr_common", mnemonic);
    if (print_bus_read_(func_name, "", "EA", "EV", op_size) < 0)
      return func_id;
  }
  if (ea_mode(opcode) < 2) {
    printf("\tSET_DN_REG%d(%d, SR);\n", 8 << op_size, opcode & 0xF);
    printf("\tFETCH_OPCODE;\n}\n\n");
  } else {
    printf("\tEV = SR;\n");
    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;
}
```