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
  lea    -0x100000(%rsp),%r11
L330:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L330
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x100028(%rsp)
  xor    %eax,%eax
  cmp    $0x3,%edi
  jne    L136
  lea    0x20(%rsp),%rbp
  mov    %rsi,%rbx
  mov    $0x100000,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    0x8(%rbx),%rdi
  lea    D52(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L207
L302:
  mov    0x10(%rbx),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L386
  mov    $0x1,%r15d
  lea    D61(%rip),%rcx
L158:
  lea    -0x1(%r15),%r14d
  movsbl %al,%edx
  mov    %rcx,%rdi
  xor    %eax,%eax
  mov    %r14d,%esi
  mov    %r15d,%r12d
  call   <printf@plt>
  mov    0x10(%rbx),%rax
  lea    D61(%rip),%rcx
  movzbl (%rax,%r15,1),%eax
  add    $0x1,%r15
  test   %al,%al
  jne    L158
  mov    %r12d,%esi
  lea    D108(%rip),%rdi
  call   <printf@plt>
  cmp    $0x9,%r12d
  jle    L355
  mov    0x10(%rbx),%rax
  lea    0x10(%rsp),%r15
  lea    -0x9(%r12),%edx
  mov    %r15,%rcx
  lea    0x1(%rax),%rsi
  sub    %rsi,%rcx
  cmp    $0x6,%rcx
  jbe    L193
  cmp    $0xf,%r14d
  jle    L193
  cmp    $0x8,%r14d
  mov    $0x1,%esi
  mov    (%rax),%rcx
  cmovg  %edx,%esi
  mov    %rcx,0x10(%rsp)
  mov    %esi,%ecx
  and    $0xfffffff8,%ecx
  and    $0x7,%esi
  je     L81
  mov    %ecx,%esi
  movzbl (%rax,%rsi,1),%edi
  movslq %ecx,%rsi
  mov    %dil,0x10(%rsp,%rsi,1)
  lea    0x1(%rcx),%esi
  cmp    %esi,%edx
  jle    L81
  movslq %esi,%rsi
  add    $0x2,%ecx
  movzbl (%rax,%rsi,1),%edi
  mov    %dil,0x10(%rsp,%rsi,1)
  cmp    %ecx,%edx
  jle    L81
  movzbl 0xa(%rax),%esi
  movslq %ecx,%rcx
  mov    %sil,0x10(%rsp,%rcx,1)
  cmp    $0xb,%edx
  je     L81
  movzbl 0xb(%rax),%ecx
  mov    %cl,0x1b(%rsp)
  cmp    $0xc,%edx
  je     L81
  movzbl 0xc(%rax),%ecx
  mov    %cl,0x1c(%rsp)
  cmp    $0xd,%edx
  je     L81
  movzbl 0xd(%rax),%ecx
  mov    %cl,0x1d(%rsp)
  cmp    $0xe,%edx
  je     L81
  movzbl 0xe(%rax),%ecx
  mov    %cl,0x1e(%rsp)
L81:
  cmp    $0x8,%r14d
  mov    $0x1,%ecx
  movslq %r14d,%r14
  mov    %r15,%rsi
  cmovg  %edx,%ecx
  movslq %edx,%rdx
  lea    D100(%rip),%rdi
  movslq %ecx,%rcx
  movb   $0x0,0x10(%rsp,%rcx,1)
  movzbl (%rax,%rdx,1),%edx
  mov    %dl,(%rax)
  lea    -0x8(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x1(%rdx)
  lea    -0x7(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x2(%rdx)
  lea    -0x6(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x3(%rdx)
  lea    -0x5(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x4(%rdx)
  lea    -0x4(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x5(%rdx)
  lea    -0x3(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x6(%rdx)
  lea    -0x2(%r12),%eax
  mov    0x10(%rbx),%rdx
  cltq
  movzbl (%rdx,%rax,1),%eax
  mov    %al,0x7(%rdx)
  mov    0x10(%rbx),%rax
  movzbl (%rax,%r14,1),%edx
  mov    %dl,0x8(%rax)
  mov    0x10(%rbx),%rax
  movb   $0x0,0x9(%rax)
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x10(%rbx),%rsi
  lea    D85(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r15,%rdi
  call   <atoll@plt>
  mov    0x10(%rbx),%rdi
  mov    %eax,%r14d
  mov    %eax,0xc(%rsp)
  call   <atoll@plt>
  mov    %r14d,%esi
  lea    D27(%rip),%rdi
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12d,%esi
  lea    D36(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  test   %r12d,%r12d
  mov    %r14d,%edx
  mov    %r12d,%esi
  lea    0xfffff(%r12),%eax
  lea    D97(%rip),%rdi
  cmovns %r12d,%eax
  sar    $0x14,%eax
  mov    %eax,0x8(%rsp)
  mov    %eax,%ecx
  mov    %r12d,%eax
  sar    $0x1f,%eax
  shr    $0xc,%eax
  lea    (%r12,%rax,1),%r15d
  and    $0xfffff,%r15d
  sub    %eax,%r15d
  xor    %eax,%eax
  mov    %r15d,%r8d
  mov    %r15d,0x4(%rsp)
  call   <printf@plt>
  test   %r14d,%r14d
  jle    L221
  lea    0x100020(%rsp),%rbx
L168:
  mov    $0x400,%r14d
L202:
  mov    $0x100000,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %rbp,%r12
  call   <memset@plt>
  cs nopw 0x0(%rax,%rax,1)
L400:
  xor    %eax,%eax
  add    $0x1,%r12
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,-0x1(%r12)
  cmp    %rbx,%r12
  jne    L400
  xor    %r15d,%r15d
  mov    $0x100000,%r12d
  nopl   0x0(%rax)
L208:
  movslq %r15d,%rdi
  mov    %r12d,%edx
  mov    %r13,%rcx
  mov    $0x1,%esi
  sub    %r15d,%edx
  add    %rbp,%rdi
  call   <fwrite@plt>
  add    %eax,%r15d
  cmp    $0xfffff,%r15d
  jle    L208
  sub    $0x1,%r14d
  jne    L202
  subl   $0x1,0xc(%rsp)
  jne    L168
L221:
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jle    L119
  xor    %r12d,%r12d
  lea    0x100020(%rsp),%rbx
L67:
  mov    $0x100000,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %rbp,%r14
  call   <memset@plt>
L110:
  xor    %eax,%eax
  add    $0x1,%r14
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,-0x1(%r14)
  cmp    %rbx,%r14
  jne    L110
  xor    %r14d,%r14d
  mov    $0x100000,%r15d
L175:
  movslq %r14d,%rdi
  mov    %r15d,%edx
  mov    %r13,%rcx
  mov    $0x1,%esi
  sub    %r14d,%edx
  add    %rbp,%rdi
  call   <fwrite@plt>
  add    %eax,%r14d
  cmp    $0xfffff,%r14d
  jle    L175
  add    $0x1,%r12d
  cmp    0x8(%rsp),%r12d
  jne    L67
L119:
  mov    $0x100000,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  jle    L45
  sub    $0x1,%eax
  mov    %rbp,%r12
  lea    0x21(%rsp,%rax,1),%rbx
L301:
  xor    %eax,%eax
  add    $0x1,%r12
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,-0x1(%r12)
  cmp    %rbx,%r12
  jne    L301
  xor    %ebx,%ebx
L396:
  mov    0x4(%rsp),%r14d
  movslq %ebx,%rdi
  mov    %r13,%rcx
  mov    $0x1,%esi
  add    %rbp,%rdi
  mov    %r14d,%edx
  sub    %ebx,%edx
  call   <fwrite@plt>
  add    %eax,%ebx
  cmp    %r14d,%ebx
  jl     L396
L45:
  mov    %r13,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L82:
  mov    0x100028(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L279
  add    $0x100038,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L207:
  mov    0x8(%rbx),%rsi
  lea    D43(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L302
L386:
  xor    %esi,%esi
  lea    D108(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
L355:
  lea    0x10(%rsp),%r12
  lea    D100(%rip),%rdi
  xor    %eax,%eax
  mov    %r12,%rsi
  call   <printf@plt>
  mov    0x10(%rbx),%rsi
  lea    D85(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12,%rdi
  call   <atoll@plt>
  mov    0x10(%rbx),%rdi
  mov    %eax,%r14d
  call   <atoll@plt>
  mov    %r14d,%esi
  lea    D27(%rip),%rdi
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12d,%esi
  lea    D36(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12d,%eax
  mov    $0x100000,%esi
  lea    D97(%rip),%rdi
  cltd
  idiv   %esi
  mov    %r12d,%esi
  mov    %edx,0x4(%rsp)
  mov    %edx,%r8d
  mov    %eax,%ecx
  mov    %r14d,%edx
  mov    %eax,0x8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L221
L193:
  movzbl (%rax),%ecx
  mov    %cl,0x10(%rsp)
  cmp    $0x1,%edx
  je     L81
  movzbl 0x1(%rax),%ecx
  mov    %cl,0x11(%rsp)
  cmp    $0x2,%edx
  je     L81
  movzbl 0x2(%rax),%ecx
  mov    %cl,0x12(%rsp)
  cmp    $0x3,%edx
  je     L81
  movzbl 0x3(%rax),%ecx
  mov    %cl,0x13(%rsp)
  cmp    $0x4,%edx
  je     L81
  movzbl 0x4(%rax),%ecx
  mov    %cl,0x14(%rsp)
  cmp    $0x5,%edx
  je     L81
  movzbl 0x5(%rax),%ecx
  mov    %cl,0x15(%rsp)
  cmp    $0x6,%edx
  je     L81
  movzbl 0x6(%rax),%ecx
  mov    %cl,0x16(%rsp)
  cmp    $0x7,%edx
  je     L81
  movzbl 0x7(%rax),%ecx
  mov    %cl,0x17(%rsp)
  cmp    $0x8,%edx
  je     L81
  movzbl 0x8(%rax),%ecx
  mov    %cl,0x18(%rsp)
  cmp    $0x9,%edx
  je     L81
  movzbl 0x9(%rax),%ecx
  mov    %cl,0x19(%rsp)
  jmp    L81
L136:
  lea    D150(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%eax
  jmp    L82
L279:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D52
type: string
name: extract_symbolic_data
arguments: label: D61
type: string
name: extract_symbolic_data
arguments: label: D108
type: string
name: extract_symbolic_data
arguments: label: D100
type: string
name: extract_symbolic_data
arguments: label: D85
type: string
name: extract_symbolic_data
arguments: label: D27
type: string
name: extract_symbolic_data
arguments: label: D36
type: string
name: extract_symbolic_data
arguments: label: D97
type: string
name: extract_symbolic_data
arguments: label: D43
type: string
name: extract_symbolic_data
arguments: label: D150
type: string

tool: D52: wb

tool: D61: argv[2][%d] = %c


tool: D108: ii %d


tool: D100: g %s


tool: D85: argv[2] %s


tool: D27: gg %llu


tool: D36: tsize %llu


tool: D97: tsize %llu  %llu gb %llu mb rsize %llu


tool: D43: open %s failed


tool: D150: usage: ./pd filename filesize

assistant: ```c
int main(int argc, char **argv) {
  char buf[1024 * 1024];
  FILE *fd;
  int64_t count = 0;
  int64_t tsize = 0;
  int64_t rsize = 0;
  int64_t i = 0, j = 0;
  int64_t wsize = 0;
  int64_t k = 0;
  int64_t t1 = 0;
  int64_t t2 = 0;
  int flag = 0;
  char g[10];
  int64_t gg = 0;
  int64_t n = 0;
  if (argc != 3) {
    printf("usage: ./pd filename filesize\n");
    return -1;
  }
  memset(buf, 0, 1024 * 1024);
  fd = fopen(argv[1], "wb");
  if (fd == NULL) {
    printf("open %s failed\n", argv[1]);
  }
  int ii = 0;
  for (; argv[2][ii] != 0; ii++) {
    printf("argv[2][%d] = %c\n", ii, argv[2][ii]);
  }
  printf("ii %d\n", ii);
  if (ii >= 10) {
    flag = 1;
    ii -= 9;
    for (n = 0; n < ii; n++) {
      g[n] = argv[2][n];
    }
    g[n] = 0;
    for (n = 0; n < 9; n++) {
      argv[2][n] = argv[2][n + ii];
    }
    argv[2][n] = 0;
  }
  printf("g %s\n", g);
  printf("argv[2] %s\n", argv[2]);
  gg = atoll(g);
  tsize = atoll(argv[2]);
  printf("gg %llu\n", gg);
  printf("tsize %llu\n", tsize);
  count = tsize / (1024 * 1024);
  rsize = tsize - count * 1024 * 1024;
  printf("tsize %llu  %llu gb %llu mb rsize %llu\n", tsize, gg, count, rsize);
  for (; gg > 0 && flag; gg--) {
    for (i = 0; i < 1024; i++) {
      memset(buf, 0, 1024 * 1024);
      for (j = 0; j < 1024 * 1024; j++) {
        buf[j] = (random() % 256);
      }
      k = 0;
      wsize = 0;
      while (wsize < 1024 * 1024) {
        k = fwrite(buf + wsize, 1, 1024 * 1024 - wsize, fd);
        wsize += k;
      }
    }
  }
  for (i = 0; i < count; i++) {
    memset(buf, 0, 1024 * 1024);
    for (j = 0; j < 1024 * 1024; j++) {
      buf[j] = (random() % 256);
    }
    k = 0;
    wsize = 0;
    while (wsize < 1024 * 1024) {
      k = fwrite(buf + wsize, 1, 1024 * 1024 - wsize, fd);
      wsize += k;
    }
  }
  memset(buf, 0, 1024 * 1024);
  for (j = 0; j < rsize; j++) {
    buf[j] = (random() % 256);
  }
  k = 0;
  wsize = 0;
  while (wsize < rsize) {
    k = fwrite(buf + wsize, 1, rsize - wsize, fd);
    wsize += k;
  }
  fclose(fd);
  return 0;
}
```