user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<check_resid>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %rdx,-0x30(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %r9,-0x48(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L121
L153:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L110
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jle    L21
L110:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%esi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L21:
  addl   $0x1,-0x18(%rbp)
L121:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L153
  movl   $0x0,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L42
L115:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  sub    %edx,%eax
  add    %eax,-0x10(%rbp)
  addl   $0x1,-0x18(%rbp)
L42:
  mov    -0x18(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L115
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  jmp    L161
L77:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  sub    %edx,%eax
  add    %eax,-0xc(%rbp)
  addl   $0x1,-0x18(%rbp)
L161:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L77
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  je     L49
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L49:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <smalloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L159
L20:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x18(%rbp)
L159:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L20
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  jmp    L17
L102:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x14(%rbp)
  jmp    L1
L166:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jns    L65
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%esi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L65:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x8(%rbp),%rax
  add    %rsi,%rax
  add    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x48(%rbp),%rax
  add    %rsi,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x8(%rbp),%rax
  add    %rsi,%rax
  add    %ecx,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x14(%rbp)
L1:
  mov    -0x18(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x14(%rbp)
  jl     L166
  addl   $0x1,-0x18(%rbp)
L17:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L102
  movl   $0x0,-0x18(%rbp)
  jmp    L27
L105:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  mov    -0x18(%rbp),%ecx
  movslq %ecx,%rcx
  lea    0x0(,%rcx,4),%rsi
  mov    -0x38(%rbp),%rcx
  add    %rsi,%rcx
  mov    (%rcx),%ecx
  sub    %ecx,%edx
  cmp    %edx,%eax
  je     L96
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  mov    %esi,%r8d
  mov    %eax,%esi
  lea    D20(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L96:
  addl   $0x1,-0x18(%rbp)
L27:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L105
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <sfree@plt>
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D0
data_type: string
name: parse_data
arguments: label: D19
data_type: string
name: parse_data
arguments: label: D18
data_type: string
name: parse_data
arguments: label: D20
data_type: string

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


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


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


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