// File: /workspace/github_c_makefile_star2_O1/ikbenlike[P]nngutils/src/sh.c
// Function: sh_add_alias
int sh_add_alias(char *arg){
    size_t n_len = 0;
    size_t c_len = 0;
    char *name = NULL;
    char *command = NULL;
    
    char *split = strchr(arg, '=');

    if(split){
        n_len = split - arg;
        name = calloc(n_len + 1, sizeof(char));
        strncpy(name, arg, n_len);
        name[n_len] = '\0';

        c_len = strlen(arg) - n_len;
        command = calloc(c_len + 1, sizeof(char));
        strncpy(command, arg + n_len + 1, c_len);
    }


    printf("alias invoked with '%s' and '%s'\n", name, command);

    char *p_name = NULL;

    if(name[0] == '\'' && name[n_len - 1] == '\''){
        p_name = calloc(n_len - 1, sizeof(char));
        strncpy(p_name, name + 1, n_len);
        p_name[n_len - 1] = '\0';
    }
    else if(name[0] == '\'' && name[n_len - 1] != '\''){
        p_name = calloc(n_len, sizeof(char));
        strncpy(p_name, name + 1, n_len);
    }
    else if(name[0] != '\'' && name[n_len - 1] == '\''){
        p_name = calloc(n_len, sizeof(char));
        strncpy(p_name, name, n_len - 1);
        p_name[n_len - 1] = '\0';
    }

    char *p_command = NULL;

    if(command[0] == '\'' && name[c_len - 1] == '\''){
        p_command = calloc(c_len - 1, sizeof(char));
        strncpy(p_command, command, c_len);
        p_command[c_len - 1] = '\0';
    }
    else if(command[0] == '\'' && name[n_len - 1] != '\''){
        p_command = calloc(c_len, sizeof(char));
        strncpy(p_command, name + 1, c_len);
    }

    printf("aliased '%s' to '%s'\n", p_name, p_command);

    return hashmap_set(alias_hashmap, p_name, p_command);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r13
movl $0x3d, %esi
callq 0x10b0
testq %rax, %rax
je 0x1a56
movq %rax, %r15
subq %r13, %r15
leaq 0x1(%r15), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1060
movb $0x0, (%r14,%r15)
movq %r13, %rdi
callq 0x1090
movq %rax, %rbx
subq %r15, %rbx
leaq 0x1(%rbx), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, %r12
leaq (%r15,%r13), %rsi
incq %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x1060
jmp 0x1a61
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r15d, %r15d
leaq 0x5fe(%rip), %rdi       # 0x2066
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x10c0
movb (%r14), %al
cmpb $0x27, %al
jne 0x1ab5
cmpb $0x27, -0x1(%r14,%r15)
jne 0x1aa1
leaq -0x1(%r15), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, %r13
leaq 0x1(%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
jmp 0x1adf
cmpb $0x27, %al
jne 0x1ab5
cmpb $0x27, -0x1(%r15,%r14)
jne 0x1b6c
cmpb $0x27, %al
je 0x1aec
cmpb $0x27, -0x1(%r14,%r15)
jne 0x1aec
leaq -0x1(%r15), %rax
movq %rax, -0x30(%rbp)
movl $0x1, %esi
movq %r15, %rdi
callq 0x10e0
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
callq 0x1060
movb $0x0, -0x1(%r13,%r15)
jmp 0x1aef
xorl %r13d, %r13d
movb (%r12), %al
cmpb $0x27, %al
jne 0x1b32
cmpb $0x27, -0x1(%r14,%rbx)
jne 0x1b26
leaq -0x1(%rbx), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1060
movb $0x0, -0x1(%r15,%rbx)
jmp 0x1b35
cmpb $0x27, %al
jne 0x1b32
cmpb $0x27, -0x1(%r15,%r14)
jne 0x1b90
xorl %r15d, %r15d
leaq 0x54c(%rip), %rdi       # 0x2088
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10c0
movq 0x2590(%rip), %rdi      # 0x40e0
movq %r13, %rsi
movq %r15, %rdx
callq 0x1532
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %esi
movq %r15, %rdi
callq 0x10e0
movq %rax, %r13
leaq 0x1(%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x1060
jmp 0x1aef
movl $0x1, %esi
movq %rbx, %rdi
callq 0x10e0
movq %rax, %r15
incq %r14
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1060
jmp 0x1b35