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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  mov    $0x1f4,%esi
  mov    $0x1f4,%edi
  call   <imgalloc@plt>
  mov    %rax,%r12
  mov    $0x1f4,%esi
  mov    $0x1f4,%edi
  call   <imgalloc@plt>
  mov    %rax,(%rsp)
  mov    $0x1f4,%esi
  mov    $0x1f4,%edi
  call   <imgalloc@plt>
  mov    %rax,%r15
  mov    $0x1f4,%esi
  mov    $0x1f4,%edi
  call   <imgalloc@plt>
  mov    %rax,%r13
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r12,%rdi
  call   <imgclear@plt>
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r15,%rdi
  call   <imgclear@plt>
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r13,%rdi
  call   <imgclear@plt>
  mov    $0xfa,%edx
  mov    $0xfa,%esi
  mov    %r12,%rdi
  call   <imgseed@plt>
  mov    $0xa6,%ecx
  mov    $0xfa,%edx
  mov    $0xfa,%esi
  mov    %r15,%rdi
  call   <imgdrawcircle@plt>
  mov    %eax,%ebx
  mov    %eax,0x8(%rsp)
  lea    0x3(%rax),%eax
  test   %ebx,%ebx
  cmovns %ebx,%eax
  sar    $0x2,%eax
  add    %ebx,%eax
  mov    %eax,0xc(%rsp)
  test   %eax,%eax
  jle    L2
  mov    $0x0,%ebp
  mov    $0x1,%ebx
  lea    0x10(%rsp),%r14
L4:
  mov    $0x1f4,%r8d
  mov    $0x1f4,%ecx
  mov    %r12,%rdx
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <imgcompare@plt>
  mov    %eax,%r8d
  mov    0x8(%rsp),%ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  imul   $0x64,%eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  imul   $0x64,%ebx,%eax
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  divsd  %xmm0,%xmm2
  divsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  mov    %ebx,%edx
  mov    %ebp,%esi
  lea    D18(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%edi
  call   <fflush@plt>
  mov    %ebp,%edx
  add    $0x1,%ebp
  lea    D2(%rip),%rsi
  mov    %r14,%rdi
  call   <sprintf@plt>
  mov    $0x1f4,%ecx
  mov    $0x1f4,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <saveppm@plt>
  mov    $0x1f4,%ecx
  mov    $0x1f4,%edx
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <imgcelliter@plt>
  mov    %eax,%ebx
  cmp    0xc(%rsp),%eax
  jle    L4
L2:
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r12,%rdi
  call   <imgfree@plt>
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    (%rsp),%rdi
  call   <imgfree@plt>
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r15,%rdi
  call   <imgfree@plt>
  mov    $0x1f4,%edx
  mov    $0x1f4,%esi
  mov    %r13,%rdi
  call   <imgfree@plt>
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L18
  mov    $0x0,%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L18:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D18
datatype: string
name: parse_data
arguments: tag: D2
datatype: string

tool: D18: img/cell%04d.ppm %d %d %.2f %d %.2f


tool: D2: img/cell%04d.ppm

assistant: ```c
int main() {
  int s = 500;
  int **cells = imgalloc(s, s);
  int **buffer = imgalloc(s, s);
  int **circle = imgalloc(s, s);
  int **compare = imgalloc(s, s);
  imgclear(cells, s, s);
  imgclear(circle, s, s);
  imgclear(compare, s, s);
  imgseed(cells, s / 2, s / 2);
  int circlearea = imgdrawcircle(circle, s / 2, s / 2, s / 3);
  int cellsarea = 1;
  int hits = 0;
  int error;
  char fname[64];
  int i = 0;
  while (cellsarea <= circlearea + circlearea / 4) {
    hits = imgcompare(compare, circle, cells, s, s);
    printf("img/cell%04d.ppm %d %d %.2f %d %.2f\n", i, cellsarea, circlearea, (double)(cellsarea * 100) / circlearea, hits, (double)(hits * 100) / circlearea);
    fflush(NULL);
    sprintf(fname, "img/cell%04d.ppm", i++);
    saveppm(fname, compare, s, s);
    error = circlearea - hits;
    cellsarea = imgcelliter(cells, buffer, s, s);
  }
  imgfree(cells, s, s);
  imgfree(buffer, s, s);
  imgfree(circle, s, s);
  imgfree(compare, s, s);
  return 0;
}
```