// File: /workspace/github_c_makefile_star2_O2/msteveb[P]autosetup/./jimsh0.c
// Function: ListSortElements
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)
{
    struct lsort_info *prev_info;

    typedef int (qsort_comparator) (const void *, const void *);
    int (*fn) (Jim_Obj **, Jim_Obj **);
    Jim_Obj **vector;
    int len;
    int rc;

    JimPanic((Jim_IsShared(listObjPtr), "ListSortElements called with shared object"));
    SetListFromAny(interp, listObjPtr);


    prev_info = sort_info;
    sort_info = info;

    vector = listObjPtr->internalRep.listValue.ele;
    len = listObjPtr->internalRep.listValue.len;
    switch (info->type) {
        case JIM_LSORT_ASCII:
            fn = ListSortString;
            break;
        case JIM_LSORT_NOCASE:
            fn = ListSortStringNoCase;
            break;
        case JIM_LSORT_INTEGER:
            fn = ListSortInteger;
            break;
        case JIM_LSORT_REAL:
            fn = ListSortReal;
            break;
        case JIM_LSORT_COMMAND:
            fn = ListSortCommand;
            break;
        case JIM_LSORT_DICT:
            fn = ListSortDict;
            break;
        default:
            fn = NULL;
            JimPanic((1, "ListSort called with invalid sort type"));
            return -1;
    }

    if (info->indexc) {

        info->subfn = fn;
        fn = ListSortIndexHelper;
    }

    if ((rc = setjmp(info->jmpbuf)) == 0) {
        qsort(vector, len, sizeof(Jim_Obj *), (qsort_comparator *) fn);

        if (info->unique && len > 1) {
            ListRemoveDuplicates(listObjPtr, fn);
        }

        Jim_InvalidateStringRep(listObjPtr);
    }
    sort_info = prev_info;

    return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r15
callq 0xd4da
movq 0x13ad8(%rip), %rbx     # 0x332a8
movq %r12, 0x13ad1(%rip)     # 0x332a8
movl 0xd8(%r12), %eax
cmpq $0x5, %rax
ja 0x1f8e4
movq 0x18(%r15), %rdx
movslq 0x20(%r15), %r14
leaq 0x13558(%rip), %rcx     # 0x32d50
movq (%rcx,%rax,8), %r13
cmpl $0x0, 0xe8(%r12)
movq %rdx, -0x50(%rbp)
je 0x1f81a
movq %r13, 0xf0(%r12)
leaq 0x46b(%rip), %r13       # 0x1fc85
movq %r12, %rdi
callq 0x62d0
testl %eax, %eax
jne 0x1f911
movl %eax, -0x3c(%rbp)
movq %rbx, -0x58(%rbp)
pushq $0x8
popq %rdx
movq -0x50(%rbp), %rdi
movq %r14, %rsi
movq %r13, -0x30(%rbp)
movq %r13, %rcx
callq 0x6100
cmpl $0x0, 0xec(%r12)
setne %al
cmpl $0x2, %r14d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1f902
movq %r15, -0x48(%rbp)
movq 0x18(%r15), %rdx
leaq 0x8(%rdx), %r12
xorl %ebx, %ebx
pushq $0x1
popq %r15
movq -0x30(%rbp), %rcx
movq %rdx, -0x38(%rbp)
movq -0x48(%rbp), %rax
movslq 0x20(%rax), %rax
cmpq %rax, %r15
jge 0x1f8e9
movslq %ebx, %r13
leaq (%rdx,%r13,8), %r14
movq %r14, %rdi
movq %r12, %rsi
callq *%rcx
testl %eax, %eax
je 0x1f8a6
incl %ebx
movslq %ebx, %r13
jmp 0x1f8cb
movq (%r14), %rsi
movl 0x10(%rsi), %eax
movl %eax, %ecx
decl %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1f8cb
movq 0x139e9(%rip), %rax     # 0x332a8
movq 0xd0(%rax), %rdi
callq 0x73bf
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%r12), %rax
movq %rax, (%rdx,%r13,8)
incq %r15
addq $0x8, %r12
jmp 0x1f87f
pushq $-0x1
popq %rax
jmp 0x1f918
incl %ebx
cmpl %eax, %ebx
jge 0x1f8fa
movq (%r12), %rax
movslq %ebx, %rcx
movq %rax, (%rdx,%rcx,8)
movq -0x48(%rbp), %r15
movl %ebx, 0x20(%r15)
movq %r15, %rdi
callq 0x94f7
movq -0x58(%rbp), %rbx
movl -0x3c(%rbp), %eax
movq %rbx, 0x13990(%rip)     # 0x332a8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq