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

```asm
<check>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  mov    %edx,%r13d
  shl    $0x2,%edx
  push   %r12
  mov    %ecx,%r12d
  push   %rbx
  mov    %rdi,%rbx
  mov    %edx,%edi
  sub    $0x48,%rsp
  mov    %esi,-0x50(%rbp)
  mov    %r8d,-0x4c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %edx,-0x64(%rbp)
  call   <alloca@plt>
  lea    0x0(,%r12,4),%r9d
  mov    %r9d,%edi
  mov    %r9d,-0x60(%rbp)
  mov    %rax,%r14
  call   <alloca@plt>
  mov    -0x4c(%rbp),%ecx
  mov    %rax,%r15
  lea    0x0(,%rcx,4),%r8d
  mov    %r8d,%edi
  mov    %r8d,-0x48(%rbp)
  call   <alloca@plt>
  mov    -0x64(%rbp),%edx
  xor    %esi,%esi
  mov    %r14,%rdi
  mov    %rax,-0x58(%rbp)
  call   <memset@plt>
  mov    -0x60(%rbp),%edx
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <memset@plt>
  mov    -0x48(%rbp),%edx
  mov    -0x58(%rbp),%rdi
  xor    %esi,%esi
  call   <memset@plt>
  mov    -0x50(%rbp),%eax
  test   %eax,%eax
  jle    L19
  sub    $0x1,%eax
  mov    %rbx,%rcx
  mov    %r14,-0x60(%rbp)
  xor    %r9d,%r9d
  lea    0x4(%rbx,%rax,4),%rax
  mov    %rcx,%r14
  xor    %ebx,%ebx
  mov    %rax,-0x48(%rbp)
  jmp    L196
  cs nopw 0x0(%rax,%rax,1)
L145:
  cmp    %edi,-0x4c(%rbp)
  jle    L192
  mov    -0x58(%rbp),%rcx
  movslq %esi,%rsi
  addl   $0x1,(%rcx,%rdi,4)
  mov    -0x60(%rbp),%rcx
  addl   $0x1,(%r15,%rsi,4)
  addl   $0x1,(%rcx,%rax,4)
L137:
  mov    (%r14),%eax
  add    $0x4,%r14
  sar    $0x18,%eax
  add    %eax,%ebx
  cmp    %r14,-0x48(%rbp)
  je     L49
L196:
  mov    (%r14),%edx
  mov    %edx,%eax
  movzbl %dh,%esi
  movzbl %dl,%edi
  sar    $0x10,%eax
  movzbl %al,%eax
  cmp    %eax,%r13d
  setle  %r10b
  cmp    %esi,%r12d
  setle  %r11b
  or     %r11b,%r10b
  je     L145
L192:
  mov    %edx,%esi
  lea    D12(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
  jmp    L137
  nopl   0x0(%rax,%rax,1)
L49:
  mov    -0x60(%rbp),%r14
  test   %ebx,%ebx
  je     L19
  cmp    %ebx,-0x50(%rbp)
  jne    L156
  mov    %r14,%r8
  xor    %ebx,%ebx
  test   %r13d,%r13d
  jle    L46
  mov    %r12d,-0x48(%rbp)
  mov    %r14,%r12
  mov    %r13d,%r14d
  mov    %r8,%r13
  nopl   0x0(%rax)
L119:
  mov    (%r12),%edx
  cmp    %edx,0x0(%r13)
  je     L14
  mov    %ebx,%esi
  lea    D14(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L14:
  add    $0x1,%ebx
  add    $0x4,%r13
  cmp    %ebx,%r14d
  jne    L119
  mov    -0x48(%rbp),%r12d
L46:
  test   %r12d,%r12d
  jle    L64
  mov    %r15,%r14
  xor    %r13d,%r13d
  lea    D45(%rip),%rbx
  nopw   0x0(%rax,%rax,1)
L96:
  mov    (%r15),%edx
  cmp    %edx,(%r14)
  je     L99
  mov    %r13d,%esi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L99:
  add    $0x1,%r13d
  add    $0x4,%r14
  cmp    %r13d,%r12d
  jne    L96
L64:
  mov    -0x4c(%rbp),%r15d
  test   %r15d,%r15d
  jle    L169
  mov    -0x58(%rbp),%r14
  xor    %ebx,%ebx
  lea    D9(%rip),%r12
  mov    %r14,%r13
  nopl   0x0(%rax)
L85:
  mov    (%r14),%edx
  cmp    %edx,0x0(%r13)
  je     L97
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L97:
  add    $0x1,%ebx
  add    $0x4,%r13
  cmp    %ebx,%r15d
  jne    L85
L169:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L35
  lea    -0x28(%rbp),%rsp
  mov    %r9d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L156:
  mov    -0x50(%rbp),%edx
  mov    %ebx,%esi
  lea    D38(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
  jmp    L169
  nopl   0x0(%rax,%rax,1)
L19:
  xor    %r9d,%r9d
  jmp    L169
L35:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D12
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D14
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D45
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D9
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D38
type_infered: string

tool: D12: unexpected cpu %#x used


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


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


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


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


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