// File: /workspace/github_c_makefile_star2_O3/msteveb[P]autosetup/./jimsh0.c
// Function: file_cmd_join
static int file_cmd_join(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    int i;
    char *newname = Jim_Alloc(MAXPATHLEN + 1);
    char *last = newname;

    *newname = 0;


    for (i = 0; i < argc; i++) {
        int len;
        const char *part = Jim_GetString(argv[i], &len);

        if (*part == '/') {

            last = newname;
        }
        else if (ISWINDOWS && strchr(part, ':')) {

            last = newname;
        }
        else if (part[0] == '.') {
            if (part[1] == '/') {
                part += 2;
                len -= 2;
            }
            else if (part[1] == 0 && last != newname) {

                continue;
            }
        }


        if (last != newname && last[-1] != '/') {
            *last++ = '/';
        }

        if (len) {
            if (last + len - newname >= MAXPATHLEN) {
                Jim_Free(newname);
                Jim_SetResultString(interp, "Path too long", -1);
                return JIM_ERR;
            }
            memcpy(last, part, len);
            last += len;
        }


        if (last > newname + 1 && last[-1] == '/') {

            if (!ISWINDOWS || !(last > newname + 2 && last[-2] == ':')) {
                *--last = 0;
            }
        }
    }

    *last = 0;



    Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));

    return JIM_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, -0x38(%rbp)
movl %esi, %r14d
movq %rdi, -0x30(%rbp)
movl $0x1001, %esi           # imm = 0x1001
xorl %edi, %edi
callq *0x21f47(%rip)          # 0x37288
movq %rax, %r12
movb $0x0, (%rax)
movl $0x0, %r13d
testl %r14d, %r14d
jle 0x15407
movl %r14d, %ebx
xorl %r15d, %r15d
xorl %r13d, %r13d
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %r14
movq (%r14), %rsi
testq %rsi, %rsi
jne 0x1537c
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%r14), %rsi
movl 0x14(%r14), %eax
movzbl (%rsi), %ecx
cmpl $0x2f, %ecx
je 0x153bd
cmpl $0x2e, %ecx
jne 0x153a1
movzbl 0x1(%rsi), %ecx
testl %ecx, %ecx
je 0x153b8
cmpl $0x2f, %ecx
jne 0x153a1
addq $0x2, %rsi
addl $-0x2, %eax
testq %r13, %r13
je 0x153bd
cmpb $0x2f, -0x1(%r12,%r13)
je 0x153c0
movb $0x2f, (%r12,%r13)
incq %r13
jmp 0x153c0
testq %r13, %r13
jne 0x153fb
xorl %r13d, %r13d
testl %eax, %eax
je 0x153e5
leaq (%r12,%r13), %rdi
movslq %eax, %r14
leaq (%rdi,%r14), %rax
subq %r12, %rax
cmpq $0x1000, %rax           # imm = 0x1000
jge 0x15458
movq %r14, %rdx
callq 0x6320
addq %r14, %r13
cmpq $0x2, %r13
jl 0x153fb
cmpb $0x2f, -0x1(%r12,%r13)
jne 0x153fb
decq %r13
movb $0x0, (%r12,%r13)
incq %r15
cmpq %r15, %rbx
jne 0x1535f
movb $0x0, (%r12,%r13)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0xaee8
movq %rax, %r15
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
movl $0x0, %r14d
jg 0x15443
movq %rbx, %rdi
callq 0x758c
movq %r15, (%rbx)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
xorl %esi, %esi
callq *0x21e25(%rip)          # 0x37288
leaq 0x162ed(%rip), %rsi     # 0x2b757
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7508
movq %rax, %r15
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
movl $0x1, %r14d
cmpl $0x2, %eax
jl 0x1543b
jmp 0x15443