#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*/ char_pointer_array_swap(char **, int, int);
scalar_t__ strcmp(char *, char *);
void string_sort(char *string_pointer_array[], int left, int right) {
  int element, last;
  if (left >= right)
    return;
  char_pointer_array_swap(string_pointer_array, left, (left + right) / 2);
  last = left;
  for (element = left + 1; element <= right; element++)
    if (strcmp(string_pointer_array[element], string_pointer_array[left]) < 0)
      char_pointer_array_swap(string_pointer_array, ++last, element);
  char_pointer_array_swap(string_pointer_array, left, last);
  string_sort(string_pointer_array, left, last - 1);
  string_sort(string_pointer_array, last + 1, right);
}


x86 assembly (clang, -O0):
<string_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1153 <string_sort+0x23>
jmp    120c <string_sort+0xdc>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1050 <char_pointer_array_swap@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11d9 <string_sort+0xa9>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    11c6 <string_sort+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
mov    -0x14(%rbp),%edx
call   1050 <char_pointer_array_swap@plt>
jmp    11cb <string_sort+0x9b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <string_sort+0x4e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <char_pointer_array_swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1030 <string_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <string_sort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    %edx,%esi
jge    11f0 <string_sort+0xc0>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r12
movslq %edx,%r13
mov    %r14,0x10(%rsp)
jmp    118d <string_sort+0x5d>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    0x8(%rsp),%rbp
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <char_pointer_array_swap@plt>
lea    -0x1(%rbx),%edx
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <string_sort@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
mov    0x10(%rsp),%r14
cmp    %r14d,%ebx
jge    11f0 <string_sort+0xc0>
lea    (%r14,%rbp,1),%eax
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <char_pointer_array_swap@plt>
mov    %ebp,%ebx
mov    %rbp,0x8(%rsp)
cmp    %r14d,%ebp
jge    1160 <string_sort+0x30>
mov    0x8(%rsp),%rbx
movslq %ebx,%r15
lea    0x1(%rbx),%ebp
mov    %r15,%r14
jmp    11c8 <string_sort+0x98>
add    $0x1,%ebp
cmp    %r14,%r13
je     1160 <string_sort+0x30>
mov    0x8(%r12,%r14,8),%rdi
add    $0x1,%r14
mov    (%r12,%r15,8),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jns    11c0 <string_sort+0x90>
add    $0x1,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <char_pointer_array_swap@plt>
jmp    11c0 <string_sort+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @string_sort(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = icmp sge i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %3
br label %64
13: ; preds = %3
%14 = load i8**, i8*** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = add nsw i32 %16, %17
%19 = sdiv i32 %18, 2
%20 = call i32 @char_pointer_array_swap(i8** %14, i32 %15, i32 %19)
%21 = load i32, i32* %5
store i32 %21, i32* %8
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %24
24: ; preds = %48, %13
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %51
28: ; preds = %24
%29 = load i8**, i8*** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %33, i8* %38)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %28
%42 = load i8**, i8*** %4
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
%45 = load i32, i32* %7
%46 = call i32 @char_pointer_array_swap(i8** %42, i32 %44, i32 %45)
br label %47
47: ; preds = %41, %28
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %24
51: ; preds = %24
%52 = load i8**, i8*** %4
%53 = load i32, i32* %5
%54 = load i32, i32* %8
%55 = call i32 @char_pointer_array_swap(i8** %52, i32 %53, i32 %54)
%56 = load i8**, i8*** %4
%57 = load i32, i32* %5
%58 = load i32, i32* %8
%59 = sub nsw i32 %58, 1
%60 = load i8**, i8*** %4
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %6
br label %64
64: ; preds = %51, %12
ret void
}

LLVM IR (-O2):
define void @string_sort(i8** %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
br i1 %4, label %5, label %38
5: ; preds = %3
%6 = sext i32 %2 to i64
br label %7
7: ; preds = %5, %32
%8 = phi i32 [ %36, %32 ], [ %1, %5 ]
%9 = add nsw i32 %8, %2
%10 = sdiv i32 %9, 2
%11 = tail call i32 @char_pointer_array_swap(i8** %0, i32 %8, i32 %10)
%12 = icmp slt i32 %8, %2
br i1 %12, label %13, label %32
13: ; preds = %7
%14 = sext i32 %8 to i64
%15 = getelementptr inbounds i8*, i8** %0, i64 %14
br label %16
16: ; preds = %13, %29
%17 = phi i64 [ %14, %13 ], [ %19, %29 ]
%18 = phi i32 [ %8, %13 ], [ %30, %29 ]
%19 = add nsw i64 %17, 1
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
%22 = load i8*, i8** %15
%23 = tail call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %16
%26 = add nsw i32 %18, 1
%27 = trunc i64 %19 to i32
%28 = tail call i32 @char_pointer_array_swap(i8** %0, i32 %26, i32 %27)
br label %29
29: ; preds = %16, %25
%30 = phi i32 [ %26, %25 ], [ %18, %16 ]
%31 = icmp eq i64 %19, %6
br i1 %31, label %32, label %16
32: ; preds = %29, %7
%33 = phi i32 [ %8, %7 ], [ %30, %29 ]
%34 = tail call i32 @char_pointer_array_swap(i8** %0, i32 %8, i32 %33)
%35 = add nsw i32 %33, -1
tail call void @string_sort(i8** %0, i32 %8, i32 %35)
%36 = add nsw i32 %33, 1
%37 = icmp slt i32 %36, %2
br i1 %37, label %7, label %38
38: ; preds = %32, %3
ret void
}