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

```asm
<formalBMStrstr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x3b8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x13a8(%rsp)
  xor    %eax,%eax
  cmp    %ecx,%esi
  jl     L117
  mov    %rdx,%rbx
  mov    %ecx,%r13d
  mov    %esi,%r14d
  mov    %rsp,%rdx
  mov    %ecx,%esi
  mov    %rdi,%r12
  mov    %rbx,%rdi
  mov    %r8d,%ebp
  sub    %ecx,%r14d
  call   <makeBMTable1@plt>
  lea    0x400(%rsp),%rdx
  mov    %r13d,%esi
  mov    %rbx,%rdi
  call   <makeBMTable2@plt>
  mov    $0xffffffff,%r11d
  xor    %r9d,%r9d
  mov    $0x1,%r10d
  cmp    %ebp,%r14d
  jl     L117
L73:
  test   %r13d,%r13d
  jle    L179
L98:
  movslq %ebp,%r15
  movslq %r13d,%rax
  xor    %edi,%edi
  xor    %r8d,%r8d
  add    %r12,%r15
  jmp    L140
  nop
L167:
  cmp    $0x78,%dl
  jne    L114
L168:
  sub    $0x1,%rax
  mov    $0x1,%r8d
  lea    -0x1(%rsi),%ecx
  test   %eax,%eax
  jle    L79
L140:
  movsbq -0x1(%r15,%rax,1),%rdx
  mov    %eax,%esi
  mov    %eax,%ecx
  cmp    %dl,-0x1(%rbx,%rax,1)
  jne    L167
  cmp    $0x78,%dl
  je     L168
  sub    $0x1,%rax
  add    $0x1,%edi
  lea    -0x1(%rsi),%ecx
  test   %eax,%eax
  jg     L140
L79:
  test   %ecx,%ecx
  jne    L174
  cmp    %r9d,%edi
  jle    L97
  mov    %ebp,%r11d
  mov    %edi,%r9d
L97:
  add    $0x1,%ebp
  cmp    %r14d,%ebp
  jle    L73
L128:
  mov    0x13a8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L99
  add    $0x13b8,%rsp
  mov    %r11d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L174:
  lea    (%rcx,%rbp,1),%eax
  cltq
  movsbq -0x1(%r12,%rax,1),%rdx
L114:
  mov    (%rsp,%rdx,4),%edx
  mov    %ecx,%eax
  test   %edx,%edx
  jle    L22
  mov    %r13d,%esi
  mov    %edx,%eax
  sub    %ecx,%esi
  sub    %esi,%eax
  cmp    %esi,%edx
  cmovl  %r10d,%eax
L22:
  test   %r8d,%r8d
  jne    L101
L160:
  sub    $0x1,%ecx
  movslq %ecx,%rcx
  mov    0x400(%rsp,%rcx,4),%r8d
L101:
  cmp    %r8d,%eax
  cmovl  %r8d,%eax
  add    %eax,%ebp
  cmp    %r14d,%ebp
  jg     L128
  test   %r13d,%r13d
  jg     L98
L179:
  je     L97
  lea    0x0(%r13,%rbp,1),%eax
  mov    %r13d,%ecx
  cltq
  movsbq -0x1(%r12,%rax,1),%rax
  mov    (%rsp,%rax,4),%eax
  test   %eax,%eax
  cmovle %r13d,%eax
  jmp    L160
L117:
  mov    $0xffffffff,%r11d
  jmp    L128
L99:
  call   <__stack_chk_fail@plt>
```

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;
}
```