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

```asm
<CalcFrameLength>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %edx,-0x2c(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    %r9,-0x40(%rbp)
  movl   $0x0,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0xffffffff,%eax
  je     L89
  mov    0x10(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0xffffffff,%eax
  jne    L94
L89:
  mov    $0xffffffff,%eax
  jmp    L64
L94:
  movl   $0x0,-0x14(%rbp)
  jmp    L98
L30:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    0x20(%rbp),%eax
  cltd
  idiv   %esi
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  imul   -0x28(%rbp),%eax
  add    %eax,-0x10(%rbp)
  addl   $0x1,-0x14(%rbp)
L98:
  mov    -0x14(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L30
  cmpl   $0x0,-0x30(%rbp)
  je     L20
  mov    -0x30(%rbp),%eax
  shl    $0x3,%eax
  cltd
  idivl  -0x10(%rbp)
  mov    %eax,-0x18(%rbp)
  mov    -0x30(%rbp),%eax
  shl    $0x3,%eax
  cltd
  idivl  -0x10(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  je     L87
  addl   $0x1,-0x18(%rbp)
  jmp    L87
L20:
  movl   $0x0,-0x18(%rbp)
L87:
  mov    -0x18(%rbp),%eax
  imul   0x20(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  imul   -0x8(%rbp),%eax
  cmp    $0xb,%eax
  jg     L85
  mov    $0xffffffff,%eax
  jmp    L64
L85:
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L96
L61:
  mov    -0x28(%rbp),%eax
  imul   -0xc(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edi
  cltd
  idiv   %edi
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  add    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%eax
  imul   -0x8(%rbp),%eax
  sub    $0xc,%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%esi
  cltd
  idiv   %esi
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    0x10(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  add    %eax,-0x1c(%rbp)
  addl   $0x1,-0x14(%rbp)
L96:
  mov    -0x14(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L61
  mov    -0x20(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x30(%rbp),%eax
  shl    $0x3,%eax
  cmp    %eax,-0x4(%rbp)
  jge    L80
  mov    $0xffffffff,%eax
  jmp    L64
L80:
  mov    -0x4(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
L64:
  pop    %rbp
  ret
```

assistant: ```c
int CalcFrameLength(int NumLevels, int GrossBitsPerCell, int NumCells, int BytesA, int *pNumeratorsA, int *pDenominatorsA, int *pNumeratorsB, int *pDenominatorsB, int LCM) {
  int NumCellsA, NumCellsB;
  int NetBitsA, NetBitsB;
  int TotalNetBits;
  int NumLCMA;
  int l;
  int BitsPerLCM = 0;
  if (pNumeratorsA[0] == -1 || pNumeratorsB[0] == -1)
    return -1;
  for (l = 0; l < NumLevels; l++) {
    BitsPerLCM += LCM / pDenominatorsA[l] * pNumeratorsA[l] * GrossBitsPerCell;
  }
  if (BytesA != 0) {
    NumLCMA = 8 * BytesA / BitsPerLCM;
    if ((8 * BytesA) % BitsPerLCM != 0) {
      NumLCMA++;
    }
  } else
    NumLCMA = 0;
  NumCellsA = NumLCMA * LCM;
  NumCellsB = NumCells - NumCellsA;
  if (GrossBitsPerCell * NumCellsB - 12 < 0)
    return -1;
  NetBitsA = 0;
  NetBitsB = 0;
  for (l = 0; l < NumLevels; l++) {
    NetBitsA += GrossBitsPerCell * NumCellsA / pDenominatorsA[l] * pNumeratorsA[l];
    NetBitsB += (GrossBitsPerCell * NumCellsB - 12) / pDenominatorsB[l] * pNumeratorsB[l];
  }
  TotalNetBits = NetBitsA + NetBitsB;
  if (TotalNetBits < 8 * BytesA)
    return -1;
  else
    return (TotalNetBits / 8);
}
```