user: 请将以下的汇编代码转换成C语言代码:

```asm
<roman_to_int>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0xffffffff,-0x8(%rbp)
  movl   $0xffffffff,-0x14(%rbp)
  movb   $0x0,-0x1d(%rbp)
  movb   $0x0,-0x1e(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <string_length@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jg     L106
  mov    $0xffffffff,%eax
  jmp    L5
L106:
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L70
L173:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x1d(%rbp)
  movsbl -0x1d(%rbp),%eax
  mov    %eax,%edi
  call   <alg_value@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0xffffffff,-0x8(%rbp)
  jne    L0
  mov    $0xffffffff,%eax
  jmp    L5
L0:
  movzbl -0x1e(%rbp),%eax
  cmp    -0x1d(%rbp),%al
  je     L38
  mov    -0x8(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L191
  cmpl   $0x1,-0x10(%rbp)
  jle    L191
  mov    $0xffffffff,%eax
  jmp    L5
L191:
  movl   $0x1,-0x10(%rbp)
  jmp    L74
L38:
  movsbl -0x1d(%rbp),%eax
  mov    %eax,%edi
  call   <alg_can_repeat@plt>
  test   %eax,%eax
  jne    L69
  mov    $0xffffffff,%eax
  jmp    L5
L69:
  addl   $0x1,-0x10(%rbp)
L74:
  cmpl   $0x0,-0xc(%rbp)
  je     L216
  cmpl   $0x1,-0x10(%rbp)
  jle    L216
  mov    $0xffffffff,%eax
  jmp    L5
L216:
  cmpl   $0x3,-0x10(%rbp)
  jle    L93
  mov    $0xffffffff,%eax
  jmp    L5
L93:
  mov    -0x8(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L72
  movsbl -0x1e(%rbp),%edx
  movsbl -0x1d(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <alg_can_come_before@plt>
  test   %eax,%eax
  jne    L152
  mov    $0xffffffff,%eax
  jmp    L5
L152:
  mov    -0x8(%rbp),%eax
  sub    %eax,-0x18(%rbp)
  movl   $0x1,-0xc(%rbp)
  jmp    L148
L72:
  mov    -0x8(%rbp),%eax
  add    %eax,-0x18(%rbp)
  movl   $0x0,-0xc(%rbp)
L148:
  movzbl -0x1d(%rbp),%eax
  mov    %al,-0x1e(%rbp)
  mov    -0x8(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  subl   $0x1,-0x1c(%rbp)
L70:
  cmpl   $0x0,-0x1c(%rbp)
  jns    L173
  mov    -0x18(%rbp),%eax
L5:
  leave
  ret
```

assistant: ```c
int roman_to_int(const char *input) {
  int length;
  int i;
  int finalValue = 0;
  int valueNow = -1;
  int valueBefore = -1;
  char algNow = '\0';
  char algBefore = '\0';
  int repetitions = 0;
  bool isSubtracting = false;
  length = string_length(input);
  if (length <= 0)
    return -1;
  for (i = length - 1; i >= 0; --i) {
    algNow = input[i];
    valueNow = alg_value(algNow);
    if (valueNow == -1)
      return -1;
    if (algBefore != algNow) {
      if (valueNow < valueBefore && repetitions > 1)
        return -1;
      repetitions = 1;
    } else {
      if (!alg_can_repeat(algNow))
        return -1;
      ++repetitions;
    }
    if (isSubtracting && repetitions >= 2)
      return -1;
    if (repetitions > 3)
      return -1;
    if (valueNow < valueBefore) {
      if (!alg_can_come_before(algNow, algBefore))
        return -1;
      finalValue -= valueNow;
      isSubtracting = true;
    } else {
      finalValue += valueNow;
      isSubtracting = false;
    }
    algBefore = algNow;
    valueBefore = valueNow;
  }
  return finalValue;
}
```