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

```asm
<pmesh_get_invariant_index>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %edi,%r15d
  mov    %edi,-0x60(%rbp)
  mov    %rsi,%rbx
  mov    %edx,%r14d
  mov    %ecx,-0x5c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <absmax@plt>
  mov    %eax,-0x58(%rbp)
  test   %eax,%eax
  je     L179
  test   %r15d,%r15d
  jle    L63
  mov    %r15d,%esi
  mov    $0x0,%eax
  jmp    L290
L394:
  add    $0x1,%rax
  cmp    %rsi,%rax
  je     L9
L290:
  bt     %eax,%r14d
  jae    L394
  cmpl   $0x0,(%rbx,%rax,4)
  jns    L394
  movl   $0xffffffff,-0x58(%rbp)
L179:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L352
  mov    -0x58(%rbp),%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L354:
  movslq %r8d,%rcx
  mov    %eax,0x0(%r13,%rcx,4)
  mov    %r14d,%eax
  mov    %edx,%ecx
  sar    %cl,%eax
  and    $0x1,%eax
  mov    %r8d,%ecx
  shl    %cl,%eax
  or     %eax,%r9d
  add    $0x1,%r8d
L230:
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  je     L305
L379:
  mov    (%rbx,%rdx,4),%eax
  mov    %eax,%ecx
  neg    %ecx
  cmovs  %eax,%ecx
  cmp    %r10d,%ecx
  jne    L354
  mov    %edi,%r15d
  mov    %edx,%ecx
  shl    %cl,%r15d
  or     %r15d,%r11d
  shr    $0x1f,%eax
  shl    %cl,%eax
  or     %eax,%r12d
  jmp    L230
L305:
  mov    %r11d,-0x64(%rbp)
  mov    %r12d,-0x4c(%rbp)
  mov    %r9d,-0x70(%rbp)
  mov    %r8d,-0x74(%rbp)
  mov    $0x1,%eax
  movzbl -0x60(%rbp),%ecx
  shl    %cl,%eax
  mov    %eax,-0x6c(%rbp)
  movslq %eax,%rdx
  lea    0xf(,%rdx,4),%rax
  mov    %rax,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L276:
  cmp    %rcx,%rsp
  je     L218
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L276
L218:
  mov    %rsi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L53
  orq    $0x0,-0x8(%rsp,%rax,1)
L53:
  mov    %rsp,%rdi
  mov    %rdi,%r15
  shl    $0x2,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  cmpl   $0x0,-0x6c(%rbp)
  jle    L289
L363:
  mov    -0x58(%rbp),%eax
  add    %eax,%eax
  mov    %eax,-0x68(%rbp)
  mov    $0x0,%r13d
  movl   $0x0,-0x48(%rbp)
  mov    -0x5c(%rbp),%eax
  not    %eax
  mov    %eax,-0x50(%rbp)
  mov    %r14d,-0x44(%rbp)
  jmp    L28
L78:
  mov    -0x5c(%rbp),%ebx
  mov    %ebx,%ecx
  mov    -0x48(%rbp),%r15d
  sub    %r15d,%ecx
  test   %ebx,%ebx
  mov    $0xffffffff,%eax
  cmovs  %eax,%ecx
  mov    -0x70(%rbp),%edx
  mov    -0x80(%rbp),%rsi
  mov    -0x74(%rbp),%edi
  call   <pmesh_get_invariant_index>
  mov    %eax,-0x58(%rbp)
  cmp    $0xffffffff,%eax
  je     L179
  add    %r15d,%eax
  mov    %eax,%edx
  mov    %eax,-0x58(%rbp)
  test   %ebx,%ebx
  js     L179
  cmp    %eax,%ebx
  mov    $0xffffffff,%eax
  cmovg  %edx,%eax
  mov    %eax,-0x58(%rbp)
  jmp    L179
L409:
  call   <get_nbits@plt>
  mov    %eax,-0x54(%rbp)
  mov    %r12d,%edi
  and    -0x44(%rbp),%edi
  call   <get_nbits@plt>
  mov    -0x60(%rbp),%esi
  sub    -0x54(%rbp),%esi
  mov    %eax,-0x54(%rbp)
  sub    %eax,%esi
  mov    -0x68(%rbp),%edx
  lea    -0x1(%rdx),%edi
  call   <ipow@plt>
  mov    %eax,%r12d
  mov    -0x54(%rbp),%esi
  mov    -0x58(%rbp),%edi
  call   <ipow@plt>
  imul   %eax,%r12d
  mov    %r12d,(%r15,%rbx,4)
  jmp    L408
L145:
  add    $0x1,%rbx
  cmp    %rbx,%r14
  je     L8
L382:
  mov    %ebx,%edi
  mov    %ebx,%r12d
  not    %r12d
  mov    -0x44(%rbp),%eax
  or     %r12d,%eax
  test   %r13d,%eax
  jne    L145
  cmp    -0x4c(%rbp),%r13d
  jne    L141
  cmp    %ebx,-0x64(%rbp)
  je     L78
L141:
  cmpl   $0x0,(%r15,%rbx,4)
  je     L409
L408:
  mov    -0x48(%rbp),%eax
  add    (%r15,%rbx,4),%eax
  mov    %eax,-0x48(%rbp)
  cmpl   $0x0,-0x50(%rbp)
  jns    L145
  cmp    -0x5c(%rbp),%eax
  jl     L145
  movl   $0xffffffff,-0x58(%rbp)
  jmp    L179
L8:
  add    $0x1,%r13d
  cmp    -0x6c(%rbp),%r13d
  je     L172
L28:
  mov    -0x6c(%rbp),%r14d
  mov    $0x0,%ebx
  jmp    L382
L289:
  movl   $0xffffffff,-0x58(%rbp)
  jmp    L179
L172:
  movl   $0xffffffff,-0x58(%rbp)
  jmp    L179
L9:
  movslq -0x60(%rbp),%rax
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L300:
  cmp    %rdx,%rsp
  je     L193
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L300
L193:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L48
  orq    $0x0,-0x8(%rsp,%rax,1)
L48:
  mov    %rsp,%r13
  mov    %r13,-0x80(%rbp)
  mov    $0x0,%edx
  mov    $0x0,%r8d
  mov    $0x0,%r9d
  mov    $0x0,%r12d
  mov    $0x0,%r11d
  mov    $0x1,%edi
  mov    -0x58(%rbp),%r10d
  jmp    L379
L63:
  movslq -0x60(%rbp),%rax
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L165:
  cmp    %rcx,%rsp
  je     L31
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L165
L31:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L286
  orq    $0x0,-0x8(%rsp,%rax,1)
L286:
  mov    %rsp,-0x80(%rbp)
  mov    $0x1,%eax
  movzbl -0x60(%rbp),%ecx
  shl    %cl,%eax
  mov    %eax,-0x6c(%rbp)
  cltq
  lea    0xf(,%rax,4),%rcx
  mov    %rcx,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rsi
  sub    %rcx,%rsi
L297:
  cmp    %rsi,%rsp
  je     L80
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L297
L80:
  mov    %rdx,%rcx
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L115
  orq    $0x0,-0x8(%rsp,%rcx,1)
L115:
  mov    %rsp,%rdi
  mov    %rdi,%r15
  lea    0x0(,%rax,4),%edx
  mov    $0x0,%esi
  call   <memset@plt>
  movl   $0x0,-0x74(%rbp)
  movl   $0x0,-0x70(%rbp)
  movl   $0x0,-0x4c(%rbp)
  movl   $0x0,-0x64(%rbp)
  jmp    L363
L352:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ptrdiff_t pmesh_get_invariant_index(int ndim, const ptrdiff_t x[], const uint32_t cmask, ptrdiff_t max_length) {
  int d;
  ptrdiff_t shell = absmax(ndim, x);
  if (shell == 0)
    return 0;
  ptrdiff_t side = shell * 2 + 1;
  ptrdiff_t ind = 0;
  uint32_t icapset = 0;
  uint32_t icapset_x = 0;
  uint32_t icap_x = 0;
  for (d = 0; d < ndim; d++) {
    if ((cmask & (1 << d)) && x[d] < 0) {
      return -1;
    }
  }
  ptrdiff_t x1[ndim];
  uint32_t cmask1 = 0;
  int ndim1;
  for (ndim1 = 0, d = 0; d < ndim; d++) {
    if (abs(x[d]) == shell) {
      icapset_x |= (1 << d);
      icap_x |= (x[d] < 0) * (1 << d);
    } else {
      x1[ndim1] = x[d];
      cmask1 |= (1 << ndim1) * ((cmask >> d) & 1);
      ndim1++;
    }
  }
  int ncapsets = 1 << ndim;
  int ncapsmax = 1 << ndim;
  int icap;
  ptrdiff_t size[ncapsets];
  memset(size, 0, sizeof(size[0]) * ncapsets);
  for (icap = 0; icap < ncapsmax; icap++) {
    for (icapset = 0; icapset < ncapsets; icapset++) {
      if (icap & ~icapset)
        continue;
      if (icap & cmask)
        continue;
      if (icap == icap_x && icapset == icapset_x) {
        ptrdiff_t max_length1 = -1;
        if (max_length >= 0) {
          max_length1 = max_length - ind;
        }
        ptrdiff_t subind = pmesh_get_invariant_index(ndim1, x1, cmask1, max_length1);
        if (subind == -1) {
          return -1;
        }
        ind += subind;
        if (max_length >= 0 && ind >= max_length) {
          return -1;
        }
        return ind;
      }
      if (size[icapset] == 0) {
        int n = get_nbits(icapset);
        int nhalf = get_nbits(cmask & ~icapset);
        size[icapset] = ipow(side - 2, ndim - n - nhalf) * ipow(shell, nhalf);
      }
      ind += size[icapset];
      if (max_length >= 0 && ind >= max_length) {
        return -1;
      }
    }
  }
  return -1;
}
```