user: Converte this assembly snippet into its equivalent C code:

```asm
<formalBMStrstr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x400,%rsp
  mov    %rdi,-0x13e8(%rbp)
  mov    %esi,-0x13ec(%rbp)
  mov    %rdx,-0x13f8(%rbp)
  mov    %ecx,-0x13f0(%rbp)
  mov    %r8d,-0x13fc(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x13ec(%rbp),%eax
  cmp    -0x13f0(%rbp),%eax
  jge    L184
  mov    $0xffffffff,%eax
  jmp    L70
L184:
  mov    -0x13f0(%rbp),%eax
  sub    %eax,-0x13ec(%rbp)
  lea    -0x13b0(%rbp),%rdx
  mov    -0x13f0(%rbp),%ecx
  mov    -0x13f8(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <makeBMTable1@plt>
  lea    -0xfb0(%rbp),%rdx
  mov    -0x13f0(%rbp),%ecx
  mov    -0x13f8(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <makeBMTable2@plt>
  movl   $0x0,-0x13cc(%rbp)
  movl   $0xffffffff,-0x13c4(%rbp)
  jmp    L53
L192:
  movl   $0x0,-0x13c8(%rbp)
  movl   $0x0,-0x13d0(%rbp)
  mov    -0x13f0(%rbp),%eax
  mov    %eax,-0x13d8(%rbp)
  jmp    L109
L142:
  mov    -0x13fc(%rbp),%edx
  mov    -0x13d8(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x13e8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x13d8(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rcx
  mov    -0x13f8(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  je     L45
  mov    -0x13fc(%rbp),%edx
  mov    -0x13d8(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x13e8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  jne    L160
L45:
  mov    -0x13fc(%rbp),%edx
  mov    -0x13d8(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x13e8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  jne    L66
  movl   $0x1,-0x13d0(%rbp)
  jmp    L40
L66:
  addl   $0x1,-0x13c8(%rbp)
L40:
  subl   $0x1,-0x13d8(%rbp)
L109:
  cmpl   $0x0,-0x13d8(%rbp)
  jg     L142
  jmp    L21
L160:
  nop
L21:
  cmpl   $0x0,-0x13d8(%rbp)
  jne    L170
  mov    -0x13cc(%rbp),%eax
  cmp    -0x13c8(%rbp),%eax
  jge    L115
  mov    -0x13c8(%rbp),%eax
  mov    %eax,-0x13cc(%rbp)
  mov    -0x13fc(%rbp),%eax
  mov    %eax,-0x13c4(%rbp)
L115:
  addl   $0x1,-0x13fc(%rbp)
  jmp    L53
L170:
  mov    -0x13fc(%rbp),%edx
  mov    -0x13d8(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x13e8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cltq
  mov    -0x13b0(%rbp,%rax,4),%eax
  mov    %eax,-0x13c0(%rbp)
  mov    -0x13d8(%rbp),%eax
  mov    %eax,-0x13d4(%rbp)
  cmpl   $0x0,-0x13c0(%rbp)
  jle    L186
  mov    -0x13f0(%rbp),%eax
  sub    -0x13d8(%rbp),%eax
  mov    %eax,-0x13bc(%rbp)
  mov    -0x13c0(%rbp),%eax
  cmp    -0x13bc(%rbp),%eax
  jl     L194
  mov    -0x13c0(%rbp),%eax
  sub    -0x13bc(%rbp),%eax
  jmp    L81
L194:
  mov    $0x1,%eax
L81:
  mov    %eax,-0x13d4(%rbp)
L186:
  cmpl   $0x0,-0x13d0(%rbp)
  jne    L75
  mov    -0x13d8(%rbp),%eax
  sub    $0x1,%eax
  cltq
  mov    -0xfb0(%rbp,%rax,4),%eax
  jmp    L155
L75:
  mov    $0x1,%eax
L155:
  mov    %eax,-0x13b8(%rbp)
  mov    -0x13b8(%rbp),%edx
  mov    -0x13d4(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  mov    %eax,-0x13b4(%rbp)
  mov    -0x13b4(%rbp),%eax
  add    %eax,-0x13fc(%rbp)
L53:
  mov    -0x13fc(%rbp),%eax
  cmp    -0x13ec(%rbp),%eax
  jle    L192
  mov    -0x13c4(%rbp),%eax
L70:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L41
  call   <__stack_chk_fail@plt>
L41:
  leave
  ret
```

assistant: ```c
int formalBMStrstr(char *text, int txtLen, char *pattern, int patLen, int txtIdx) {
  int bmTable1[256], bmTable2[1000], patIdx, shtIdx, shtIdx1, shtIdx2, i1, i2, includeX, maxMatch, match, maxIdx;
  if (txtLen < patLen)
    return -1;
  txtLen -= patLen;
  makeBMTable1(pattern, patLen, bmTable1);
  makeBMTable2(pattern, patLen, bmTable2);
  maxMatch = 0;
  maxIdx = -1;
  while (txtIdx <= txtLen) {
    match = 0;
    includeX = 0;
    patIdx = patLen;
    for (; patIdx > 0; --patIdx) {
      if (text[txtIdx + patIdx - 1] != pattern[patIdx - 1] && text[txtIdx + patIdx - 1] != 'x')
        break;
      if (text[txtIdx + patIdx - 1] == 'x')
        includeX = 1;
      else
        ++match;
    }
    if (patIdx == 0) {
      if (maxMatch < match) {
        maxMatch = match;
        maxIdx = txtIdx;
      }
      ++txtIdx;
      continue;
    }
    i1 = bmTable1[(int)text[txtIdx + patIdx - 1]];
    shtIdx1 = patIdx;
    if (i1 > 0) {
      i2 = patLen - patIdx;
      shtIdx1 = (i1 < i2) ? 1 : i1 - i2;
    }
    shtIdx2 = (includeX == 0) ? bmTable2[patIdx - 1] : 1;
    shtIdx = (shtIdx1 > shtIdx2) ? shtIdx1 : shtIdx2;
    txtIdx += shtIdx;
  }
  return maxIdx;
}
```