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

```asm
<io_mon>:
  endbr64
  push   %r14
  lea    D116(%rip),%rsi
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  lea    D67(%rip),%rdi
  push   %rbx
  sub    $0xc0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L19
L131:
  lea    0x48(%rsp),%rax
  mov    %rsp,%r12
  lea    0x8(%rsp),%rcx
  mov    %r13,%rdi
  push   %rax
  lea    D26(%rip),%r14
  mov    %r12,%rdx
  mov    %r14,%rsi
  lea    0x48(%rsp),%rax
  push   %rax
  lea    0x48(%rsp),%rax
  push   %rax
  lea    0x48(%rsp),%rax
  push   %rax
  lea    0x48(%rsp),%rax
  push   %rax
  lea    0x48(%rsp),%rax
  push   %rax
  lea    0x48(%rsp),%r9
  lea    0x40(%rsp),%r8
  call   <fscanf@plt>
  mov    %r12,%rsp
  cmp    $0xa,%eax
  jne    L74
L90:
  mov    $0xee6b280,%esi
  xor    %edi,%edi
  lea    0x50(%rsp),%rbx
  call   <timeout@plt>
  mov    %r13,%rdi
  call   <rewind@plt>
  lea    0x58(%rsp),%rcx
  mov    %rbx,%rdx
  mov    %r14,%rsi
  lea    0x98(%rsp),%rax
  mov    %r13,%rdi
  push   %rax
  lea    0x98(%rsp),%rax
  push   %rax
  lea    0x98(%rsp),%rax
  push   %rax
  lea    0x98(%rsp),%rax
  push   %rax
  lea    0x98(%rsp),%rax
  push   %rax
  lea    0x98(%rsp),%rax
  push   %rax
  lea    0x98(%rsp),%r9
  lea    0x90(%rsp),%r8
  call   <fscanf@plt>
  add    $0x30,%rsp
  cmp    $0xa,%eax
  jne    L86
L157:
  mov    %r13,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  jne    L150
L48:
  xor    %eax,%eax
  xor    %edi,%edi
  xor    %esi,%esi
  nopl   (%rax)
L6:
  mov    (%r12,%rax,1),%rcx
  mov    (%rbx,%rax,1),%rdx
  add    $0x8,%rax
  add    %rsi,%rcx
  add    %rdi,%rdx
  mov    %rcx,%rsi
  mov    %rdx,%rdi
  cmp    $0x50,%rax
  jne    L6
  mov    0x70(%rsp),%rax
  sub    0x20(%rsp),%rax
  js     L73
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L177:
  sub    %rcx,%rdx
  js     L178
  pxor   %xmm1,%xmm1
  cvtsi2sd %rdx,%xmm1
L7:
  divsd  %xmm1,%xmm0
  lea    0xa0(%rsp),%r12
  mov    $0x14,%esi
  lea    D21(%rip),%rdx
  mov    %r12,%rdi
  mulsd  D20(%rip),%xmm0
  call   <snprintf@plt>
  test   %eax,%eax
  js     L136
L172:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <multithread_write@plt>
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L79
  add    $0xc0,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L74:
  mov    %r13,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  je     L15
  lea    D5(%rip),%rdi
  call   <die@plt>
  jmp    L90
  nopw   0x0(%rax,%rax,1)
L86:
  mov    %r13,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  je     L8
  lea    D1(%rip),%rdi
  call   <die@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  je     L48
L150:
  lea    D92(%rip),%rdi
  call   <die@plt>
  jmp    L48
  nop
L178:
  mov    %rdx,%rax
  and    $0x1,%edx
  pxor   %xmm1,%xmm1
  shr    %rax
  or     %rdx,%rax
  cvtsi2sd %rax,%xmm1
  addsd  %xmm1,%xmm1
  jmp    L7
  xchg   %ax,%ax
L73:
  mov    %rax,%rsi
  and    $0x1,%eax
  pxor   %xmm0,%xmm0
  shr    %rsi
  or     %rax,%rsi
  cvtsi2sd %rsi,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L177
  xchg   %ax,%ax
L136:
  lea    D64(%rip),%rdi
  call   <die_sans_errno@plt>
  jmp    L172
  nopl   0x0(%rax)
L15:
  lea    D79(%rip),%rdi
  call   <die_sans_errno@plt>
  jmp    L90
  nopl   0x0(%rax)
L8:
  lea    D36(%rip),%rdi
  call   <die_sans_errno@plt>
  jmp    L157
  nopl   0x0(%rax)
L19:
  lea    D98(%rip),%rdi
  call   <die@plt>
  jmp    L131
L79:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D116
type_infered: string
name: unpack_data
arguments: label: D67
type_infered: string
name: unpack_data
arguments: label: D26
type_infered: string
name: unpack_data
arguments: label: D21
type_infered: string
name: unpack_data
arguments: label: D20
type_infered: f64
name: unpack_data
arguments: label: D5
type_infered: string
name: unpack_data
arguments: label: D1
type_infered: string
name: unpack_data
arguments: label: D92
type_infered: string
name: unpack_data
arguments: label: D64
type_infered: string
name: unpack_data
arguments: label: D79
type_infered: string
name: unpack_data
arguments: label: D36
type_infered: string
name: unpack_data
arguments: label: D98
type_infered: string

tool: D116: r

tool: D67: /proc/stat

tool: D26: cpu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu

tool: D21: io:%3.0f%%

tool: D20: 100

tool: D5: first fscanf on /proc/stat in io_mon failed

tool: D1: second fscanf on /proc/stat in io_mon failed

tool: D92: couldn't close /proc/stat in io_mon

tool: D64: snprintf in io_mon failed

tool: D79: matching error for first fscanf on /proc/stat in io_mon

tool: D36: matching error for second fscanf on /proc/stat in io_mon

tool: D98: couldn't open /proc/stat in io_mon

assistant: ```c
void *io_mon(void *thread_id) {
  FILE *procstat = fopen("/proc/stat", "r");
  if (procstat == NULL) {
    die("couldn't open /proc/stat in io_mon");
  }
  unsigned long int start_stats[10];
  int values_read = fscanf(procstat, "cpu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", start_stats + 0, start_stats + 1, start_stats + 2, start_stats + 3, start_stats + 4, start_stats + 5, start_stats + 6, start_stats + 7, start_stats + 8, start_stats + 9);
  if (values_read != 10) {
    if (ferror(procstat)) {
      die("first fscanf on /proc/stat in io_mon failed");
    } else {
      die_sans_errno("matching error for first fscanf on /proc/stat in io_mon");
    }
  }
  timeout(0, 250000000);
  rewind(procstat);
  unsigned long int end_stats[10];
  values_read = fscanf(procstat, "cpu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", end_stats + 0, end_stats + 1, end_stats + 2, end_stats + 3, end_stats + 4, end_stats + 5, end_stats + 6, end_stats + 7, end_stats + 8, end_stats + 9);
  if (values_read != 10) {
    if (ferror(procstat)) {
      die("second fscanf on /proc/stat in io_mon failed");
    } else {
      die_sans_errno("matching error for second fscanf on /proc/stat in io_mon");
    }
  }
  if (fclose(procstat) != 0) {
    die("couldn't close /proc/stat in io_mon");
  }
  int i;
  unsigned long int total_starting_cpu_time = 0;
  unsigned long int total_ending_cpu_time = 0;
  for (i = 0; i < 10; i++) {
    total_starting_cpu_time += start_stats[i];
    total_ending_cpu_time += end_stats[i];
  }
  double percent_iowait = ((double)(end_stats[4] - start_stats[4]) / (double)(total_ending_cpu_time - total_starting_cpu_time)) * 100;
  char out_buffer[20];
  int bytes_written = snprintf(out_buffer, 20, "io:%3.0f%%", percent_iowait);
  if (bytes_written < 0) {
    die_sans_errno("snprintf in io_mon failed");
  }
  multithread_write(out_buffer, (int *)thread_id);
  return NULL;
}
```