// File: /workspace/github_c_makefile_star2_O0/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: sort_list(cJSON*, int)
static cJSON *sort_list(cJSON *list, const cJSON_bool case_sensitive)
{
    cJSON *first = list;
    cJSON *second = list;
    cJSON *current_item = list;
    cJSON *result = list;
    cJSON *result_tail = NULL;

    if ((list == NULL) || (list->next == NULL))
    {
        /* One entry is sorted already. */
        return result;
    }

    while ((current_item != NULL) && (current_item->next != NULL) && (compare_strings((unsigned char*)current_item->string, (unsigned char*)current_item->next->string, case_sensitive) < 0))
    {
        /* Test for list sorted. */
        current_item = current_item->next;
    }
    if ((current_item == NULL) || (current_item->next == NULL))
    {
        /* Leave sorted lists unmodified. */
        return result;
    }

    /* reset pointer to the beginning */
    current_item = list;
    while (current_item != NULL)
    {
        /* Walk two pointers to find the middle. */
        second = second->next;
        current_item = current_item->next;
        /* advances current_item two steps at a time */
        if (current_item != NULL)
        {
            current_item = current_item->next;
        }
    }
    if ((second != NULL) && (second->prev != NULL))
    {
        /* Split the lists */
        second->prev->next = NULL;
        second->prev = NULL;
    }

    /* Recursively sort the sub-lists. */
    first = sort_list(first, case_sensitive);
    second = sort_list(second, case_sensitive);
    result = NULL;

    /* Merge the sub-lists */
    while ((first != NULL) && (second != NULL))
    {
        cJSON *smaller = NULL;
        if (compare_strings((unsigned char*)first->string, (unsigned char*)second->string, case_sensitive) < 0)
        {
            smaller = first;
        }
        else
        {
            smaller = second;
        }

        if (result == NULL)
        {
            /* start merged list with the smaller element */
            result_tail = smaller;
            result = smaller;
        }
        else
        {
            /* add smaller element to the list */
            result_tail->next = smaller;
            smaller->prev = result_tail;
            result_tail = smaller;
        }

        if (first == smaller)
        {
            first = first->next;
        }
        else
        {
            second = second->next;
        }
    }

    if (first != NULL)
    {
        /* Append rest of first list. */
        if (result == NULL)
        {
            return first;
        }
        result_tail->next = first;
        first->prev = result_tail;
    }
    if (second != NULL)
    {
        /* Append rest of second list */
        if (result == NULL)
        {
            return second;
        }
        result_tail->next = second;
        second->prev = result_tail;
    }

    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xa238
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xa245
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa467
jmp 0xa247
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x49(%rbp)
je 0xa286
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x49(%rbp)
je 0xa286
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rsi
movl -0x14(%rbp), %edx
callq 0xa030
cmpl $0x0, %eax
setl %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0xa28f
jmp 0xa29c
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xa247
cmpq $0x0, -0x30(%rbp)
je 0xa2ad
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xa2ba
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa467
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xa2f3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xa2f1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xa2c2
cmpq $0x0, -0x28(%rbp)
je 0xa320
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa320
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xa1f0
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xa1f0
movq %rax, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x4a(%rbp)
je 0xa35f
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0xa36b
jmp 0xa401
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
movl -0x14(%rbp), %edx
callq 0xa030
cmpl $0x0, %eax
jge 0xa39a
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0xa3a2
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xa3bb
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xa3da
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0xa3f1
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xa3fc
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xa348
cmpq $0x0, -0x20(%rbp)
je 0xa430
cmpq $0x0, -0x38(%rbp)
jne 0xa419
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa467
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x28(%rbp)
je 0xa45f
cmpq $0x0, -0x38(%rbp)
jne 0xa448
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa467
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)