#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 test_qsort_strings(char const **, char const **, int);
int test_qsort_strings_presorted(void) {
  const char *expect[] = {"AA", "BB", "CC", "DD", "EE"};
  const char *in_str[] = {"AA", "BB", "CC", "DD", "EE"};
  return test_qsort_strings(in_str, expect, 5);
}


x86 assembly (clang, -O0):
<test_qsort_strings_presorted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xec1(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xe7a(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe72(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe62(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe5a(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x5,%edx
call   1040 <test_qsort_strings@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_qsort_strings_presorted>:
sub    $0x58,%rsp
lea    0xee5(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xedc(%rip),%rcx
mov    %rcx,0x38(%rsp)
lea    0xed3(%rip),%rdx
mov    %rdx,0x40(%rsp)
lea    0xeca(%rip),%rsi
mov    %rsi,0x48(%rsp)
lea    0xec1(%rip),%rdi
mov    %rdi,0x50(%rsp)
mov    %rax,(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x20(%rsp)
mov    %rsp,%rdi
lea    0x30(%rsp),%rsi
mov    $0x5,%edx
call   1030 <test_qsort_strings@plt>
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"AA\00"
@.str.1 = [3 x i8] c"BB\00"
@.str.2 = [3 x i8] c"CC\00"
@.str.3 = [3 x i8] c"DD\00"
@.str.4 = [3 x i8] c"EE\00"
define i32 @test_qsort_strings_presorted() {
%1 = alloca [5 x i8*]
%2 = alloca [5 x i8*]
%3 = bitcast [5 x i8*]* %1 to i8*
%4 = bitcast i8* %3 to [5 x i8*]*
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8** %9
%10 = bitcast [5 x i8*]* %2 to i8*
%11 = bitcast i8* %10 to [5 x i8*]*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
%19 = call i32 @test_qsort_strings(i8** %17, i8** %18, i32 5)
ret i32 %19
}

LLVM IR (-O2):
@.str = [3 x i8] c"AA\00"
@.str.1 = [3 x i8] c"BB\00"
@.str.2 = [3 x i8] c"CC\00"
@.str.3 = [3 x i8] c"DD\00"
@.str.4 = [3 x i8] c"EE\00"
define i32 @test_qsort_strings_presorted() {
%1 = alloca [5 x i8*]
%2 = alloca [5 x i8*]
%3 = bitcast [5 x i8*]* %1 to i8*
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = bitcast [5 x i8*]* %2 to i8*
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %14
%15 = call i32 @test_qsort_strings(i8** %10, i8** %4, i32 5)
ret i32 %15
}