#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
scalar_t__ malloc(int);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void insertionsort(char **array, int strMax) {
  char *current;
  int position;
  int i;
  for (i = 1; i < strMax; i++) {
    current = (char *)malloc(sizeof(array[i]));
    strcpy(current, array[i]);
    position = i;
    while ((position > 0) && (strcasecmp(array[position - 1], current) > 0)) {
      strcpy(array[position], array[position - 1]);
      --position;
    }
    strcpy(array[position], current);
    int count;
    for (count = 0; count < strMax; count++) {
    }
  }
}


x86 assembly (clang, -O0):
<insertionsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123c <insertionsort+0x10c>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x25(%rbp)
jle    11ae <insertionsort+0x7e>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
setg   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11be <insertionsort+0x8e>
jmp    11ee <insertionsort+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <insertionsort+0x4b>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1229 <insertionsort+0xf9>
jmp    121b <insertionsort+0xeb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120a <insertionsort+0xda>
jmp    122e <insertionsort+0xfe>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1146 <insertionsort+0x16>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertionsort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     11d8 <insertionsort+0xa8>
mov    %rdi,%r15
mov    %esi,%eax
mov    %rax,(%rsp)
mov    $0x1,%r12d
jmp    1179 <insertionsort+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %r13d,%rax
mov    (%r15,%rax,8),%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r12
cmp    (%rsp),%r12
je     11d8 <insertionsort+0xa8>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    (%r15,%r12,8),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %r12,%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%r13),%rbp
mov    %ebp,%eax
mov    (%r15,%rax,8),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jle    1160 <insertionsort+0x30>
mov    (%r15,%r13,8),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0x1(%rbp),%rax
mov    %rbp,%r13
cmp    $0x1,%rax
jg     11a0 <insertionsort+0x70>
xor    %r13d,%r13d
jmp    1160 <insertionsort+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @insertionsort(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i32 1, i32* %7
br label %9
9: ; preds = %71, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %74
13: ; preds = %9
%14 = call i64 @malloc(i32 8)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = load i8**, i8*** %3
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %16, i8* %21)
%23 = load i32, i32* %7
store i32 %23, i32* %6
br label %24
24: ; preds = %39, %13
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i8**, i8*** %3
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %28, i64 %31
%33 = load i8*, i8** %32
%34 = load i8*, i8** %5
%35 = call i64 @strcasecmp(i8* %33, i8* %34)
%36 = icmp sgt i64 %35, 0
br label %37
37: ; preds = %27, %24
%38 = phi i1 [ false, %24 ], [ %36, %27 ]
br i1 %38, label %39, label %54
39: ; preds = %37
%40 = load i8**, i8*** %3
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %3
%46 = load i32, i32* %6
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %45, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @strcpy(i8* %44, i8* %50)
%52 = load i32, i32* %6
%53 = add nsw i32 %52, -1
store i32 %53, i32* %6
br label %24
54: ; preds = %37
%55 = load i8**, i8*** %3
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = load i8*, i8** %5
%61 = call i32 @strcpy(i8* %59, i8* %60)
store i32 0, i32* %8
br label %62
62: ; preds = %67, %54
%63 = load i32, i32* %8
%64 = load i32, i32* %4
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %70
66: ; preds = %62
br label %67
67: ; preds = %66
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %62
70: ; preds = %62
br label %71
71: ; preds = %70
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
br label %9
74: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @insertionsort(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %35
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %26
%7 = phi i64 [ 1, %4 ], [ %33, %26 ]
%8 = tail call i64 @malloc(i32 8)
%9 = inttoptr i64 %8 to i8*
%10 = getelementptr inbounds i8*, i8** %0, i64 %7
%11 = load i8*, i8** %10
%12 = tail call i32 @strcpy(i8* %9, i8* %11)
br label %13
13: ; preds = %6, %21
%14 = phi i64 [ %7, %6 ], [ %15, %21 ]
%15 = add nsw i64 %14, -1
%16 = and i64 %15, 4294967295
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @strcasecmp(i8* %18, i8* %9)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %13
%22 = getelementptr inbounds i8*, i8** %0, i64 %14
%23 = load i8*, i8** %22
%24 = tail call i32 @strcpy(i8* %23, i8* %18)
%25 = icmp sgt i64 %14, 1
br i1 %25, label %13, label %26
26: ; preds = %21, %13
%27 = phi i64 [ 0, %21 ], [ %14, %13 ]
%28 = shl i64 %27, 32
%29 = ashr exact i64 %28, 32
%30 = getelementptr inbounds i8*, i8** %0, i64 %29
%31 = load i8*, i8** %30
%32 = tail call i32 @strcpy(i8* %31, i8* %9)
%33 = add nuw nsw i64 %7, 1
%34 = icmp eq i64 %33, %5
br i1 %34, label %35, label %6
35: ; preds = %26, %2
ret void
}