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

```asm
<check_resid>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,0x10(%rsp)
  mov    %rdx,0x18(%rsp)
  mov    %rcx,0x20(%rsp)
  mov    %r8,%r15
  mov    %r9,%r14
  mov    0x70(%rsp),%rbp
  add    %edi,%esi
  mov    %esi,0x14(%rsp)
  test   %esi,%esi
  jle    L14
  mov    %esi,%r12d
  mov    $0x0,%ebx
  lea    D8(%rip),%r13
  mov    %r8,0x8(%rsp)
  mov    %rcx,%r15
  mov    %r9,0x28(%rsp)
  mov    %rdx,%r14
  jmp    L0
L254:
  mov    (%r14,%rbx,4),%ecx
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L163:
  add    $0x1,%rbx
  cmp    %r12,%rbx
  je     L95
L0:
  mov    %ebx,%esi
  mov    (%r15,%rbx,4),%edx
  test   %edx,%edx
  js     L254
  cmp    (%r14,%rbx,4),%edx
  jle    L163
  jmp    L254
L95:
  mov    0x8(%rsp),%r15
  mov    0x28(%rsp),%r14
L14:
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L256
  mov    %eax,%edx
  mov    $0x0,%eax
  mov    $0x0,%esi
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%rdi
L289:
  add    (%rcx,%rax,4),%esi
  sub    (%rdi,%rax,4),%esi
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L289
  mov    0x14(%rsp),%edi
  cmp    %edi,0x10(%rsp)
  jge    L253
L224:
  movslq 0x10(%rsp),%rax
  mov    $0x0,%edx
  mov    0x14(%rsp),%ecx
  mov    0x18(%rsp),%rdi
  mov    0x20(%rsp),%r8
L5:
  add    (%rdi,%rax,4),%edx
  sub    (%r8,%rax,4),%edx
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L5
L179:
  cmp    %edx,%esi
  jne    L121
L24:
  mov    0x14(%rsp),%ebx
  lea    0x0(,%rbx,4),%edi
  call   <smalloc@plt>
  mov    %rax,%r13
  test   %ebx,%ebx
  jle    L177
L147:
  mov    %r13,%rax
  mov    0x14(%rsp),%edx
  lea    0x0(%r13,%rdx,4),%rdx
L21:
  movl   $0x0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L21
  mov    0x14(%rsp),%edi
  cmp    %edi,0x10(%rsp)
  jge    L75
L102:
  movslq 0x10(%rsp),%r12
  shl    $0x2,%r12
  lea    (%r15,%r12,1),%rax
  mov    %rax,0x8(%rsp)
  add    %r13,%r12
  jmp    L138
L253:
  mov    $0x0,%edx
  jmp    L179
L121:
  lea    D29(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L24
L180:
  mov    0x0(%rbp,%rbx,4),%eax
  add    %eax,(%r12)
  movslq (%r14,%rbx,4),%rax
  mov    0x0(%rbp,%rbx,4),%edx
  add    %edx,0x0(%r13,%rax,4)
  add    $0x1,%rbx
  cmp    %ebx,0x4(%r15)
  jle    L120
L91:
  mov    0x0(%rbp,%rbx,4),%ecx
  test   %ecx,%ecx
  jns    L180
  mov    (%r14,%rbx,4),%edx
  mov    0x10(%rsp),%esi
  lea    D7(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L180
L120:
  addl   $0x1,0x10(%rsp)
  mov    0x10(%rsp),%eax
  addq   $0x4,0x8(%rsp)
  add    $0x4,%r12
  cmp    0x14(%rsp),%eax
  jge    L199
L138:
  mov    0x8(%rsp),%rax
  mov    %rax,%r15
  mov    (%rax),%ebx
  cmp    0x4(%rax),%ebx
  jge    L120
  movslq %ebx,%rbx
  jmp    L91
L199:
  cmpl   $0x0,0x14(%rsp)
  jle    L150
L75:
  mov    $0x0,%ebx
  lea    D10(%rip),%rbp
  mov    0x14(%rsp),%r12d
  mov    0x18(%rsp),%r14
  mov    0x20(%rsp),%r15
  jmp    L187
L22:
  add    $0x1,%rbx
  cmp    %ebx,%r12d
  jle    L150
L187:
  mov    %ebx,%esi
  mov    0x0(%r13,%rbx,4),%edx
  mov    (%r14,%rbx,4),%ecx
  mov    (%r15,%rbx,4),%r8d
  mov    %ecx,%eax
  sub    %r8d,%eax
  cmp    %eax,%edx
  je     L22
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L22
L177:
  mov    0x14(%rsp),%edi
  cmp    %edi,0x10(%rsp)
  jl     L102
L150:
  mov    %r13,%rdi
  call   <sfree@plt>
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L256:
  mov    $0x0,%esi
  mov    0x14(%rsp),%edi
  cmp    %edi,0x10(%rsp)
  jl     L224
  mov    %edi,%ebx
  lea    0x0(,%rdi,4),%edi
  call   <smalloc@plt>
  mov    %rax,%r13
  test   %ebx,%ebx
  jg     L147
  jmp    L150
```

tool_calls: name: read_data
arguments: data_label: D8
type_guessed: string
name: read_data
arguments: data_label: D29
type_guessed: string
name: read_data
arguments: data_label: D7
type_guessed: string
name: read_data
arguments: data_label: D10
type_guessed: string

tool: D8: BAD resid[%d] = %d, vweight = %d


tool: D29: left_used = %d, NOT EQUAL TO right_resid = %d


tool: D7: Negative flow (%d,%d) = %d


tool: D10: ERROR: diff[%d] = %d, but vweight = %d and resid = %d


assistant: ```c
void check_resid(int n_left, int n_right, int *vweight, int *resid, int *pointers, int *indices, int *flow) {
  int i, j, left_used, right_used;
  int *diff;
  for (i = 0; i < n_left + n_right; i++) {
    if (resid[i] < 0 || resid[i] > vweight[i]) {
      printf("BAD resid[%d] = %d, vweight = %d\n", i, resid[i], vweight[i]);
    }
  }
  left_used = right_used = 0;
  for (i = 0; i < n_left; i++) {
    left_used += vweight[i] - resid[i];
  }
  for (i = n_left; i < n_left + n_right; i++) {
    right_used += vweight[i] - resid[i];
  }
  if (left_used != right_used) {
    printf("left_used = %d, NOT EQUAL TO right_resid = %d\n", left_used, right_used);
  }
  diff = smalloc((n_left + n_right) * sizeof(int));
  for (i = 0; i < n_left + n_right; i++) {
    diff[i] = 0;
  }
  for (i = n_left; i < n_left + n_right; i++) {
    for (j = pointers[i]; j < pointers[i + 1]; j++) {
      if (flow[j] < 0) {
        printf("Negative flow (%d,%d) = %d\n", i, indices[j], flow[j]);
      }
      diff[i] += flow[j];
      diff[indices[j]] += flow[j];
    }
  }
  for (i = 0; i < n_left + n_right; i++) {
    if (diff[i] != vweight[i] - resid[i]) {
      printf("ERROR: diff[%d] = %d, but vweight = %d and resid = %d\n", i, diff[i], vweight[i], resid[i]);
    }
  }
  sfree(diff);
}
```