#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*/ assert(int);
int /*<<< orphan*/ bwt_sort_strings(char **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
void test_bwt_sort_strings() {
  char *strings[4] = {"1234", "abcd", "0123", "aaaa"};
  bwt_sort_strings(strings, 4);
  assert(!strcmp(strings[0], "0123"));
  assert(!strcmp(strings[1], "1234"));
  assert(!strcmp(strings[2], "aaaa"));
  assert(!strcmp(strings[3], "abcd"));
  printf("\tSort strings test passed\n");
}


x86 assembly (clang, -O0):
<test_bwt_sort_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2cb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cab(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2ca8(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1060 <bwt_sort_strings@plt>
mov    -0x20(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bwt_sort_strings>:
sub    $0x28,%rsp
movaps 0x2cc5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2ca9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
call   1060 <bwt_sort_strings@plt>
mov    (%rsp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x10(%rsp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    0x18(%rsp),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1234\00"
@.str.1 = [5 x i8] c"abcd\00"
@.str.2 = [5 x i8] c"0123\00"
@.str.3 = [5 x i8] c"aaaa\00"
@__const.test_bwt_sort_strings.strings = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [27 x i8] c"\09Sort strings test passed\0A\00"
define void @test_bwt_sort_strings() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%4 = call i32 @bwt_sort_strings(i8** %3, i32 4)
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%6 = load i8*, i8** %5
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"1234\00"
@.str.1 = [5 x i8] c"abcd\00"
@.str.2 = [5 x i8] c"0123\00"
@.str.3 = [5 x i8] c"aaaa\00"
@__const.test_bwt_sort_strings.strings = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@str = [26 x i8] c"\09Sort strings test passed\00"
define void @test_bwt_sort_strings() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%4 = call i32 @bwt_sort_strings(i8** %3, i32 4)
%5 = load i8*, i8** %3
%6 = call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* dereferenceable(1) %23, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
ret void
}