#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ check_sorted(void **, int /*<<< orphan*/);
int /*<<< orphan*/ print_array(void **, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ ptr_array_sort(void **, int /*<<< orphan*/);
void test_sort(void **a, uint32_t n) {
  printf("input:  ");
  print_array(a, n);
  ptr_array_sort(a, n);
  printf("output: ");
  print_array(a, n);
  check_sorted(a, n);
  printf("\n");
}


x86 assembly (clang, -O0):
<test_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <print_array@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <ptr_array_sort@plt>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <print_array@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <check_sorted@plt>
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sort>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea1(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <print_array@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <ptr_array_sort@plt>
lea    0xe8a(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <print_array@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <check_sorted@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"input: \00"
@.str.1 = [9 x i8] c"output: \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @test_sort(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = load i8**, i8*** %3
%7 = load i32, i32* %4
%8 = call i32 @print_array(i8** %6, i32 %7)
%9 = load i8**, i8*** %3
%10 = load i32, i32* %4
%11 = call i32 @ptr_array_sort(i8** %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8**, i8*** %3
%14 = load i32, i32* %4
%15 = call i32 @print_array(i8** %13, i32 %14)
%16 = load i8**, i8*** %3
%17 = load i32, i32* %4
%18 = call i32 @check_sorted(i8** %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"input: \00"
@.str.1 = [9 x i8] c"output: \00"
define void @test_sort(i8** %0, i32 %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @print_array(i8** %0, i32 %1)
%5 = tail call i32 @ptr_array_sort(i8** %0, i32 %1)
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @print_array(i8** %0, i32 %1)
%8 = tail call i32 @check_sorted(i8** %0, i32 %1)
%9 = tail call i32 @putchar(i32 10)
ret void
}