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

```asm
<arithmetic_op>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x10(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <eval_register@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0xffffffff,-0xc(%rbp)
  jne    L55
  mov    $0xffffffff,%eax
  jmp    L48
L55:
  mov    -0xc(%rbp),%eax
  shl    $0x9,%eax
  or     %eax,-0x24(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  add    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  cmp    $0x2c,%al
  je     L14
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  call   <error@plt>
  jmp    L48
L14:
  lea    -0x10(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <eval_register@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0xffffffff,-0xc(%rbp)
  jne    L41
  mov    $0xffffffff,%eax
  jmp    L48
L41:
  cmpl   $0x7,-0xc(%rbp)
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0xc(%rbp),%eax
  shl    $0x3,%eax
  or     %eax,-0x24(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  add    %rax,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  and    $0x1c0,%eax
  cmp    $0x1c0,%eax
  je     L145
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  cmp    $0x2c,%al
  je     L128
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D38(%rip),%rax
  mov    %rax,%rdi
  call   <error@plt>
  jmp    L48
L128:
  lea    -0x10(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <eval_register@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0xffffffff,-0xc(%rbp)
  jne    L34
  mov    $0xffffffff,%eax
  jmp    L48
L34:
  cmpl   $0x7,-0xc(%rbp)
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0xc(%rbp),%eax
  or     %eax,-0x24(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  add    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  test   %al,%al
  je     L44
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <error@plt>
  jmp    L48
L145:
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  test   %al,%al
  je     L44
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <error@plt>
  jmp    L48
L44:
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <apply_masking_mode@plt>
L48:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L150
  call   <__stack_chk_fail@plt>
L150:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D23
data_type: string
name: retrieve_data
arguments: tag: D38
data_type: string
name: retrieve_data
arguments: tag: D19
data_type: string
name: retrieve_data
arguments: tag: D7
data_type: string

tool: D23: Expected second operand in "%s"

tool: D38: Expected third operand in "%s"

tool: D19: Expected only three operands in "%s"

tool: D7: Expected only two operands in "%s"

assistant: ```c
unsigned int arithmetic_op(const char *text, const char *ip, unsigned int ret) {
  int len;
  unsigned int lval = eval_register(ip, &len);
  if (lval == -1u)
    return -1u;
  ret |= (lval << 9);
  ip += len;
  if (*ip++ != ',')
    return error("Expected second operand in \"%s\"", text);
  lval = eval_register(ip, &len);
  if (lval == -1u)
    return -1u;
  assert(lval <= 7);
  ret |= (lval << 3);
  ip += len;
  if ((ret & 0700) != 0700) {
    if (*ip++ != ',')
      return error("Expected third operand in \"%s\"", text);
    lval = eval_register(ip, &len);
    if (lval == -1u)
      return -1u;
    assert(lval <= 7);
    ret |= lval;
    ip += len;
    if (*ip++ != '\0')
      return error("Expected only three operands in \"%s\"", text);
  } else {
    if (*ip++ != '\0')
      return error("Expected only two operands in \"%s\"", text);
  }
  return apply_masking_mode(ret);
}
```