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

```asm
<ASAP_ParseDuration>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  test   %eax,%eax
  jle    L169
  mov    %eax,%edx
  movsbl (%rbx),%eax
  sub    $0x30,%eax
  cmp    $0x9,%eax
  ja     L169
  cmp    $0x1,%edx
  je     L194
  movsbl 0x1(%rbx),%ecx
  sub    $0x30,%ecx
  cmp    $0x9,%ecx
  jbe    L130
  mov    $0x4,%ecx
  mov    $0x3,%r11d
  mov    $0x3,%r10d
  mov    $0x2,%r9d
  mov    $0x2,%r8d
  mov    $0x1,%esi
  mov    $0x1,%edi
L148:
  movzbl (%rbx,%rsi,1),%esi
  cmp    $0x3a,%sil
  je     L101
  imul   $0x3e8,%eax,%eax
  mov    %edi,%ecx
L40:
  cmp    $0x2e,%sil
  jne    L169
  lea    0x1(%rcx),%esi
  cmp    %esi,%edx
  jle    L169
  movslq %esi,%rsi
  movsbl (%rbx,%rsi,1),%esi
  sub    $0x30,%esi
  cmp    $0x9,%esi
  ja     L169
  imul   $0x64,%esi,%esi
  lea    0x2(%rcx),%edi
  add    %esi,%eax
  cmp    %edi,%edx
  jle    L124
  movslq %edi,%rdi
  movsbl (%rbx,%rdi,1),%esi
  sub    $0x30,%esi
  cmp    $0x9,%esi
  ja     L169
  lea    (%rsi,%rsi,4),%esi
  add    $0x3,%ecx
  lea    (%rax,%rsi,2),%eax
  cmp    %ecx,%edx
  jle    L124
  movslq %ecx,%rcx
  movsbl (%rbx,%rcx,1),%edx
  sub    $0x30,%edx
  cmp    $0x9,%edx
  ja     L169
  add    %edx,%eax
L124:
  pop    %rbx
  ret
  nopl   0x0(%rax,%rax,1)
L130:
  lea    (%rax,%rax,4),%eax
  lea    (%rcx,%rax,2),%eax
  cmp    $0x2,%edx
  jne    L141
L194:
  imul   $0x3e8,%eax,%eax
  pop    %rbx
  ret
  nopl   0x0(%rax,%rax,1)
L101:
  cmp    %edx,%r8d
  jge    L169
  movsbl (%rbx,%r9,1),%esi
  sub    $0x30,%esi
  cmp    $0x5,%esi
  ja     L169
  lea    (%rax,%rax,2),%eax
  lea    (%rsi,%rax,2),%eax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  cmp    %r10d,%edx
  jle    L169
  movsbl (%rbx,%r11,1),%esi
  sub    $0x30,%esi
  cmp    $0x9,%esi
  ja     L169
  add    %esi,%eax
  imul   $0x3e8,%eax,%eax
  cmp    %ecx,%edx
  jle    L124
  movslq %ecx,%rsi
  movzbl (%rbx,%rsi,1),%esi
  jmp    L40
  nopw   0x0(%rax,%rax,1)
L169:
  mov    $0xffffffff,%eax
  pop    %rbx
  ret
L141:
  mov    $0x5,%ecx
  mov    $0x4,%r11d
  mov    $0x4,%r10d
  mov    $0x3,%r9d
  mov    $0x3,%r8d
  mov    $0x2,%esi
  mov    $0x2,%edi
  jmp    L148
```

assistant: ```c
int ASAP_ParseDuration(const char *s) {
  int i = 0;
  int r;
  int d;
  int n = strlen(s);
  if (i >= n)
    return -1;
  d = (s)[i] - 48;
  if (d < 0 || d > 9)
    return -1;
  i++;
  ;
  r = d;
  if (i < n) {
    d = (s)[i] - 48;
    if (d >= 0 && d <= 9) {
      i++;
      r = 10 * r + d;
    }
    if (i < n && (s)[i] == ':') {
      i++;
      if (i >= n)
        return -1;
      d = (s)[i] - 48;
      if (d < 0 || d > 5)
        return -1;
      i++;
      ;
      r = (6 * r + d) * 10;
      if (i >= n)
        return -1;
      d = (s)[i] - 48;
      if (d < 0 || d > 9)
        return -1;
      i++;
      ;
      r += d;
    }
  }
  r *= 1000;
  if (i >= n)
    return r;
  if ((s)[i] != '.')
    return -1;
  i++;
  if (i >= n)
    return -1;
  d = (s)[i] - 48;
  if (d < 0 || d > 9)
    return -1;
  i++;
  ;
  r += 100 * d;
  if (i >= n)
    return r;
  d = (s)[i] - 48;
  if (d < 0 || d > 9)
    return -1;
  i++;
  ;
  r += 10 * d;
  if (i >= n)
    return r;
  d = (s)[i] - 48;
  if (d < 0 || d > 9)
    return -1;
  i++;
  ;
  r += d;
  return r;
}
```