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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  lea    D18(%rip),%rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rdi
  lea    0x60(%rsp),%rbx
  call   <time@plt>
  lea    0xa0(%rsp),%r14
  mov    %eax,%edi
  call   <srand@plt>
  mov    0x8(%r13),%rdi
  call   <atoi@plt>
  mov    0x10(%r13),%rdi
  call   <atoi@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %eax,%edi
  mov    %eax,%r12d
  call   <read@plt>
  lea    0x34(%rsp),%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x34(%rsp),%ecx
  mov    %r14,%rdi
  xor    %eax,%eax
  lea    D32(%rip),%rdx
  lea    D14(%rip),%rsi
  call   <sprintf@plt>
  mov    %r14,%rdi
  lea    D19(%rip),%rsi
  call   <strcat@plt>
  lea    D25(%rip),%rsi
  mov    %eax,%edi
  call   <fopen@plt>
  lea    0x44(%rsp),%rcx
  lea    0x40(%rsp),%rdx
  sub    $0x8,%rsp
  mov    %rax,0x20(%rsp)
  mov    %rax,%rdi
  lea    0x58(%rsp),%rax
  lea    D41(%rip),%rsi
  push   %rax
  lea    0x5c(%rsp),%r9
  lea    0x58(%rsp),%r8
  call   <fscanf@plt>
  mov    0x18(%r13),%rdi
  call   <atoi@plt>
  mov    $0x40,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  mov    %eax,%r14d
  call   <memset@plt>
  mov    $0xde,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    %r14d,%edi
  mov    $0x40,%edx
  mov    %rbx,%rsi
  call   <write@plt>
  pop    %rdi
  pop    %r8
  lea    0x38(%rsp),%rax
  lea    0x2c(%rsp),%r13
  mov    %rax,0x8(%rsp)
  lea    0x3c(%rsp),%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax,%rax,1)
L194:
  mov    $0x40,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x2c(%rsp),%eax
  cmp    $0x6f,%eax
  je     L208
  cmp    $0x29a,%eax
  jne    L194
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  xor    %r15d,%r15d
  call   <read@plt>
  mov    0x8(%rsp),%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x38(%rsp),%eax
  cmp    %eax,0x40(%rsp)
  mov    %rbx,%rdi
  setg   %r15b
  xor    %edx,%edx
  cmp    0x44(%rsp),%eax
  setl   %dl
  add    %edx,%r15d
  xor    %edx,%edx
  cmp    0x48(%rsp),%eax
  setl   %dl
  add    %edx,%r15d
  xor    %edx,%edx
  cmp    0x4c(%rsp),%eax
  setl   %dl
  add    %edx,%r15d
  cmp    0x50(%rsp),%eax
  mov    $0x40,%edx
  setl   %al
  xor    %esi,%esi
  movzbl %al,%eax
  add    %eax,%r15d
  call   <memset@plt>
  mov    %r15d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r14d,%edi
  call   <write@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  mov    0x10(%rsp),%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x3c(%rsp),%eax
  cmp    $0x14d,%eax
  je     L239
  cmp    $0x1bc,%eax
  je     L316
  cmp    $0x22b,%eax
  jne    L194
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0xf8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L208:
  mov    0x40(%rsp),%eax
  mov    0x44(%rsp),%edx
  xor    %r15d,%r15d
  mov    0x48(%rsp),%ecx
  mov    0x4c(%rsp),%esi
  test   %eax,%eax
  setg   %r15b
  xor    %eax,%eax
  test   %edx,%edx
  setg   %al
  add    %eax,%r15d
  xor    %eax,%eax
  test   %ecx,%ecx
  setg   %al
  add    %eax,%r15d
  mov    0x50(%rsp),%eax
  test   %esi,%esi
  jle    L290
  add    $0x1,%r15d
  test   %eax,%eax
  jle    L5
L126:
  add    $0x1,%r15d
L5:
  xor    %eax,%eax
  call   <rand@plt>
  mov    0x40(%rsp),%r8d
  cltd
  idiv   %r15d
  test   %r8d,%r8d
  jle    L269
  test   %edx,%edx
  je     L326
  sub    $0x1,%edx
L269:
  mov    0x44(%rsp),%r8d
  test   %r8d,%r8d
  jle    L241
  test   %edx,%edx
  je     L326
  sub    $0x1,%edx
L241:
  mov    0x48(%rsp),%r8d
  test   %r8d,%r8d
  jle    L66
  test   %edx,%edx
  je     L326
  sub    $0x1,%edx
L66:
  mov    0x4c(%rsp),%r8d
  test   %r8d,%r8d
  jle    L271
  test   %edx,%edx
  je     L326
  sub    $0x1,%edx
L271:
  mov    0x50(%rsp),%r8d
  test   %edx,%edx
  jne    L194
  test   %r8d,%r8d
  jle    L194
L326:
  mov    %r8d,%edx
  jmp    L91
  nopl   0x0(%rax,%rax,1)
L290:
  test   %eax,%eax
  jg     L126
  test   %r15d,%r15d
  jne    L5
  mov    $0xffffffff,%edx
L91:
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    $0x40,%edx
  mov    %rbx,%rsi
  mov    %r14d,%edi
  call   <write@plt>
  jmp    L194
L316:
  mov    0x38(%rsp),%eax
  cmp    %eax,0x40(%rsp)
  jle    L215
  movl   $0xffffffff,0x40(%rsp)
L215:
  cmp    0x44(%rsp),%eax
  jge    L68
  movl   $0xffffffff,0x44(%rsp)
L68:
  cmp    0x48(%rsp),%eax
  jge    L246
  movl   $0xffffffff,0x48(%rsp)
L246:
  cmp    0x4c(%rsp),%eax
  jge    L156
  movl   $0xffffffff,0x4c(%rsp)
L156:
  cmp    0x50(%rsp),%eax
  jge    L194
L338:
  movl   $0xffffffff,0x50(%rsp)
  jmp    L194
  nopl   0x0(%rax,%rax,1)
L239:
  mov    0x38(%rsp),%eax
  cmp    %eax,0x40(%rsp)
  jge    L174
  movl   $0xffffffff,0x40(%rsp)
L174:
  cmp    0x44(%rsp),%eax
  jle    L266
  movl   $0xffffffff,0x44(%rsp)
L266:
  cmp    0x48(%rsp),%eax
  jle    L46
  movl   $0xffffffff,0x48(%rsp)
L46:
  cmp    0x4c(%rsp),%eax
  jle    L42
  movl   $0xffffffff,0x4c(%rsp)
L42:
  cmp    0x50(%rsp),%eax
  jle    L194
  jmp    L338
L54:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D18
type_infered: string
name: parse_data
arguments: tag: D32
type_infered: string
name: parse_data
arguments: tag: D14
type_infered: string
name: parse_data
arguments: tag: D19
type_infered: string
name: parse_data
arguments: tag: D25
type_infered: string
name: parse_data
arguments: tag: D41
type_infered: string

tool: D18: %d

tool: D32: data

tool: D14: %s%d

tool: D19: .txt

tool: D25: r

tool: D41: %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);
}
```