#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ qsort_aligned(void *, size_t, size_t,
                                 int (*)(void const *, void const *));
int /*<<< orphan*/ qsort_nonaligned(void *, size_t, size_t,
                                    int (*)(void const *, void const *));
int /*<<< orphan*/ qsort_words(void *, size_t,
                               int (*)(void const *, void const *));
extern void SDL_qsort(void *base, size_t nmemb, size_t size,
                      int (*compare)(const void *, const void *)) {
  if (nmemb <= 1)
    return;
  if (((int)base | size) & (sizeof(int) - 1))
    qsort_nonaligned(base, nmemb, size, compare);
  else if (size != sizeof(int))
    qsort_aligned(base, nmemb, size, compare);
  else
    qsort_words(base, nmemb, compare);
}


x86 assembly (clang, -O0):
<SDL_qsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x1,-0x10(%rbp)
ja     1158 <SDL_qsort+0x28>
jmp    11c5 <SDL_qsort+0x95>
mov    -0x8(%rbp),%rax
cltq
or     -0x18(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     118a <SDL_qsort+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <qsort_nonaligned@plt>
jmp    11c5 <SDL_qsort+0x95>
cmpq   $0x4,-0x18(%rbp)
je     11af <SDL_qsort+0x7f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <qsort_aligned@plt>
jmp    11c0 <SDL_qsort+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <qsort_words@plt>
jmp    11c5 <SDL_qsort+0x95>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SDL_qsort>:
cmp    $0x2,%rsi
jae    1137 <SDL_qsort+0x7>
ret
mov    %edi,%eax
or     %edx,%eax
test   $0x3,%al
je     1144 <SDL_qsort+0x14>
jmp    1040 <qsort_nonaligned@plt>
cmp    $0x4,%rdx
jne    1152 <SDL_qsort+0x22>
mov    %rcx,%rdx
jmp    1030 <qsort_words@plt>
jmp    1050 <qsort_aligned@plt>

LLVM IR (-O0):
define void @SDL_qsort(i8* %0, i64 %1, i64 %2, i32 (i8*, i8*)* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32 (i8*, i8*)*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32 (i8*, i8*)* %3, i32 (i8*, i8*)** %8
%9 = load i64, i64* %6
%10 = icmp ule i64 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %4
br label %41
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = ptrtoint i8* %13 to i32
%15 = sext i32 %14 to i64
%16 = load i64, i64* %7
%17 = or i64 %15, %16
%18 = and i64 %17, 3
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %12
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %8
%25 = call i32 @qsort_nonaligned(i8* %21, i64 %22, i64 %23, i32 (i8*, i8*)* %24)
br label %41
26: ; preds = %12
%27 = load i64, i64* %7
%28 = icmp ne i64 %27, 4
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = load i64, i64* %6
%32 = load i64, i64* %7
%33 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %8
%34 = call i32 @qsort_aligned(i8* %30, i64 %31, i64 %32, i32 (i8*, i8*)* %33)
br label %40
35: ; preds = %26
%36 = load i8*, i8** %5
%37 = load i64, i64* %6
%38 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %8
%39 = call i32 @qsort_words(i8* %36, i64 %37, i32 (i8*, i8*)* %38)
br label %40
40: ; preds = %35, %29
br label %41
41: ; preds = %11, %40, %20
ret void
}

LLVM IR (-O2):
define void @SDL_qsort(i8* %0, i64 %1, i64 %2, i32 (i8*, i8*)* %3) {
%5 = icmp ult i64 %1, 2
br i1 %5, label %19, label %6
6: ; preds = %4
%7 = ptrtoint i8* %0 to i64
%8 = or i64 %7, %2
%9 = and i64 %8, 3
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @qsort_nonaligned(i8* %0, i64 %1, i64 %2, i32 (i8*, i8*)* %3)
br label %19
13: ; preds = %6
%14 = icmp eq i64 %2, 4
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @qsort_aligned(i8* %0, i64 %1, i64 %2, i32 (i8*, i8*)* %3)
br label %19
17: ; preds = %13
%18 = tail call i32 @qsort_words(i8* %0, i64 %1, i32 (i8*, i8*)* %3)
br label %19
19: ; preds = %15, %17, %4, %11
ret void
}