user: Translate the below assembly code into C programming language:

```asm
<_substr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %rcx,-0x40(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0xffffffff,-0x1c(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L175
  mov    $0xffffffff,%eax
  jmp    L60
L144:
  nop
L139:
  addq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L139
L175:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <sqlite3ReadUtf8@plt>
  test   %rax,%rax
  je     L170
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  cmp    %eax,-0x34(%rbp)
  jg     L144
L170:
  movl   $0x0,-0x20(%rbp)
  jmp    L49
L37:
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x8(%rbp)
L76:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <sqlite3ReadUtf8@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <sqlite3ReadUtf8@plt>
  mov    %eax,-0x14(%rbp)
  nop
L56:
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L56
  nop
L83:
  addq   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L83
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L47
  cmpl   $0x0,-0x18(%rbp)
  je     L47
  cmpl   $0x0,-0x14(%rbp)
  jne    L76
L47:
  cmpl   $0x0,-0x18(%rbp)
  jne    L114
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L86
L114:
  nop
L123:
  addq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xc0,%eax
  cmp    $0x80,%eax
  je     L123
  addl   $0x1,-0x20(%rbp)
L49:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <sqlite3ReadUtf8@plt>
  test   %rax,%rax
  jne    L37
L86:
  cmpq   $0x0,-0x40(%rbp)
  je     L61
  mov    -0x40(%rbp),%rax
  mov    -0x30(%rbp),%rdx
  mov    %rdx,(%rax)
L61:
  cmpl   $0x0,-0x1c(%rbp)
  js     L108
  mov    -0x1c(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  jmp    L60
L108:
  mov    -0x1c(%rbp),%eax
L60:
  leave
  ret
```

assistant: ```c
int _substr(const char *z1, const char *z2, int s, const char **p) {
  int c = 0;
  int rVal = -1;
  const char *zt1;
  const char *zt2;
  int c1, c2;
  if ('\0' == *z1) {
    return -1;
  }
  while ((sqlite3ReadUtf8((unsigned char *)z2) != 0) && (c++) < s) {
    while ((0xc0 & *++(z2)) == 0x80) {
    };
  }
  c = 0;
  while ((sqlite3ReadUtf8((unsigned char *)z2)) != 0) {
    zt1 = z1;
    zt2 = z2;
    do {
      c1 = sqlite3ReadUtf8((unsigned char *)zt1);
      c2 = sqlite3ReadUtf8((unsigned char *)zt2);
      while ((0xc0 & *++(zt1)) == 0x80) {
      };
      while ((0xc0 & *++(zt2)) == 0x80) {
      };
    } while (c1 == c2 && c1 != 0 && c2 != 0);
    if (c1 == 0) {
      rVal = c;
      break;
    }
    while ((0xc0 & *++(z2)) == 0x80) {
    };
    ++c;
  }
  if (p) {
    *p = z2;
  }
  return rVal >= 0 ? rVal + s : rVal;
}
```