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

```asm
<prompt>:
  endbr64
  push   %r15
  push   %r14
  lea    D41(%rip),%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    D166(%rip),%rbx
  sub    $0x2d8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2c8(%rsp)
  xor    %eax,%eax
  lea    0x1c0(%rsp),%rax
  lea    0x20(%rsp),%r13
  mov    %rax,(%rsp)
  lea    0x18(%rsp),%rax
  lea    0x70(%rsp),%r12
  mov    %rax,0x8(%rsp)
  lea    0xc0(%rsp),%rbp
  xchg   %ax,%ax
L123:
  xor    %esi,%esi
  xor    %edi,%edi
  call   <fstat@plt>
  mov    $0x4c,%edx
  mov    %rbx,%rsi
  shr    $0x3f,%rax
  mov    %rax,%rdi
  call   <_assert@plt>
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <fstat@plt>
  mov    $0x4d,%edx
  mov    %rbx,%rsi
  shr    $0x3f,%rax
  mov    %rax,%rdi
  call   <_assert@plt>
  xor    %esi,%esi
  mov    $0x2,%edi
  call   <fstat@plt>
  mov    $0x4e,%edx
  mov    %rbx,%rsi
  shr    $0x3f,%rax
  mov    %rax,%rdi
  call   <_assert@plt>
  mov    %r13,%rdi
  call   <getcwd@plt>
  mov    %r12,%rdi
  call   <gettty@plt>
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <printf@plt>
  xor    %edi,%edi
  mov    $0xff,%edx
  mov    %rbp,%rsi
  call   <get_line@plt>
  mov    $0x2,%edx
  lea    D203(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L169
  call   <print_help@plt>
  jmp    L123
  nopl   (%rax)
L169:
  mov    $0x7,%edx
  lea    D73(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L241
  call   <logout@plt>
  jmp    L123
  nopl   0x0(%rax,%rax,1)
L241:
  mov    $0x1,%edx
  lea    D13(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L123
  call   <fork@plt>
  test   %eax,%eax
  je     L144
  xor    %eax,%eax
  call   <wait@plt>
  jmp    L123
  nopw   0x0(%rax,%rax,1)
L144:
  mov    (%rsp),%rdi
  lea    D12(%rip),%rsi
  call   <strcpy@plt>
  lea    D90(%rip),%rsi
  mov    %rbp,%rdi
  call   <strtok@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L233
  jmp    L240
  nopl   0x0(%rax)
L239:
  lea    D90(%rip),%rsi
  xor    %edi,%edi
  call   <strtok@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L273
L48:
  mov    %r15,%rdi
  call   <creat@plt>
  mov    $0x1,%edi
  call   <close@plt>
  mov    $0x401,%esi
  mov    %r15,%rdi
  call   <open@plt>
  test   %rax,%rax
  js     L243
L257:
  lea    D90(%rip),%rsi
  xor    %edi,%edi
  call   <strtok@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L240
L233:
  mov    $0x3,%edx
  lea    D60(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L239
  mov    $0x2,%edx
  lea    D47(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L250
  lea    D90(%rip),%rsi
  xor    %edi,%edi
  call   <strtok@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L126
L187:
  mov    $0x1,%edi
  call   <close@plt>
  mov    %r15,%rdi
  call   <creat@plt>
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <open@plt>
  test   %rax,%rax
  jns    L257
L243:
  mov    %r15,%rdx
  lea    D179(%rip),%rsi
L74:
  mov    $0x2,%edi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L257
  nopl   (%rax)
L250:
  mov    $0x2,%edx
  lea    D59(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L251
  lea    D90(%rip),%rsi
  xor    %edi,%edi
  call   <strtok@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L219
L287:
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <stat@plt>
  test   %rax,%rax
  js     L194
L84:
  xor    %edi,%edi
  call   <close@plt>
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <open@plt>
  test   %rax,%rax
  jns    L257
  mov    %r15,%rdx
  lea    D32(%rip),%rsi
  jmp    L74
  nopw   0x0(%rax,%rax,1)
L251:
  mov    $0x2,%edx
  lea    D126(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L281
  mov    0x8(%rsp),%rdi
  call   <pipe@plt>
  call   <fork@plt>
  test   %eax,%eax
  jne    L49
  mov    (%rsp),%rdi
  lea    D12(%rip),%rsi
  call   <strcpy@plt>
  mov    0x1c(%rsp),%edi
  call   <close@plt>
  xor    %edi,%edi
  call   <close@plt>
  mov    0x18(%rsp),%edi
  xor    %esi,%esi
  call   <dup2@plt>
  jmp    L257
L273:
  lea    D148(%rip),%rsi
  mov    $0x2,%edi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L48
L49:
  mov    0x18(%rsp),%edi
  call   <close@plt>
  mov    $0x1,%edi
  call   <close@plt>
  mov    0x1c(%rsp),%edi
  mov    $0x1,%esi
  call   <dup2@plt>
L240:
  mov    (%rsp),%rdi
  call   <exec@plt>
  xor    %eax,%eax
  call   <getpid@plt>
  lea    D37(%rip),%rsi
  mov    $0x2,%edi
  mov    %eax,%edx
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L123
  nopw   0x0(%rax,%rax,1)
L281:
  mov    %r15,%rsi
  mov    (%rsp),%r15
  mov    %r15,%rdi
  call   <strcat@plt>
  lea    D90(%rip),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  jmp    L257
  nopl   0x0(%rax,%rax,1)
L126:
  lea    D148(%rip),%rsi
  mov    $0x2,%edi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L187
L194:
  mov    %r15,%rdx
  lea    D32(%rip),%rsi
  mov    $0x2,%edi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L84
L219:
  lea    D148(%rip),%rsi
  mov    $0x2,%edi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L287
```

tool_calls: name: read_data
arguments: label: D41
type_guessed: string
name: read_data
arguments: label: D166
type_guessed: string
name: read_data
arguments: label: D203
type_guessed: string
name: read_data
arguments: label: D73
type_guessed: string
name: read_data
arguments: label: D13
type_guessed: string
name: read_data
arguments: label: D12
type_guessed: string
name: read_data
arguments: label: D90
type_guessed: string
name: read_data
arguments: label: D60
type_guessed: string
name: read_data
arguments: label: D47
type_guessed: string
name: read_data
arguments: label: D179
type_guessed: string
name: read_data
arguments: label: D59
type_guessed: string
name: read_data
arguments: label: D32
type_guessed: string
name: read_data
arguments: label: D126
type_guessed: string
name: read_data
arguments: label: D148
type_guessed: string
name: read_data
arguments: label: D37
type_guessed: string

tool: D41: %s@%s$ 

tool: D166: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fossum/wsu_cs460/refs/heads/master/final/fsh.c

tool: D203: ?

tool: D73: logout

tool: 

tool: D12: /bin/

tool: D90:  

tool: D60: >>

tool: D47: >

tool: D179: %s: Could not open for writing


tool: D59: <

tool: D32: Could not open %s for reading


tool: D126: |

tool: D148: NULL output filename


tool: D37: PID:%d failed to execute


assistant: ```c
int prompt() {
  int cid;
  char cwd[80], tty[80], request[255], command[255];
  while (1) {
    _assert(fstat(0, 0) < 0, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fossum/wsu_cs460/refs/heads/master/final/fsh.c", 76);
    _assert(fstat(1, 0) < 0, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fossum/wsu_cs460/refs/heads/master/final/fsh.c", 77);
    _assert(fstat(2, 0) < 0, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fossum/wsu_cs460/refs/heads/master/final/fsh.c", 78);
    getcwd(cwd);
    gettty(tty);
    printf("%s@%s$ ", tty, cwd);
    get_line(0, request, 255);
    if (strncmp(request, "?", 2) == 0) {
      print_help();
      continue;
    } else if (strncmp(request, "logout", 7) == 0) {
      logout();
    } else if (strncmp(request, "", 1) == 0) {
      continue;
    } else {
      char *tok;
      cid = fork();
      if (!cid) {
        strcpy(command, "/bin/");
        tok = strtok(request, " ");
        while (tok != 0) {
          if (strncmp(tok, ">>", 3) == 0) {
            tok = strtok(0, " ");
            if (tok == 0) {
              fprintf(2, "NULL output filename\n");
              exit(-1);
            }
            creat(tok);
            close(1);
            if (open(tok, 01 | 02000) < 0) {
              fprintf(2, "%s: Could not open for writing\n", tok);
              exit(-1);
            }
          } else if (strncmp(tok, ">", 2) == 0) {
            tok = strtok(0, " ");
            if (tok == 0) {
              fprintf(2, "NULL output filename\n");
              exit(-1);
            }
            close(1);
            creat(tok);
            if (open(tok, 01) < 0) {
              fprintf(2, "%s: Could not open for writing\n", tok);
              exit(-1);
            }
          } else if (strncmp(tok, "<", 2) == 0) {
            tok = strtok(0, " ");
            if (tok == 0) {
              fprintf(2, "NULL output filename\n");
              exit(-1);
            }
            if (stat(tok, 0) < 0) {
              fprintf(2, "Could not open %s for reading\n", tok);
              exit(-1);
            }
            close(0);
            if (open(tok, 00) < 0) {
              fprintf(2, "Could not open %s for reading\n", tok);
              exit(-1);
            }
          } else if (strncmp(tok, "|", 2) == 0) {
            int new_pipe[2], pipe_pid;
            pipe(new_pipe);
            pipe_pid = fork();
            if (!pipe_pid) {
              strcpy(command, "/bin/");
              close(new_pipe[1]);
              close(0);
              dup2(new_pipe[0], 0);
            } else {
              tok = 0;
              close(new_pipe[0]);
              close(1);
              dup2(new_pipe[1], 1);
              continue;
            }
          } else {
            strcat(command, tok);
            strcat(command, " ");
          }
          tok = strtok(0, " ");
        }
        exec(command);
        fprintf(2, "PID:%d failed to execute\r\n", getpid());
        exit(-1);
      } else {
        wait();
      }
    }
  }
  return (-1);
}
```