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
  lea    D58(%rip),%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x108,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xf8(%rsp)
  xor    %eax,%eax
  lea    0x40(%rsp),%rdi
  lea    0x70(%rsp),%rbx
  call   <time@plt>
  lea    0xb0(%rsp),%r14
  lea    0x50(%rsp),%r15
  mov    %eax,%edi
  call   <srand@plt>
  mov    0x8(%rbp),%rdi
  call   <atoi@plt>
  mov    0x10(%rbp),%rdi
  call   <atoi@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %eax,%edi
  mov    %eax,%r13d
  call   <read@plt>
  lea    0x44(%rsp),%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x44(%rsp),%ecx
  mov    %r14,%rdi
  xor    %eax,%eax
  lea    D25(%rip),%rdx
  lea    D50(%rip),%rsi
  call   <sprintf@plt>
  mov    %r14,%rdi
  lea    D18(%rip),%rsi
  call   <strcat@plt>
  lea    D12(%rip),%rsi
  mov    %eax,%edi
  call   <fopen@plt>
  lea    0x54(%rsp),%rcx
  sub    $0x8,%rsp
  mov    %r15,%rdx
  mov    %rax,0x30(%rsp)
  mov    %rax,%rdi
  lea    0x68(%rsp),%rax
  lea    D34(%rip),%rsi
  push   %rax
  lea    0x6c(%rsp),%r9
  lea    0x68(%rsp),%r8
  call   <fscanf@plt>
  mov    0x18(%rbp),%rdi
  call   <atoi@plt>
  mov    $0x40,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  mov    %eax,0x24(%rsp)
  mov    %eax,%r14d
  call   <memset@plt>
  mov    $0xde,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    %r14d,%edi
  mov    $0x40,%edx
  mov    %rbx,%rsi
  call   <write@plt>
  pop    %r8
  pop    %r9
  lea    0x48(%rsp),%rax
  lea    0x3c(%rsp),%r14
  mov    %rax,0x18(%rsp)
  lea    0x4c(%rsp),%rax
  lea    0x64(%rsp),%rbp
  mov    %rax,0x20(%rsp)
  nopl   (%rax)
L166:
  mov    $0x40,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r13d,%edi
  call   <read@plt>
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x3c(%rsp),%eax
  cmp    $0x6f,%eax
  je     L158
  cmp    $0x29a,%eax
  jne    L166
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r13d,%edi
  call   <read@plt>
  mov    0x18(%rsp),%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x48(%rsp),%esi
  mov    %r15,%rcx
  mov    %r15,%rax
  xor    %r8d,%r8d
L202:
  xor    %edx,%edx
  cmp    %esi,(%rax)
  setg   %dl
  add    $0x4,%rax
  add    %edx,%r8d
  cmp    %rbp,%rax
  jne    L202
  xor    %esi,%esi
  mov    $0x40,%edx
  mov    %rbx,%rdi
  mov    %rcx,0x8(%rsp)
  mov    %r8d,0x10(%rsp)
  call   <memset@plt>
  mov    0x10(%rsp),%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    0x14(%rsp),%edi
  mov    $0x40,%edx
  mov    %rbx,%rsi
  call   <write@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r13d,%edi
  call   <read@plt>
  mov    0x20(%rsp),%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x4c(%rsp),%eax
  mov    0x8(%rsp),%rcx
  cmp    $0x14d,%eax
  je     L187
  cmp    $0x1bc,%eax
  je     L181
  cmp    $0x22b,%eax
  jne    L166
  mov    0x28(%rsp),%rdi
  call   <fclose@plt>
  mov    0xf8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L186
  add    $0x108,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L158:
  mov    %r15,%rsi
  mov    %r15,%rax
  xor    %ecx,%ecx
L170:
  mov    (%rax),%edi
  xor    %edx,%edx
  test   %edi,%edi
  setg   %dl
  add    $0x4,%rax
  add    %edx,%ecx
  cmp    %rax,%rbp
  jne    L170
  mov    $0xffffffff,%edx
  test   %ecx,%ecx
  jne    L137
L82:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    0x14(%rsp),%edi
  mov    $0x40,%edx
  mov    %rbx,%rsi
  call   <write@plt>
  jmp    L166
L181:
  mov    0x48(%rsp),%eax
L178:
  cmp    %eax,(%rcx)
  jle    L58
  movl   $0xffffffff,(%rcx)
L58:
  add    $0x4,%rcx
  cmp    %rbp,%rcx
  jne    L178
  jmp    L166
  nopl   0x0(%rax)
L187:
  mov    0x48(%rsp),%eax
L134:
  cmp    %eax,(%rcx)
  jge    L109
  movl   $0xffffffff,(%rcx)
L109:
  add    $0x4,%rcx
  cmp    %rbp,%rcx
  jne    L134
  jmp    L166
  nopl   0x0(%rax)
L137:
  xor    %eax,%eax
  mov    %ecx,0x10(%rsp)
  mov    %rsi,0x8(%rsp)
  call   <rand@plt>
  mov    0x10(%rsp),%ecx
  mov    0x8(%rsp),%rsi
  cltd
  idiv   %ecx
L5:
  mov    (%rsi),%r8d
  test   %r8d,%r8d
  jle    L135
  test   %edx,%edx
  je     L133
  sub    $0x1,%edx
L135:
  add    $0x4,%rsi
  cmp    %rbp,%rsi
  jne    L5
  jmp    L166
L133:
  mov    %r8d,%edx
  jmp    L82
L186:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D58
datatype: string
name: read_data
arguments: label: D25
datatype: string
name: read_data
arguments: label: D50
datatype: string
name: read_data
arguments: label: D18
datatype: string
name: read_data
arguments: label: D12
datatype: string
name: read_data
arguments: label: D34
datatype: string

tool: D58: %d

tool: D25: data

tool: D50: %s%d

tool: D18: .txt

tool: D12: r

tool: D34: %d %d %d %d %d

assistant: ```c
int main(int argc, char *argv[]) {
  char msg[64];
  int n, i;
  time_t t;
  srand((unsigned)time(&t));
  int temp = atoi(argv[1]);
  int fd = atoi(argv[2]);
  int n3;
  read(fd, msg, 64);
  sscanf(msg, "%d", &n3);
  char txt_file[64];
  sprintf(txt_file, "%s%d", "data", n3);
  FILE *in = fopen(strcat(txt_file, ".txt"), "r");
  int input_num[5];
  fscanf(in, "%d %d %d %d %d", &input_num[0], &input_num[1], &input_num[2], &input_num[3], &input_num[4]);
  int fd1 = atoi(argv[3]);
  memset(&msg[0], 0, sizeof(msg));
  sprintf(msg, "%d", 222);
  write(fd1, msg, 64);
  int n1, n2;
  int count = 0, num_n = 0;
  while (1) {
    memset(&msg[0], 0, sizeof(msg));
    read(fd, msg, 64);
    sscanf(msg, "%d", &n);
    if (n == 111) {
      num_n = 0;
      for (i = 0; i < 5; i++) {
        if (input_num[i] > 0)
          num_n++;
      }
      if (num_n == 0) {
        sprintf(msg, "%d", -1);
        write(fd1, msg, 64);
      } else {
        int rnd_n = rand() % num_n;
        for (i = 0; i < 5; i++) {
          if (input_num[i] > 0 && rnd_n == 0) {
            sprintf(msg, "%d", input_num[i]);
            write(fd1, msg, 64);
            break;
          } else if (input_num[i] > 0)
            rnd_n--;
        }
      }
    } else if (n == 666) {
      read(fd, msg, 64);
      sscanf(msg, "%d", &n1);
      count = 0;
      for (i = 0; i < 5; i++) {
        if (input_num[i] > n1)
          count++;
      }
      memset(&msg[0], 0, sizeof(msg));
      sprintf(msg, "%d", count);
      write(fd1, msg, 64);
      read(fd, msg, 64);
      sscanf(msg, "%d", &n2);
      if (n2 == 333) {
        for (i = 0; i < 5; i++) {
          if (input_num[i] < n1)
            input_num[i] = -1;
        }
      }
      if (n2 == 444) {
        for (i = 0; i < 5; i++) {
          if (input_num[i] > n1)
            input_num[i] = -1;
        }
      }
      if (n2 == 555) {
        break;
      }
    }
  }
  fclose(in);
}
```