#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 */
typedef int /*<<< orphan*/ const wchar_t;

/* Variables and functions */
void wstr_naive_sort(wchar_t **array, size_t count,
                     int (*comp)(const wchar_t *, const wchar_t *)) {
  wchar_t *addrI = NULL;
  wchar_t *addrJ = NULL;
  wchar_t *tmp;
  for (size_t i = 0; i < count; ++i) {
    for (size_t j = i + 1; j < count; ++j) {
      addrI = *(array + i);
      addrJ = *(array + j);
      if (comp(addrI, addrJ) > 0) {
        tmp = addrI;
        array[i] = addrJ;
        array[j] = tmp;
      }
    }
  }
}


x86 assembly (clang, -O0):
<wstr_naive_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11df <wstr_naive_sort+0xdf>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c9 <wstr_naive_sort+0xc9>
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   *%rax
cmp    $0x0,%eax
jle    11b3 <wstr_naive_sort+0xb3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11b8 <wstr_naive_sort+0xb8>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1146 <wstr_naive_sort+0x46>
jmp    11ce <wstr_naive_sort+0xce>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    112c <wstr_naive_sort+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wstr_naive_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
test   %rsi,%rsi
je     1179 <wstr_naive_sort+0x79>
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebp,%ebp
jmp    113a <wstr_naive_sort+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%rbp
cmp    %r15,%rbp
je     1179 <wstr_naive_sort+0x79>
lea    0x1(%rbp),%rax
mov    %rax,0x8(%rsp)
cmp    %r15,%rax
jae    1130 <wstr_naive_sort+0x30>
mov    0x8(%rsp),%r14
jmp    1159 <wstr_naive_sort+0x59>
nop
add    $0x1,%r14
cmp    %r15,%r14
jae    1130 <wstr_naive_sort+0x30>
mov    (%r12,%rbp,8),%r13
mov    (%r12,%r14,8),%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   *0x10(%rsp)
test   %eax,%eax
jle    1150 <wstr_naive_sort+0x50>
mov    %rbx,(%r12,%rbp,8)
mov    %r13,(%r12,%r14,8)
jmp    1150 <wstr_naive_sort+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @wstr_naive_sort(i32** %0, i64 %1, i32 (i32*, i32*)* %2) {
%4 = alloca i32**
%5 = alloca i64
%6 = alloca i32 (i32*, i32*)*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
store i32** %0, i32*** %4
store i64 %1, i64* %5
store i32 (i32*, i32*)* %2, i32 (i32*, i32*)** %6
store i32* null, i32** %7
store i32* null, i32** %8
store i64 0, i64* %10
br label %12
12: ; preds = %52, %3
%13 = load i64, i64* %10
%14 = load i64, i64* %5
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i64, i64* %10
%18 = add i64 %17, 1
store i64 %18, i64* %11
br label %19
19: ; preds = %48, %16
%20 = load i64, i64* %11
%21 = load i64, i64* %5
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %51
23: ; preds = %19
%24 = load i32**, i32*** %4
%25 = load i64, i64* %10
%26 = getelementptr inbounds i32*, i32** %24, i64 %25
%27 = load i32*, i32** %26
store i32* %27, i32** %7
%28 = load i32**, i32*** %4
%29 = load i64, i64* %11
%30 = getelementptr inbounds i32*, i32** %28, i64 %29
%31 = load i32*, i32** %30
store i32* %31, i32** %8
%32 = load i32 (i32*, i32*)*, i32 (i32*, i32*)** %6
%33 = load i32*, i32** %7
%34 = load i32*, i32** %8
%35 = call i32 %32(i32* %33, i32* %34)
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %23
%38 = load i32*, i32** %7
store i32* %38, i32** %9
%39 = load i32*, i32** %8
%40 = load i32**, i32*** %4
%41 = load i64, i64* %10
%42 = getelementptr inbounds i32*, i32** %40, i64 %41
store i32* %39, i32** %42
%43 = load i32*, i32** %9
%44 = load i32**, i32*** %4
%45 = load i64, i64* %11
%46 = getelementptr inbounds i32*, i32** %44, i64 %45
store i32* %43, i32** %46
br label %47
47: ; preds = %37, %23
br label %48
48: ; preds = %47
%49 = load i64, i64* %11
%50 = add i64 %49, 1
store i64 %50, i64* %11
br label %19
51: ; preds = %19
br label %52
52: ; preds = %51
%53 = load i64, i64* %10
%54 = add i64 %53, 1
store i64 %54, i64* %10
br label %12
55: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @wstr_naive_sort(i32** nocapture %0, i64 %1, i32 (i32*, i32*)* nocapture %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %7, label %8
5: ; preds = %22, %8
%6 = icmp eq i64 %10, %1
br i1 %6, label %7, label %8
7: ; preds = %5, %3
ret void
8: ; preds = %3, %5
%9 = phi i64 [ %10, %5 ], [ 0, %3 ]
%10 = add nuw i64 %9, 1
%11 = icmp ult i64 %10, %1
br i1 %11, label %12, label %5
12: ; preds = %8
%13 = getelementptr inbounds i32*, i32** %0, i64 %9
br label %14
14: ; preds = %12, %22
%15 = phi i64 [ %10, %12 ], [ %23, %22 ]
%16 = load i32*, i32** %13
%17 = getelementptr inbounds i32*, i32** %0, i64 %15
%18 = load i32*, i32** %17
%19 = tail call i32 %2(i32* %16, i32* %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
store i32* %18, i32** %13
store i32* %16, i32** %17
br label %22
22: ; preds = %14, %21
%23 = add nuw i64 %15, 1
%24 = icmp ult i64 %23, %1
br i1 %24, label %14, label %5
}