// File: /workspace/github_cpp_makefile_star2_O2/mukul-mehta[P]meta/shell.cc
// Function: getShellPrompt()
const char* getShellPrompt() {
    string username = getUsername();
    string hostname = getHostname();
    char timeBuffer[12];

    auto t = time(nullptr);
    struct tm* ltime = localtime(&t);
    strftime(timeBuffer, sizeof(timeBuffer), "%H:%M:%S", ltime);

    char* prompt = (char*)malloc(BUFSIZE * sizeof(char));

    // Check width of terminal
    // Needed because some part of the prompt is on the right end and need to fill with correct num spaces in between
    struct winsize size;
    ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
    int width = size.ws_col;
    int numSpaces = width - (strlen(__CWD) + 2) - (hostname.size()) - (strlen(timeBuffer));

    string spaces(numSpaces, ' ');
    sprintf(prompt, ": %s%s%s%s%s%s%s [%s%s@%s%s] \n%s@%s ", GREEN, __CWD, NORM, spaces.c_str(),
            GRAY, timeBuffer, NORM, CYAN, username.c_str(), hostname.c_str(), NORM, RED, NORM);
    sprintf(prompt, "%s%s%s: %s%s%s%s%s%s%s\n%s%s%s %s@%s ", YELLOW, hostname.c_str(), NORM,
            GREENIT, __CWD, NORM, spaces.c_str(), GRAY, timeBuffer, NORM, CYAN, username.c_str(),
            NORM, RED, NORM);
    return prompt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq 0x68(%rsp), %rdi
callq 0x4093
leaq 0x18(%rsp), %rdi
callq 0x40c0
xorl %edi, %edi
callq 0x2270
leaq 0x58(%rsp), %rdi
movq %rax, (%rdi)
callq 0x21d0
leaq 0x2737(%rip), %rdx      # 0x516e
leaq 0xc(%rsp), %r12
pushq $0xc
popq %rsi
movq %r12, %rdi
movq %rax, %rcx
callq 0x2220
movl $0x1000, %edi           # imm = 0x1000
callq 0x23a0
movq %rax, %rbx
pushq $0x1
popq %rdi
leaq 0x60(%rsp), %r15
movl $0x5413, %esi           # imm = 0x5413
movq %r15, %rdx
xorl %eax, %eax
callq 0x23f0
movzwl 0x2(%r15), %r14d
leaq 0x6c56(%rip), %rdi      # 0x96d0
callq 0x2100
movq %rax, %r15
addl 0x20(%rsp), %r15d
movq %r12, %rdi
callq 0x2100
addl %r15d, %eax
negl %eax
addl %r14d, %eax
addl $-0x2, %eax
movslq %eax, %rsi
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x38(%rsp), %rdi
pushq $0x20
popq %rdx
callq 0x22d0
leaq 0x38(%rsp), %rax
movq (%rax), %r9
leaq 0x68(%rsp), %r13
leaq 0x18(%rsp), %r14
subq $0x8, %rsp
leaq 0x26d2(%rip), %r15      # 0x51a2
leaq 0x26dc(%rip), %r12      # 0x51b3
leaq 0x26cf(%rip), %rbp      # 0x51ad
leaq 0x26c2(%rip), %r11      # 0x51a7
leaq 0x268b(%rip), %rsi      # 0x5177
leaq 0x26a9(%rip), %rdx      # 0x519c
movq %rbx, %rdi
leaq 0x6bd3(%rip), %rcx      # 0x96d0
movq %r15, %r8
xorl %eax, %eax
pushq %r15
pushq %r12
pushq %r15
pushq (%r14)
pushq (%r13)
pushq %rbp
pushq %r15
leaq 0x4c(%rsp), %rbp
pushq %rbp
pushq %r11
callq 0x2070
addq $0x50, %rsp
movq (%r14), %rcx
subq $0x8, %rsp
leaq 0x2688(%rip), %rsi      # 0x51b9
leaq 0x26a6(%rip), %rdx      # 0x51de
leaq 0x26a5(%rip), %r9       # 0x51e4
movq %rbx, %rdi
movq %r15, %r8
movl $0x0, %eax
pushq %r15
pushq %r12
pushq %r15
pushq (%r13)
leaq 0x2652(%rip), %r10      # 0x51ad
pushq %r10
pushq %r15
pushq %rbp
leaq 0x2640(%rip), %r10      # 0x51a7
pushq %r10
leaq 0x80(%rsp), %r14
pushq (%r14)
pushq %r15
pushq 0x645c(%rip)            # 0x8fd8
callq 0x2070
addq $0x60, %rsp
movq %r14, %rdi
callq 0x2120
leaq 0x18(%rsp), %rdi
callq 0x2120
movq %r13, %rdi
callq 0x2120
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x2120
jmp 0x2bc6
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x24a0