user: What is the c source code of the assembly code below:

```asm
<check_resid>:
  endbr64
  push   %r15
  lea    (%rdi,%rsi,1),%eax
  push   %r14
  mov    %r9,%r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  push   %rbp
  movslq %eax,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdx,0x10(%rsp)
  mov    0x70(%rsp),%r12
  mov    %rcx,0x18(%rsp)
  mov    %r8,0x8(%rsp)
  mov    %eax,0x20(%rsp)
  test   %eax,%eax
  jle    L33
  xor    %r15d,%r15d
  mov    %edi,0x24(%rsp)
  mov    0x10(%rsp),%r13
  lea    D9(%rip),%rbx
  mov    %r12,0x28(%rsp)
  mov    %r15,%r12
  mov    0x18(%rsp),%r15
  nopw   0x0(%rax,%rax,1)
L263:
  mov    (%r15,%r12,4),%edx
  mov    0x0(%r13,%r12,4),%ecx
  mov    %r12d,%esi
  test   %edx,%edx
  js     L9
  cmp    %ecx,%edx
  jle    L162
L9:
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L162:
  add    $0x1,%r12
  cmp    %r12,%rbp
  jne    L263
  mov    0x24(%rsp),%r13d
  mov    0x28(%rsp),%r12
L33:
  movslq %r13d,%rbx
  xor    %eax,%eax
  xor    %esi,%esi
  test   %r13d,%r13d
  jle    L167
  mov    0x10(%rsp),%rdx
  mov    0x18(%rsp),%rcx
  nopl   0x0(%rax,%rax,1)
L177:
  add    (%rdx,%rax,4),%esi
  sub    (%rcx,%rax,4),%esi
  add    $0x1,%rax
  cmp    %rax,%rbx
  jne    L177
  cmp    0x20(%rsp),%r13d
  jge    L18
L269:
  mov    0x20(%rsp),%ecx
  mov    0x10(%rsp),%rdi
  mov    %rbx,%rax
  xor    %edx,%edx
  mov    0x18(%rsp),%r8
  nopl   (%rax)
L140:
  add    (%rdi,%rax,4),%edx
  sub    (%r8,%rax,4),%edx
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L140
L218:
  cmp    %edx,%esi
  jne    L73
L163:
  mov    0x20(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <smalloc@plt>
  mov    0x20(%rsp),%edx
  mov    %rax,%r15
  test   %edx,%edx
  jle    L220
  xor    %esi,%esi
  lea    0x0(,%rbp,4),%rdx
  mov    %rax,%rdi
  call   <memset@plt>
  cmp    0x20(%rsp),%r13d
  jge    L101
L183:
  mov    0x8(%rsp),%r8
  shl    $0x2,%rbx
  mov    %r14,%rax
  lea    (%r15,%rbx,1),%rbp
  add    %rbx,%r8
  mov    %r8,%r14
  mov    %rax,%r8
  nopl   0x0(%rax)
L138:
  movslq (%r14),%rbx
  cmp    0x4(%r14),%ebx
  jge    L217
  mov    %r13d,%esi
  mov    %r8,%r13
  jmp    L141
  nopl   0x0(%rax)
L60:
  add    %ecx,0x0(%rbp)
  movslq 0x0(%r13,%rbx,4),%rax
  mov    (%r12,%rbx,4),%edx
  add    $0x1,%rbx
  add    %edx,(%r15,%rax,4)
  cmp    %ebx,0x4(%r14)
  jle    L142
L141:
  mov    (%r12,%rbx,4),%ecx
  test   %ecx,%ecx
  jns    L60
  mov    0x0(%r13,%rbx,4),%edx
  lea    D34(%rip),%rdi
  xor    %eax,%eax
  mov    %esi,0x8(%rsp)
  call   <printf@plt>
  mov    (%r12,%rbx,4),%ecx
  mov    0x8(%rsp),%esi
  jmp    L60
  nopl   0x0(%rax,%rax,1)
L142:
  mov    %r13,%r8
  mov    %esi,%r13d
L217:
  add    $0x1,%r13d
  add    $0x4,%r14
  add    $0x4,%rbp
  cmp    0x20(%rsp),%r13d
  jl     L138
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  jle    L106
L101:
  mov    0x20(%rsp),%r12d
  mov    0x10(%rsp),%r13
  xor    %ebx,%ebx
  lea    D18(%rip),%rbp
  mov    0x18(%rsp),%r14
  nopl   0x0(%rax)
L2:
  mov    0x0(%r13,%rbx,4),%ecx
  mov    (%r14,%rbx,4),%r8d
  mov    %ebx,%esi
  mov    (%r15,%rbx,4),%edx
  mov    %ecx,%eax
  sub    %r8d,%eax
  cmp    %eax,%edx
  je     L247
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L247:
  add    $0x1,%rbx
  cmp    %ebx,%r12d
  jg     L2
L106:
  add    $0x38,%rsp
  mov    %r15,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1090 <sfree@plt>
L73:
  lea    D20(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L163
L167:
  cmp    0x20(%rsp),%r13d
  jl     L269
  mov    0x20(%rsp),%ebx
  lea    0x0(,%rbx,4),%edi
  call   <smalloc@plt>
  mov    %rax,%r15
  test   %ebx,%ebx
  jle    L220
  lea    0x0(,%rbp,4),%rdx
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <memset@plt>
  jmp    L101
  nopl   (%rax)
L220:
  movslq %r13d,%rbx
  cmp    0x20(%rsp),%r13d
  jl     L183
  jmp    L106
L18:
  xor    %edx,%edx
  jmp    L218
```

tool_calls: name: unpack_data
arguments: data_tag: D9
datatype: string
name: unpack_data
arguments: data_tag: D34
datatype: string
name: unpack_data
arguments: data_tag: D18
datatype: string
name: unpack_data
arguments: data_tag: D20
datatype: string

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


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


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


tool: D20: left_used = %d, NOT EQUAL TO right_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);
}
```