.file "main.c" .text .globl state .data .align 4 .type state, @object .size state, 4 state: .long 1 .globl input .bss .align 32 .type input, @object .size input, 100 input: .zero 100 .section .rodata .[NUL]: .string " " .[exit]: .string "exit" .[test]: .string "test" .[clear]: .string "clear" .[unix]: .string "unix" .[ls]: .string "ls" .[date]: .string "date" .[whoami]: .string "whoami" .[cat]: .string "cat" .[Usage: cat ]: .string "Usage: cat " .[nl]: .string "nl" .[Usage: nl ]: .string "Usage: nl " .[cd]: .string "cd" .[help]: .string "help" .text .globl main .type main, @function main: .|MAIN LOOP|: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 addq $-128, %rsp movq %fs:40, %rax movq %rax, -8(%rbp) xorl %eax, %eax jmp .L2 .|NULL|: movl $0, %eax call print_shell@PLT movl $0, %eax call get_input@PLT leaq .[NUL](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strtok@PLT movq %rax, -112(%rbp) leaq .[NUL](%rip), %rax movq %rax, %rsi movl $0, %edi call strtok@PLT movq %rax, -104(%rbp) cmpq $0, -112(%rbp) je .|nop| leaq .[exit](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|test| movl $0, %eax call do_exit@PLT jmp .L2 .|test|: leaq .[test](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|clear| movl $0, %eax call test@PLT jmp .L2 .|clear|: leaq .[clear](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|unix| movl $0, %eax call clear_screen@PLT jmp .L2 .|unix|: leaq .[unix](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|ls| movl $0, %eax call _unix@PLT jmp .L2 .|ls|: leaq .[ls](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|date| movl $0, %eax call ls@PLT jmp .L2 .|date|: leaq .[date](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|whoami| movl $0, %eax call date@PLT jmp .L2 .|whoami|: leaq .[whoami](%rip), %rax movq %rax, %rsi leaq input(%rip), %rax movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|cat| movl $0, %eax call whoami@PLT jmp .L2 .|cat|: movq -112(%rbp), %rax leaq .[cat](%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|nl| cmpq $0, -104(%rbp) je .|Usage: cat | movq -104(%rbp), %rax movq %rax, %rdi call cat@PLT jmp .L2 .|Usage: cat |: leaq .[Usage: cat ](%rip), %rax movq %rax, %rdi call puts@PLT jmp .L2 .|nl|: movq -112(%rbp), %rax leaq .[nl](%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|cd| cmpq $0, -104(%rbp) je .|Usage: nl | movq -104(%rbp), %rax movq %rax, %rdi call nl@PLT jmp .L2 .|Usage: nl |: leaq .[Usage: nl ](%rip), %rax movq %rax, %rdi call puts@PLT jmp .L2 .|cd|: movq -112(%rbp), %rax leaq .[cd](%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .|help| movq -104(%rbp), %rax movq %rax, %rdi call cd@PLT jmp .L2 .|help|: movq -112(%rbp), %rax leaq .[help](%rip), %rdx movq %rdx, %rsi movq %rax, %rdi call strcmp@PLT testl %eax, %eax jne .L17 movl $0, %eax call help@PLT jmp .L2 .L17: movl $0, -116(%rbp) movl -116(%rbp), %eax leal 1(%rax), %edx movl %edx, -116(%rbp) cltq movq -112(%rbp), %rdx movq %rdx, -96(%rbp,%rax,8) jmp .L18 .L20: movl -116(%rbp), %eax leal 1(%rax), %edx movl %edx, -116(%rbp) cltq movq -104(%rbp), %rdx movq %rdx, -96(%rbp,%rax,8) .L18: leaq .[NUL](%rip), %rax movq %rax, %rsi movl $0, %edi call strtok@PLT movq %rax, -104(%rbp) cmpq $0, -104(%rbp) je .L19 cmpl $8, -116(%rbp) jle .L20 .L19: movl -116(%rbp), %eax cltq movq $0, -96(%rbp,%rax,8) leaq -96(%rbp), %rdx movq -112(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call execute_program@PLT jmp .L2 .|nop|: nop .L2: movl state(%rip), %eax testl %eax, %eax jne .|NULL| movl $0, %eax movq -8(%rbp), %rdx subq %fs:40, %rdx je .|leave| call __stack_chk_fail@PLT .|leave|: leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE6: .size main, .-main .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: