user: Translate the below assembly code into C programming language:

```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,-0x58(%rbp)
  mov    %r8d,-0x54(%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,-0x50(%rbp)
  mov    %rax,%r14
  call   <alloca@plt>
  mov    -0x54(%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,-0x60(%rbp)
  call   <memset@plt>
  mov    -0x50(%rbp),%edx
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <memset@plt>
  mov    -0x48(%rbp),%edx
  mov    -0x60(%rbp),%rdi
  xor    %esi,%esi
  call   <memset@plt>
  mov    -0x58(%rbp),%eax
  test   %eax,%eax
  jle    L110
  sub    $0x1,%eax
  mov    %rbx,%rcx
  mov    %r15,%r8
  xor    %r9d,%r9d
  lea    0x4(%rbx,%rax,4),%rax
  xor    %ebx,%ebx
  mov    %r14,%r15
  mov    %r12d,%r14d
  mov    %rax,-0x50(%rbp)
  mov    %ebx,%r12d
  mov    %rcx,%rbx
  nopl   0x0(%rax)
L167:
  mov    (%rbx),%edx
  mov    %edx,%eax
  movzbl %dh,%ecx
  movzbl %dl,%esi
  sar    $0x10,%eax
  movzbl %al,%eax
  cmp    %eax,%r13d
  setle  %dil
  cmp    %ecx,%r14d
  setle  %r10b
  or     %r10b,%dil
  jne    L133
  cmp    %esi,-0x54(%rbp)
  jle    L133
  mov    -0x60(%rbp),%rdi
  movslq %ecx,%rcx
  add    $0x4,%rbx
  addl   $0x1,(%rdi,%rsi,4)
  addl   $0x1,(%r8,%rcx,4)
  addl   $0x1,(%r15,%rax,4)
  mov    -0x4(%rbx),%eax
  sar    $0x18,%eax
  add    %eax,%r12d
  cmp    %rbx,-0x50(%rbp)
  jne    L167
  mov    %r12d,%ebx
  mov    %r14d,%r12d
  mov    %r15,%r14
  mov    %r8,%r15
  test   %ebx,%ebx
  jne    L159
L110:
  xor    %r9d,%r9d
L96:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L194
  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)
L133:
  xor    %eax,%eax
  mov    %edx,%esi
  lea    D49(%rip),%rdi
  mov    %r8,-0x48(%rbp)
  call   <printf@plt>
  mov    (%rbx),%eax
  add    $0x4,%rbx
  mov    -0x48(%rbp),%r8
  sar    $0x18,%eax
  add    %eax,%r12d
  cmp    -0x50(%rbp),%rbx
  je     L36
  mov    $0x1,%r9d
  jmp    L167
  nopl   (%rax)
L36:
  mov    %r12d,%ebx
  mov    $0x1,%r9d
  mov    %r14d,%r12d
  mov    %r15,%r14
  mov    %r8,%r15
  test   %ebx,%ebx
  je     L110
L159:
  cmp    -0x58(%rbp),%ebx
  jne    L37
  mov    %r14,%r8
  xor    %ebx,%ebx
  test   %r13d,%r13d
  jle    L101
  mov    %r12d,-0x48(%rbp)
  mov    %r14,%r12
  mov    %r13d,%r14d
  mov    %r8,%r13
  xchg   %ax,%ax
L137:
  mov    (%r12),%edx
  cmp    %edx,0x0(%r13)
  je     L130
  mov    %ebx,%esi
  lea    D31(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L130:
  add    $0x1,%ebx
  add    $0x4,%r13
  cmp    %ebx,%r14d
  jne    L137
  mov    -0x48(%rbp),%r12d
L101:
  test   %r12d,%r12d
  jle    L71
  mov    %r15,%r14
  xor    %r13d,%r13d
  lea    D2(%rip),%rbx
  nopw   0x0(%rax,%rax,1)
L127:
  mov    (%r15),%edx
  cmp    %edx,(%r14)
  je     L132
  mov    %r13d,%esi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L132:
  add    $0x1,%r13d
  add    $0x4,%r14
  cmp    %r13d,%r12d
  jne    L127
L71:
  mov    -0x54(%rbp),%r15d
  test   %r15d,%r15d
  jle    L96
  mov    -0x60(%rbp),%r14
  xor    %ebx,%ebx
  lea    D11(%rip),%r12
  mov    %r14,%r13
  nopl   (%rax)
L92:
  mov    (%r14),%edx
  cmp    %edx,0x0(%r13)
  je     L72
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
L72:
  add    $0x1,%ebx
  add    $0x4,%r13
  cmp    %ebx,%r15d
  jne    L92
  jmp    L96
  nopl   0x0(%rax)
L37:
  mov    -0x58(%rbp),%edx
  mov    %ebx,%esi
  lea    D20(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%r9d
  jmp    L96
L194:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D49
type_infered: string
name: disassemble_data
arguments: tag: D31
type_infered: string
name: disassemble_data
arguments: tag: D2
type_infered: string
name: disassemble_data
arguments: tag: D11
type_infered: string
name: disassemble_data
arguments: tag: D20
type_infered: string

tool: D49: unexpected cpu %#x used


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


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


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


tool: D20: 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;
}
```