user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x100000(%rsp),%r11
L23:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L23
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x100028(%rsp)
  xor    %eax,%eax
  cmp    $0x3,%edi
  jne    L98
  mov    %rsi,%rbx
  lea    0x20(%rsp),%rdi
  mov    $0x100000,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  mov    0x8(%rbx),%rdi
  lea    D154(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L140
L242:
  mov    0x10(%rbx),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L70
  mov    $0x1,%r12d
L35:
  mov    %r12d,%ebp
  lea    -0x1(%r12),%r14d
  movsbl %al,%edx
  mov    %r14d,%esi
  lea    D108(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x10(%rbx),%rax
  movzbl (%rax,%r12,1),%eax
  add    $0x1,%r12
  test   %al,%al
  jne    L35
  mov    %ebp,%esi
  lea    D7(%rip),%rdi
  call   <printf@plt>
  cmp    $0x9,%ebp
  jle    L25
  lea    -0x9(%rbp),%ecx
  mov    0x10(%rbx),%rdx
  mov    $0x0,%eax
L76:
  movzbl (%rdx,%rax,1),%esi
  mov    %sil,0x16(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L76
  sub    $0x9,%ebp
  cmp    $0x8,%r14d
  mov    $0x1,%eax
  cmovle %eax,%ebp
  movslq %ebp,%rbp
  movb   $0x0,0x16(%rsp,%rbp,1)
  mov    $0x0,%eax
  movslq %r14d,%r14
L133:
  mov    0x10(%rbx),%rdx
  lea    (%rdx,%rax,1),%rcx
  movzbl -0x8(%r14,%rcx,1),%ecx
  mov    %cl,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    $0x9,%rax
  jne    L133
  mov    0x10(%rbx),%rax
  movb   $0x0,0x9(%rax)
  lea    0x16(%rsp),%rbp
  mov    %rbp,%rsi
  lea    D36(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x10(%rbx),%rsi
  lea    D88(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <atoll@plt>
  mov    %eax,%r15d
  mov    0x10(%rbx),%rdi
  call   <atoll@plt>
  mov    %eax,%ebx
  mov    %r15d,%esi
  lea    D11(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebx,%esi
  lea    D111(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    0xfffff(%rbx),%ecx
  test   %ebx,%ebx
  cmovns %ebx,%ecx
  sar    $0x14,%ecx
  mov    %ecx,0xc(%rsp)
  mov    %ebx,%eax
  sar    $0x1f,%eax
  shr    $0xc,%eax
  lea    (%rbx,%rax,1),%r8d
  and    $0xfffff,%r8d
  sub    %eax,%r8d
  mov    %r8d,0x8(%rsp)
  mov    %r15d,%edx
  mov    %ebx,%esi
  lea    D109(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  test   %r15d,%r15d
  jle    L28
  lea    0x20(%rsp),%r12
  jmp    L15
L98:
  lea    D157(%rip),%rdi
  call   <puts@plt>
  mov    $0xffffffff,%eax
  jmp    L48
L140:
  mov    0x8(%rbx),%rsi
  lea    D32(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L242
L12:
  sub    $0x1,%r14d
  je     L178
L251:
  mov    $0x100000,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    %r12,%rbx
  lea    0x100020(%rsp),%rbp
L143:
  mov    $0x0,%eax
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,(%rbx)
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L143
  mov    $0x0,%ebx
  mov    $0x100000,%ebp
L54:
  mov    %ebp,%edx
  sub    %ebx,%edx
  movslq %ebx,%rdi
  add    %r12,%rdi
  mov    %r13,%rcx
  mov    $0x1,%esi
  call   <fwrite@plt>
  add    %eax,%ebx
  cmp    $0xfffff,%ebx
  jle    L54
  jmp    L12
L178:
  sub    $0x1,%r15d
  je     L28
L15:
  mov    $0x400,%r14d
  jmp    L251
L52:
  add    $0x1,%r14d
  cmp    0xc(%rsp),%r14d
  je     L193
L213:
  mov    $0x100000,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    %r12,%rbx
  lea    0x100020(%rsp),%rbp
L141:
  mov    $0x0,%eax
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,(%rbx)
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L141
  mov    $0x0,%ebx
  mov    $0x100000,%ebp
L30:
  mov    %ebp,%edx
  sub    %ebx,%edx
  movslq %ebx,%rdi
  add    %r12,%rdi
  mov    %r13,%rcx
  mov    $0x1,%esi
  call   <fwrite@plt>
  add    %eax,%ebx
  cmp    $0xfffff,%ebx
  jle    L30
  jmp    L52
L193:
  lea    0x20(%rsp),%rdi
  mov    $0x100000,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jle    L38
  lea    0x20(%rsp),%rbx
  lea    -0x1(%rax),%eax
  lea    0x21(%rsp,%rax,1),%rbp
L235:
  mov    $0x0,%eax
  call   <random@plt>
  cltd
  shr    $0x18,%edx
  add    %edx,%eax
  movzbl %al,%eax
  sub    %edx,%eax
  mov    %al,(%rbx)
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L235
  mov    $0x0,%ebx
  lea    0x20(%rsp),%rbp
L111:
  mov    0x8(%rsp),%r15d
  mov    %r15d,%edx
  sub    %ebx,%edx
  movslq %ebx,%rdi
  add    %rbp,%rdi
  mov    %r13,%rcx
  mov    $0x1,%esi
  call   <fwrite@plt>
  add    %eax,%ebx
  cmp    %r15d,%ebx
  jl     L111
L38:
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L48:
  mov    0x100028(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L224
  add    $0x100038,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L70:
  mov    $0x0,%esi
  lea    D7(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L25:
  lea    0x16(%rsp),%rbp
  mov    %rbp,%rsi
  lea    D36(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x10(%rbx),%rsi
  lea    D88(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <atoll@plt>
  mov    %eax,%ebp
  mov    0x10(%rbx),%rdi
  call   <atoll@plt>
  mov    %eax,%ebx
  mov    %ebp,%esi
  lea    D11(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebx,%esi
  lea    D111(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x100000,%ecx
  mov    %ebx,%eax
  cltd
  idiv   %ecx
  mov    %edx,%r8d
  mov    %eax,%ecx
  mov    %eax,0xc(%rsp)
  mov    %edx,0x8(%rsp)
  mov    %ebp,%edx
  mov    %ebx,%esi
  lea    D109(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L28:
  cmpl   $0x0,0xc(%rsp)
  jle    L193
  mov    $0x0,%r14d
  lea    0x20(%rsp),%r12
  jmp    L213
L224:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D154
type_guessed: string
name: read_data
arguments: label: D108
type_guessed: string
name: read_data
arguments: label: D7
type_guessed: string
name: read_data
arguments: label: D36
type_guessed: string
name: read_data
arguments: label: D88
type_guessed: string
name: read_data
arguments: label: D11
type_guessed: string
name: read_data
arguments: label: D111
type_guessed: string
name: read_data
arguments: label: D109
type_guessed: string
name: read_data
arguments: label: D157
type_guessed: string
name: read_data
arguments: label: D32
type_guessed: string

tool: D154: wb

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


tool: D7: ii %d


tool: D36: g %s


tool: D88: argv[2] %s


tool: D11: gg %llu


tool: D111: tsize %llu


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


tool: D157: usage: ./pd filename filesize

tool: D32: open %s failed


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;
}
```