user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<check>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x50(%rbp)
  mov    %edx,%ebx
  mov    %ecx,%r15d
  mov    %r8d,%r13d
  mov    %r8d,-0x4c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    0x0(,%rdx,4),%r12d
  mov    %r12d,%edi
  call   <alloca@plt>
  mov    %rax,-0x58(%rbp)
  lea    0x0(,%r15,4),%r14d
  mov    %r14d,%edi
  call   <alloca@plt>
  mov    %rax,-0x60(%rbp)
  shl    $0x2,%r13d
  mov    %r13d,%edi
  call   <alloca@plt>
  mov    %rax,-0x68(%rbp)
  mov    %r12d,%edx
  mov    $0x0,%esi
  mov    -0x58(%rbp),%rdi
  call   <memset@plt>
  mov    %r14d,%edx
  mov    $0x0,%esi
  mov    -0x60(%rbp),%rdi
  call   <memset@plt>
  mov    %r13d,%edx
  mov    $0x0,%esi
  mov    -0x68(%rbp),%rdi
  call   <memset@plt>
  mov    -0x50(%rbp),%eax
  test   %eax,%eax
  jle    L96
  mov    -0x48(%rbp),%rcx
  mov    %rcx,%r13
  lea    -0x1(%rax),%eax
  lea    0x4(%rcx,%rax,4),%rax
  mov    %rax,-0x48(%rbp)
  mov    $0x0,%r12d
  mov    $0x0,%edi
  jmp    L0
L34:
  mov    %edx,%esi
  lea    D25(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
L221:
  mov    (%r14),%eax
  sar    $0x18,%eax
  add    %eax,%r12d
  add    $0x4,%r13
  cmp    -0x48(%rbp),%r13
  je     L186
L0:
  mov    %r13,%r14
  mov    0x0(%r13),%edx
  mov    %edx,%eax
  sar    $0x10,%eax
  movzbl %al,%eax
  movzbl %dh,%ecx
  movzbl %dl,%esi
  cmp    %eax,%ebx
  setle  %r8b
  cmp    %ecx,%r15d
  setle  %r9b
  or     %r9b,%r8b
  jne    L34
  cmp    %esi,-0x4c(%rbp)
  jle    L34
  movslq %esi,%rsi
  mov    -0x68(%rbp),%rdx
  addl   $0x1,(%rdx,%rsi,4)
  movslq %ecx,%rcx
  mov    -0x60(%rbp),%rsi
  addl   $0x1,(%rsi,%rcx,4)
  cltq
  mov    -0x58(%rbp),%rcx
  addl   $0x1,(%rcx,%rax,4)
  jmp    L221
L186:
  test   %r12d,%r12d
  je     L39
  cmp    %r12d,-0x50(%rbp)
  jne    L269
  mov    -0x58(%rbp),%r13
  mov    $0x0,%r12d
  lea    D0(%rip),%r14
  test   %ebx,%ebx
  jle    L8
  mov    %r15d,-0x48(%rbp)
  mov    -0x58(%rbp),%r15
  jmp    L243
L269:
  mov    -0x50(%rbp),%edx
  mov    %r12d,%esi
  lea    D41(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%r12d
  jmp    L39
L13:
  add    $0x1,%r12d
  add    $0x4,%r13
  cmp    %r12d,%ebx
  je     L104
L243:
  mov    (%r15),%edx
  cmp    %edx,0x0(%r13)
  je     L13
  mov    %r12d,%esi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  jmp    L13
L104:
  mov    -0x48(%rbp),%r15d
L8:
  test   %r15d,%r15d
  jle    L102
  mov    -0x60(%rbp),%r14
  mov    %r14,%r12
  mov    $0x0,%ebx
  lea    D38(%rip),%r13
  jmp    L230
L146:
  add    $0x1,%ebx
  add    $0x4,%r12
  cmp    %ebx,%r15d
  je     L102
L230:
  mov    (%r14),%edx
  cmp    %edx,(%r12)
  je     L146
  mov    %ebx,%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  jmp    L146
L102:
  mov    -0x4c(%rbp),%ecx
  test   %ecx,%ecx
  jle    L161
  mov    -0x68(%rbp),%r15
  mov    %r15,%r13
  mov    $0x0,%ebx
  lea    D36(%rip),%r14
  mov    %edi,%eax
  mov    %ecx,%r12d
  jmp    L23
L41:
  add    $0x1,%ebx
  add    $0x4,%r13
  cmp    %ebx,%r12d
  je     L55
L23:
  mov    (%r15),%edx
  cmp    %edx,0x0(%r13)
  je     L41
  mov    %ebx,%esi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L41
L55:
  mov    %eax,%r12d
L39:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L154
  mov    %r12d,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L96:
  mov    $0x0,%r12d
  jmp    L39
L161:
  mov    %edi,%r12d
  jmp    L39
L154:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D25
type: string
name: read_data
arguments: tag: D0
type: string
name: read_data
arguments: tag: D41
type: string
name: read_data
arguments: tag: D38
type: string
name: read_data
arguments: tag: D36
type: string

tool: D25: unexpected cpu %#x used


tool: D0: gang %d not used %d times


tool: D41: offloaded %d times,  expected %d


tool: D38: worker %d not used %d times


tool: D36: vector %d not used %d times


assistant: ```c
int check(const int *ary, int size, int gp, int wp, int vp) {
  int exit = 0;
  int ix;
  int *gangs = (int *)alloca(gp * sizeof(int));
  int *workers = (int *)alloca(wp * sizeof(int));
  int *vectors = (int *)alloca(vp * sizeof(int));
  int offloaded = 0;
  memset(gangs, 0, gp * sizeof(int));
  memset(workers, 0, wp * sizeof(int));
  memset(vectors, 0, vp * sizeof(int));
  for (ix = 0; ix < size; ix++) {
    int g = (ary[ix] >> 16) & 0xff;
    int w = (ary[ix] >> 8) & 0xff;
    int v = (ary[ix] >> 0) & 0xff;
    if (g >= gp || w >= wp || v >= vp) {
      printf("unexpected cpu %#x used\n", ary[ix]);
      exit = 1;
    } else {
      vectors[v]++;
      workers[w]++;
      gangs[g]++;
    }
    offloaded += ary[ix] >> 24;
  }
  if (!offloaded)
    return 0;
  if (offloaded != size) {
    printf("offloaded %d times,  expected %d\n", offloaded, size);
    return 1;
  }
  for (ix = 0; ix < gp; ix++)
    if (gangs[ix] != gangs[0]) {
      printf("gang %d not used %d times\n", ix, gangs[0]);
      exit = 1;
    }
  for (ix = 0; ix < wp; ix++)
    if (workers[ix] != workers[0]) {
      printf("worker %d not used %d times\n", ix, workers[0]);
      exit = 1;
    }
  for (ix = 0; ix < vp; ix++)
    if (vectors[ix] != vectors[0]) {
      printf("vector %d not used %d times\n", ix, vectors[0]);
      exit = 1;
    }
  return exit;
}
```