.file "commands.c" .text .section .rodata .LC0: .string "Unix Timestamp: %lld\n" .text .globl _unix .type _unix, @function _unix: .LFB6: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $16, %rsp movl $0, %edi call time@PLT movq %rax, -8(%rbp) movq -8(%rbp), %rax movq %rax, %rsi leaq .LC0(%rip), %rax movq %rax, %rdi movl $0, %eax call printf@PLT nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE6: .size _unix, .-_unix .section .rodata .LC1: .string "." .LC2: .string "Failed to open directory" .LC3: .string ".." .LC4: .string "realloc" .LC5: .string "strdup" .LC6: .string "%s%s\n" .text .globl ls .type ls, @function ls: .LFB7: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 pushq %rbx subq $56, %rsp .cfi_offset 3, -24 movq $0, -56(%rbp) movq $0, -48(%rbp) leaq .LC1(%rip), %rax movq %rax, %rdi call opendir@PLT movq %rax, -32(%rbp) cmpq $0, -32(%rbp) jne .L5 leaq .LC2(%rip), %rax movq %rax, %rdi call puts@PLT jmp .L2 .L9: movq -24(%rbp), %rax addq $19, %rax leaq .LC1(%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax je .L5 movq -24(%rbp), %rax addq $19, %rax leaq .LC3(%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax je .L5 movq -48(%rbp), %rax addq $1, %rax leaq 0(,%rax,8), %rdx movq -56(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call realloc@PLT movq %rax, -56(%rbp) cmpq $0, -56(%rbp) jne .L7 leaq .LC4(%rip), %rax movq %rax, %rdi call perror@PLT movq -32(%rbp), %rax movq %rax, %rdi call closedir@PLT jmp .L2 .L7: movq -24(%rbp), %rax addq $19, %rax movq -48(%rbp), %rdx leaq 0(,%rdx,8), %rcx movq -56(%rbp), %rdx leaq (%rcx,%rdx), %rbx movq %rax, %rdi call strdup@PLT movq %rax, (%rbx) movq -48(%rbp), %rax leaq 0(,%rax,8), %rdx movq -56(%rbp), %rax addq %rdx, %rax movq (%rax), %rax testq %rax, %rax jne .L8 leaq .LC5(%rip), %rax movq %rax, %rdi call perror@PLT movq -32(%rbp), %rax movq %rax, %rdi call closedir@PLT jmp .L2 .L8: addq $1, -48(%rbp) .L5: movq -32(%rbp), %rax movq %rax, %rdi call readdir@PLT movq %rax, -24(%rbp) cmpq $0, -24(%rbp) jne .L9 movq -32(%rbp), %rax movq %rax, %rdi call closedir@PLT movq -48(%rbp), %rsi movq -56(%rbp), %rax movq compareStrings@GOTPCREL(%rip), %rdx movq %rdx, %rcx movl $8, %edx movq %rax, %rdi call qsort@PLT movq $0, -40(%rbp) jmp .L10 .L11: movq -40(%rbp), %rax leaq 0(,%rax,8), %rdx movq -56(%rbp), %rax addq %rdx, %rax movq (%rax), %rax movq %rax, %rdi call getTypeSuffix@PLT movq %rax, %rdx movq -40(%rbp), %rax leaq 0(,%rax,8), %rcx movq -56(%rbp), %rax addq %rcx, %rax movq (%rax), %rax movq %rax, %rsi leaq .LC6(%rip), %rax movq %rax, %rdi movl $0, %eax call printf@PLT movl $5000, %edi call usleep@PLT movq -40(%rbp), %rax leaq 0(,%rax,8), %rdx movq -56(%rbp), %rax addq %rdx, %rax movq (%rax), %rax movq %rax, %rdi call free@PLT addq $1, -40(%rbp) .L10: movq -40(%rbp), %rax cmpq -48(%rbp), %rax jb .L11 movq -56(%rbp), %rax movq %rax, %rdi call free@PLT .L2: movq -8(%rbp), %rbx leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE7: .size ls, .-ls .section .rodata .LC7: .string "clock_gettime" .LC8: .string "localtime_r" .LC9: .string "%a %b %d %H:%M:%S %Z %Y" .LC10: .string "strftime returned 0\n" .text .globl date .type date, @function date: .LFB8: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $192, %rsp movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax leaq -192(%rbp), %rax movq %rax, %rsi movl $0, %edi call clock_gettime@PLT cmpl $-1, %eax jne .L13 leaq .LC7(%rip), %rax movq %rax, %rdi call perror@PLT jmp .L12 .L13: leaq -176(%rbp), %rdx leaq -192(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call localtime_r@PLT testq %rax, %rax jne .L15 leaq .LC8(%rip), %rax movq %rax, %rdi call perror@PLT jmp .L12 .L15: leaq -176(%rbp), %rdx leaq -112(%rbp), %rax movq %rdx, %rcx leaq .LC9(%rip), %rdx movl $100, %esi movq %rax, %rdi call strftime@PLT testq %rax, %rax jne .L16 movq stderr(%rip), %rax movq %rax, %rcx movl $20, %edx movl $1, %esi leaq .LC10(%rip), %rax movq %rax, %rdi call fwrite@PLT jmp .L12 .L16: leaq -112(%rbp), %rax movq %rax, %rdi call puts@PLT .L12: movq -8(%rbp), %rax subq %fs:40, %rax je .L18 call __stack_chk_fail@PLT .L18: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE8: .size date, .-date .section .rodata .LC11: .string "USER" .LC12: .string "Failed to get username." .text .globl whoami .type whoami, @function whoami: .LFB9: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $16, %rsp leaq .LC11(%rip), %rax movq %rax, %rdi call getenv@PLT movq %rax, -8(%rbp) cmpq $0, -8(%rbp) je .L20 movq -8(%rbp), %rax movq %rax, %rdi call puts@PLT jmp .L22 .L20: leaq .LC12(%rip), %rax movq %rax, %rdi call perror@PLT .L22: nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE9: .size whoami, .-whoami .section .rodata .LC13: .string "r" .LC14: .string "cat" .LC15: .string "%s" .text .globl cat .type cat, @function cat: .LFB10: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $304, %rsp movq %rdi, -296(%rbp) movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax movq -296(%rbp), %rax leaq .LC13(%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call fopen@PLT movq %rax, -280(%rbp) cmpq $0, -280(%rbp) jne .L26 leaq .LC14(%rip), %rax movq %rax, %rdi call perror@PLT jmp .L23 .L27: leaq -272(%rbp), %rax movq %rax, %rsi leaq .LC15(%rip), %rax movq %rax, %rdi movl $0, %eax call printf@PLT .L26: movq -280(%rbp), %rdx leaq -272(%rbp), %rax movl $256, %esi movq %rax, %rdi call fgets@PLT testq %rax, %rax jne .L27 movq -280(%rbp), %rax movq %rax, %rdi call fclose@PLT .L23: movq -8(%rbp), %rax subq %fs:40, %rax je .L28 call __stack_chk_fail@PLT .L28: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE10: .size cat, .-cat .section .rodata .LC16: .string "nl" .LC17: .string "%6d\t%s" .text .globl nl .type nl, @function nl: .LFB11: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $304, %rsp movq %rdi, -296(%rbp) movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax movq -296(%rbp), %rax leaq .LC13(%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call fopen@PLT movq %rax, -280(%rbp) cmpq $0, -280(%rbp) jne .L30 leaq .LC16(%rip), %rax movq %rax, %rdi call perror@PLT jmp .L29 .L30: movl $1, -284(%rbp) jmp .L32 .L33: movl -284(%rbp), %eax leal 1(%rax), %edx movl %edx, -284(%rbp) leaq -272(%rbp), %rdx movl %eax, %esi leaq .LC17(%rip), %rax movq %rax, %rdi movl $0, %eax call printf@PLT .L32: movq -280(%rbp), %rdx leaq -272(%rbp), %rax movl $256, %esi movq %rax, %rdi call fgets@PLT testq %rax, %rax jne .L33 movq -280(%rbp), %rax movq %rax, %rdi call fclose@PLT .L29: movq -8(%rbp), %rax subq %fs:40, %rax je .L34 call __stack_chk_fail@PLT .L34: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE11: .size nl, .-nl .section .rodata .LC18: .string "HOME" .LC19: .string "cd: HOME not set\n" .LC20: .string "cd" .text .globl cd .type cd, @function cd: .LFB12: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movq %rdi, -24(%rbp) cmpq $0, -24(%rbp) jne .L36 leaq .LC18(%rip), %rax movq %rax, %rdi call getenv@PLT movq %rax, -8(%rbp) cmpq $0, -8(%rbp) jne .L37 movq stderr(%rip), %rax movq %rax, %rcx movl $17, %edx movl $1, %esi leaq .LC19(%rip), %rax movq %rax, %rdi call fwrite@PLT jmp .L35 .L37: movq -8(%rbp), %rax movq %rax, -24(%rbp) .L36: movq -24(%rbp), %rax movq %rax, %rdi call chdir@PLT testl %eax, %eax je .L35 leaq .LC20(%rip), %rax movq %rax, %rdi call perror@PLT .L35: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE12: .size cd, .-cd .section .rodata .LC21: .string "fork" .LC22: .string "execvp" .LC23: .string "waitpid" .text .globl execute_program .type execute_program, @function execute_program: .LFB13: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movq %rdi, -24(%rbp) movq %rsi, -32(%rbp) movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax call fork@PLT movl %eax, -12(%rbp) cmpl $-1, -12(%rbp) jne .L40 leaq .LC21(%rip), %rax movq %rax, %rdi call perror@PLT jmp .L39 .L40: cmpl $0, -12(%rbp) jne .L42 movq -32(%rbp), %rdx movq -24(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call execvp@PLT leaq .LC22(%rip), %rax movq %rax, %rdi call perror@PLT movl $1, %edi call exit@PLT .L42: leaq -16(%rbp), %rcx movl -12(%rbp), %eax movl $0, %edx movq %rcx, %rsi movl %eax, %edi call waitpid@PLT cmpl $-1, %eax jne .L39 leaq .LC23(%rip), %rax movq %rax, %rdi call perror@PLT .L39: movq -8(%rbp), %rax subq %fs:40, %rax je .L44 call __stack_chk_fail@PLT .L44: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE13: .size execute_program, .-execute_program .section .rodata .LC24: .string "Available commands:" .LC25: .string "exit" .LC26: .string "test" .LC27: .string "clear" .LC28: .string "unix" .LC29: .string "ls" .LC30: .string "date" .LC31: .string "whoami" .LC32: .string "help" .LC33: .string "exec" .text .globl help .type help, @function help: .LFB14: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 leaq .LC24(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC25(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC26(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC27(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC28(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC29(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC30(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC31(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC14(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC16(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC20(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC32(%rip), %rax movq %rax, %rdi call puts@PLT leaq .LC33(%rip), %rax movq %rax, %rdi call puts@PLT nop popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE14: .size help, .-help .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4: