// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rdi, %rbx
xorl %r12d, %r12d
movl $0x1001, %esi           # imm = 0x1001
xorl %edi, %edi
callq *0x22ace(%rip)          # 0x38288
movq %rax, %r15
movb $0x0, (%rax)
testl %r13d, %r13d
jle 0x158dd
movl %r13d, %eax
movq %rax, -0x30(%rbp)
xorl %r14d, %r14d
xorl %r12d, %r12d
movq -0x38(%rbp), %rax
movq (%rax,%r14,8), %r13
cmpq $0x0, (%r13)
jne 0x157ef
movq 0x8(%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
movl 0x14(%r13), %eax
movq (%r13), %rsi
movzbl (%rsi), %ecx
cmpl $0x2f, %ecx
je 0x1581e
cmpl $0x2e, %ecx
jne 0x15821
movzbl 0x1(%rsi), %ecx
testl %ecx, %ecx
je 0x158bd
cmpl $0x2f, %ecx
jne 0x15821
addq $0x2, %rsi
addl $-0x2, %eax
jmp 0x15821
xorl %r12d, %r12d
testq %r12, %r12
je 0x15836
cmpb $0x2f, -0x1(%r15,%r12)
je 0x15836
movb $0x2f, (%r15,%r12)
incq %r12
testl %eax, %eax
je 0x158a3
leaq (%r15,%r12), %rdi
movslq %eax, %r13
leaq (%rdi,%r13), %rax
subq %r15, %rax
cmpq $0x1000, %rax           # imm = 0x1000
jl 0x15898
movq %r15, %rdi
xorl %esi, %esi
callq *0x22a2d(%rip)          # 0x38288
movq %rbx, %rdi
leaq 0x16f4d(%rip), %rsi     # 0x2c7b2
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
movq %rax, %r13
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1588e
movq %rbx, %rdi
callq 0x759a
movq %r13, (%rbx)
movl $0x1, %ecx
jmp 0x158cb
movq %r13, %rdx
callq 0x6320
addq %r13, %r12
xorl %ecx, %ecx
cmpq $0x2, %r12
jl 0x158cb
cmpb $0x2f, -0x1(%r15,%r12)
jne 0x158cb
decq %r12
movb $0x0, (%r15,%r12)
jmp 0x158cb
movl $0x4, %ecx
testq %r12, %r12
je 0x15821
testb $0x3, %cl
jne 0x15916
incq %r14
cmpq %r14, -0x30(%rbp)
jne 0x157d6
movb $0x0, (%r15,%r12)
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0xaf08
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1590f
movq %rbx, %rdi
callq 0x759a
movq %r14, (%rbx)
xorl %eax, %eax
jmp 0x1591b
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq