#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*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ swap_my(char **, int, int);
void qsort_my(char *v[], int left, int right) {
  int i = 0;
  int j = 0;
  int last = 0;
  if (left > right)
    return;
  printf("in qsort .\n");
  swap_my(v, left, (left + right) / 2);
  last = left;
  for (i = left + 1; i <= right; i++)
    if (strcmp(v[i], v[left]) < 0)
      swap_my(v, ++last, i);
  swap_my(v, left, last);
  qsort_my(v, left, last - 1);
  qsort_my(v, last + 1, right);
}


x86 assembly (clang, -O0):
<qsort_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1178 <qsort_my+0x38>
jmp    123d <qsort_my+0xfd>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
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   1060 <swap_my@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     120a <qsort_my+0xca>
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    11f7 <qsort_my+0xb7>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
mov    -0x14(%rbp),%edx
call   1060 <swap_my@plt>
jmp    11fc <qsort_my+0xbc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <qsort_my+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <swap_my@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1050 <qsort_my@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1050 <qsort_my@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qsort_my>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    %edx,%esi
jle    1161 <qsort_my+0x21>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
movslq %edx,%r12
mov    %r14,0x10(%rsp)
jmp    11ae <qsort_my+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    0x8(%rsp),%rbp
mov    %ebp,%esi
mov    %r13d,%edx
call   1060 <swap_my@plt>
lea    -0x1(%r13),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <qsort_my@plt>
lea    0x1(%r13),%ebp
mov    0x10(%rsp),%r14
cmp    %r14d,%r13d
jge    1152 <qsort_my+0x12>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
lea    (%r14,%rbp,1),%eax
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <swap_my@plt>
mov    %ebp,%r13d
mov    %rbp,0x8(%rsp)
cmp    %r14d,%ebp
jge    1180 <qsort_my+0x40>
mov    0x8(%rsp),%r13
movslq %r13d,%r15
lea    0x1(%r13),%ebp
mov    %r15,%r14
jmp    11f8 <qsort_my+0xb8>
nop
add    $0x1,%ebp
cmp    %r14,%r12
je     1180 <qsort_my+0x40>
mov    0x8(%rbx,%r14,8),%rdi
add    $0x1,%r14
mov    (%rbx,%r15,8),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jns    11f0 <qsort_my+0xb0>
add    $0x1,%r13d
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   1060 <swap_my@plt>
jmp    11f0 <qsort_my+0xb0>

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

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