// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %r12
movq %rsi, %r15
callq 0xe338
movq 0x15301(%rip), %rbx     # 0x382a8
movq %r12, 0x152fa(%rip)     # 0x382a8
movl 0xd8(%r12), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq $0x5, %rax
ja 0x23127
movq 0x18(%r15), %rcx
movq %rcx, -0x40(%rbp)
movslq 0x20(%r15), %r14
leaq 0x14d78(%rip), %rcx     # 0x37d50
movq (%rcx,%rax,8), %r13
cmpl $0x0, 0xe8(%r12)
je 0x22ff6
movq %r13, 0xf0(%r12)
leaq 0x52b(%rip), %r13       # 0x23521
movq %r12, %rdi
callq 0x62d0
testl %eax, %eax
jne 0x2311e
movl %eax, -0x2c(%rbp)
movq %rbx, -0x50(%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 0x230ec
movq 0x18(%r15), %r12
movq %r15, -0x38(%rbp)
movl 0x20(%r15), %ecx
cmpl $0x2, %ecx
jl 0x230ca
movq %r13, -0x48(%rbp)
xorl %ebx, %ebx
movl $0x1, %edx
movl $0x8, %r13d
movq %rdx, %r15
movslq %ebx, %rax
leaq (%r12,%rax,8), %r14
leaq (%r12,%r13), %rsi
movq %r14, %rdi
callq *-0x48(%rbp)
testl %eax, %eax
je 0x2307d
incl %ebx
jmp 0x230a2
movq (%r14), %rsi
movl 0x10(%rsi), %eax
movl %eax, %ecx
decl %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x230a2
movq 0x15212(%rip), %rax     # 0x382a8
movq 0xd0(%rax), %rdi
callq 0x759a
movq (%r12,%r15,8), %rcx
movslq %ebx, %rdx
movq %rcx, (%r12,%rdx,8)
incq %r15
movq -0x38(%rbp), %rcx
movslq 0x20(%rcx), %rcx
addq $0x8, %r13
movq %r15, %rdx
cmpq %rcx, %r15
jl 0x23061
movl %ebx, %eax
incl %eax
jmp 0x230d5
movl $0x1, %r15d
movl $0x1, %eax
cmpl %ecx, %eax
jge 0x230e4
movq (%r12,%r15,8), %rcx
movslq %eax, %rdx
movq %rcx, (%r12,%rdx,8)
movq -0x38(%rbp), %r15
movl %eax, 0x20(%r15)
movq (%r15), %rdi
testq %rdi, %rdi
sete %al
leaq 0x1519c(%rip), %rcx     # 0x38298
cmpq %rcx, %rdi
sete %cl
orb %al, %cl
jne 0x23110
xorl %eax, %eax
movl %eax, %esi
callq *0x15178(%rip)          # 0x38288
movq $0x0, (%r15)
movq -0x50(%rbp), %rbx
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq %rbx, 0x15181(%rip)     # 0x382a8
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq