#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strmap_swap(char **, int *, int, int);
int strmap_part(char **strs, int *nums, int left, int mid, int right) {
  char *pivot = strs[mid];
  strmap_swap(strs, nums, mid, right);
  int sto = left, i;
  for (i = left; i < right; i++) {
    if (strcmp(strs[i], pivot) <= 0) {
      strmap_swap(strs, nums, i, sto);
      sto++;
    }
  }
  strmap_swap(strs, nums, sto, right);
  return sto;
}


x86 assembly (clang, -O0):
<strmap_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <strmap_swap@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c3 <strmap_part+0xa3>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jg     11b0 <strmap_part+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1040 <strmap_swap@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b5 <strmap_part+0x95>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1169 <strmap_part+0x49>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <strmap_swap@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmap_part>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r12d
mov    %edx,%ebp
mov    %rdi,%r15
movslq %ecx,%rdx
mov    (%rdi,%rdx,8),%r13
mov    %rsi,(%rsp)
mov    %r8d,%ecx
call   1040 <strmap_swap@plt>
cmp    %r12d,%ebp
jge    1191 <strmap_part+0x71>
movslq %ebp,%rax
lea    (%r15,%rax,8),%r14
mov    %ebp,%ebx
jmp    116c <strmap_part+0x4c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x8,%r14
cmp    %ebp,%r12d
je     1193 <strmap_part+0x73>
mov    (%r14),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jg     1160 <strmap_part+0x40>
mov    %r15,%rdi
mov    (%rsp),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <strmap_swap@plt>
add    $0x1,%ebx
jmp    1160 <strmap_part+0x40>
mov    %ebp,%ebx
mov    %r15,%rdi
mov    (%rsp),%rsi
mov    %ebx,%edx
mov    %r12d,%ecx
call   1040 <strmap_swap@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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