// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0x3d, %esi
callq 0x10b0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1c9b
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x1060
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rdi
callq 0x1090
subq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq -0x10(%rbp), %rsi
addq $0x1, %rsi
movq -0x18(%rbp), %rdx
callq 0x1060
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq 0x13bc(%rip), %rdi      # 0x3066
movb $0x0, %al
callq 0x10c0
movq $0x0, -0x38(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x1d1a
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x1d1a
movq -0x10(%rbp), %rdi
subq $0x1, %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movq -0x10(%rbp), %rdx
callq 0x1060
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
jmp 0x1dc0
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x1d64
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
je 0x1d64
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movq -0x10(%rbp), %rdx
callq 0x1060
jmp 0x1dbe
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
je 0x1dbc
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x1dbc
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
callq 0x1060
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
jmp 0x1dbe
jmp 0x1dc0
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x1e22
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x1e22
movq -0x18(%rbp), %rdi
subq $0x1, %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x1060
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
jmp 0x1e6c
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x1e6a
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
je 0x1e6a
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x10e0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movq -0x18(%rbp), %rdx
callq 0x1060
jmp 0x1e6c
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq 0x120d(%rip), %rdi      # 0x3088
movb $0x0, %al
callq 0x10c0
movq 0x3257(%rip), %rdi      # 0x50e0
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x14c0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)