// File: /workspace/github_c_makefile_star2_O2/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, -0x40(%rbp)
movl %esi, %r15d
movq %rdi, -0x38(%rbp)
xorl %r14d, %r14d
movl $0x1001, %esi           # imm = 0x1001
xorl %edi, %edi
callq *0x1fa06(%rip)          # 0x33288
movq %rax, %r12
movb $0x0, (%rax)
testl %r15d, %r15d
cmovlel %r14d, %r15d
xorl %ebx, %ebx
cmpq %r14, %r15
je 0x13934
movq -0x40(%rbp), %rax
movq (%rax,%r14,8), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x7fc7
movzbl (%rax), %ecx
cmpl $0x2f, %ecx
je 0x138e9
cmpl $0x2e, %ecx
jne 0x138cd
movzbl 0x1(%rax), %ecx
testl %ecx, %ecx
je 0x138e4
cmpl $0x2f, %ecx
jne 0x138cd
addq $0x2, %rax
addl $-0x2, -0x2c(%rbp)
testq %rbx, %rbx
je 0x138e9
cmpb $0x2f, -0x1(%r12,%rbx)
je 0x138eb
movb $0x2f, (%r12,%rbx)
incq %rbx
jmp 0x138eb
testq %rbx, %rbx
jne 0x1392c
xorl %ebx, %ebx
movslq -0x2c(%rbp), %r13
testq %r13, %r13
je 0x13916
leaq (%r12,%rbx), %rdi
leaq (%rdi,%r13), %rcx
subq %r12, %rcx
cmpq $0x1000, %rcx           # imm = 0x1000
jge 0x13970
movq %rax, %rsi
movq %r13, %rdx
callq 0x6320
addq %r13, %rbx
cmpq $0x2, %rbx
jl 0x1392c
cmpb $0x2f, -0x1(%r12,%rbx)
jne 0x1392c
decq %rbx
movb $0x0, (%r12,%rbx)
incq %r14
jmp 0x13891
movb $0x0, (%r12,%rbx)
movq -0x38(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0xa654
movq %rax, %rbx
incl 0x10(%rax)
movq (%r14), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x13969
movq %r14, %rdi
callq 0x73bf
movq %rbx, (%r14)
xorl %eax, %eax
jmp 0x139b6
movq %r12, %rdi
xorl %esi, %esi
callq *0x1f90d(%rip)          # 0x33288
leaq 0x13e25(%rip), %rsi     # 0x277a7
pushq $-0x1
popq %rdx
movq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x7363
movq %rax, %rbx
incl 0x10(%rax)
movq (%r14), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x139b0
movq %r14, %rdi
callq 0x73bf
movq %rbx, (%r14)
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq