user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rbp
  lea    0x30(%rsp),%r12
  mov    %rbp,%rbx
L95:
  mov    $0x3e800000,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  test   %rax,%rax
  je     L118
  add    $0x8,%rbx
  cmp    %r12,%rbx
  jne    L95
  lea    0xc(%rsp),%r13
  mov    %r13,%rdi
  call   <CPU_ZERO@plt>
  mov    %r13,%rsi
  mov    $0x3,%edi
  call   <CPU_SET@plt>
  xor    %eax,%eax
  call   <getpid@plt>
  mov    %r13,%rdx
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <sched_setaffinity@plt>
  test   %rax,%rax
  jne    L106
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <getpid@plt>
  lea    D8(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  xor    %edi,%edi
  call   <time@plt>
  mov    %eax,%edi
  call   <srand@plt>
  mov    %rbp,%rax
L61:
  mov    (%rax),%rdx
  lea    0x7d000(%rbx),%ecx
L62:
  mov    %ebx,%esi
  add    $0x1,%ebx
  add    $0x800,%rdx
  mov    %esi,-0x800(%rdx)
  cmp    %ecx,%ebx
  jne    L62
  add    $0x8,%rax
  cmp    $0x1f4000,%ebx
  jne    L61
  lea    D0(%rip),%rdi
  call   <puts@plt>
L41:
  mov    %rbp,%r13
L5:
  xor    %edi,%edi
  nopl   0x0(%rax)
L116:
  mov    %rdi,%rax
  add    $0xa00000,%rdi
  mov    %rdi,%rcx
  shr    $0x2,%rax
  shr    $0x2,%rcx
  cmp    %rcx,%rax
  jae    L59
  mov    0x0(%r13),%rsi
  xchg   %ax,%ax
L25:
  mov    %ebx,%edx
  add    $0x1,%ebx
  mov    %edx,(%rsi,%rax,4)
  add    $0x200,%rax
  cmp    %rcx,%rax
  jb     L25
L59:
  cmp    $0x3e800000,%rdi
  jne    L116
  mov    $0x1,%edi
  add    $0x8,%r13
  call   <sleep@plt>
  cmp    %r12,%r13
  jne    L5
  jmp    L41
L106:
  lea    D3(%rip),%rdi
  call   <perror@plt>
L19:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L111
  add    $0x48,%rsp
  or     $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L118:
  lea    D23(%rip),%rdi
  call   <perror@plt>
  jmp    L19
L111:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D8
type: string
name: read_data
arguments: label: D0
type: string
name: read_data
arguments: label: D3
type: string
name: read_data
arguments: label: D23
type: string

tool: D8: mem_bomb: pid %d


tool: D0: memory saturated

tool: D3: error

tool: D23: malloc error


assistant: ```c
int main() {
  size_t size = 1000 * (1024 * 1024);
  int *buf[4];
  int n, count, part;
  int i, j, k;
  int start, end;
  for (i = 0; i < 4; i++) {
    buf[i] = malloc(size);
    if (buf[i] == NULL) {
      perror("malloc error\n");
      return -1;
    }
  }
  int cpuid = 3;
  cpu_set_t cpus;
  CPU_ZERO(&cpus);
  CPU_SET(cpuid, &cpus);
  if (sched_setaffinity(getpid(), sizeof(cpus), &cpus) != 0) {
    perror("error");
    return -1;
  }
  printf("mem_bomb: pid %d\n", getpid());
  count = 0;
  srand(time(NULL));
  n = 0;
  part = 0;
  for (i = 0; i < 4; i++) {
    start = 0;
    end = 1000;
    for (j = start * (1024 * 1024) / sizeof(int); j < end * (1024 * 1024) / sizeof(int); j += 512) {
      buf[i][j] = count++;
    }
  }
  printf("memory saturated\n");
  while (1) {
    for (i = 0; i < 4; i++) {
      int step = 10;
      start = end = 0;
      for (k = 0; k < 1000; k += step) {
        start = k;
        end = start + step;
        for (j = start * (1024 * 1024) / sizeof(int); j < end * (1024 * 1024) / sizeof(int); j += 512) {
          buf[i][j] = count++;
        }
      }
      sleep(1);
    }
  }
  return 0;
}
```