// File: /workspace/github_c_makefile_star2_O3/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 0xe2fe
movq 0x14b93(%rip), %rbx     # 0x372a8
movq %r12, 0x14b8c(%rip)     # 0x372a8
movl 0xd8(%r12), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq $0x5, %rax
ja 0x228a0
movq 0x18(%r15), %rcx
movq %rcx, -0x40(%rbp)
movslq 0x20(%r15), %r14
leaq 0x1460a(%rip), %rcx     # 0x36d50
movq (%rcx,%rax,8), %r13
cmpl $0x0, 0xe8(%r12)
je 0x22764
movq %r13, 0xf0(%r12)
leaq 0x4eb(%rip), %r13       # 0x22c4f
movq %r12, %rdi
callq 0x62d0
testl %eax, %eax
jne 0x22897
movl %eax, -0x2c(%rbp)
movq %rbx, -0x58(%rbp)
movl $0x8, %edx
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rcx
callq 0x6100
cmpl $0x0, 0xec(%r12)
setne %al
cmpl $0x2, %r14d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x22865
movq 0x18(%r15), %rsi
movq %r15, -0x38(%rbp)
movl 0x20(%r15), %ecx
cmpl $0x2, %ecx
jl 0x22843
movq %r13, -0x50(%rbp)
xorl %ebx, %ebx
movl $0x1, %edx
movl $0x8, %r13d
movq %rsi, -0x48(%rbp)
movq %rdx, %r15
movslq %ebx, %r12
leaq (%rsi,%r12,8), %r14
addq %r13, %rsi
movq %r14, %rdi
callq *-0x50(%rbp)
testl %eax, %eax
je 0x227f5
incl %ebx
movslq %ebx, %r12
jmp 0x2281a
movq (%r14), %rsi
movl 0x10(%rsi), %eax
movl %eax, %ecx
decl %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x2281a
movq 0x14a9a(%rip), %rax     # 0x372a8
movq 0xd0(%rax), %rdi
callq 0x758c
movq -0x48(%rbp), %rsi
movq (%rsi,%r15,8), %rcx
movq %rcx, (%rsi,%r12,8)
incq %r15
movq -0x38(%rbp), %rcx
movslq 0x20(%rcx), %rcx
addq $0x8, %r13
movq %r15, %rdx
cmpq %rcx, %r15
jl 0x227d7
movl %ebx, %eax
incl %eax
jmp 0x2284e
movl $0x1, %r15d
movl $0x1, %eax
cmpl %ecx, %eax
jge 0x2285d
movq (%rsi,%r15,8), %rcx
movslq %eax, %rdx
movq %rcx, (%rsi,%rdx,8)
movq -0x38(%rbp), %r15
movl %eax, 0x20(%r15)
movq (%r15), %rdi
testq %rdi, %rdi
sete %al
leaq 0x14a23(%rip), %rcx     # 0x37298
cmpq %rcx, %rdi
sete %cl
orb %al, %cl
jne 0x22889
xorl %eax, %eax
movl %eax, %esi
callq *0x149ff(%rip)          # 0x37288
movq $0x0, (%r15)
movq -0x58(%rbp), %rbx
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq %rbx, 0x14a08(%rip)     # 0x372a8
movl %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq