#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*/ strcpy(char *, char *);
void Insertion_Sort(char (*str_arr)[20], char *str, int count) {
  int i = 0;
  for (i = 0; i < count; i++) {
    if (strcmp(str, str_arr[i]) < 0) {
      for (int j = count - 1; j > i; j--) {
        strcpy(str_arr[j], str_arr[j - 1]);
      }
      strcpy(str_arr[i], str);
      break;
    }
  }
  if (i == count)
    strcpy(str_arr[i - 1], str);
}


x86 assembly (clang, -O0):
<Insertion_Sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e9 <Insertion_Sort+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    11d6 <Insertion_Sort+0xb6>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11b9 <Insertion_Sort+0x99>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1178 <Insertion_Sort+0x58>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11e9 <Insertion_Sort+0xc9>
jmp    11db <Insertion_Sort+0xbb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <Insertion_Sort+0x21>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1211 <Insertion_Sort+0xf1>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Insertion_Sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r13d
mov    %rsi,%r12
mov    %rdi,%r15
test   %edx,%edx
jle    116f <Insertion_Sort+0x4f>
mov    %r13d,%r14d
xor    %ebp,%ebp
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
js     119f <Insertion_Sort+0x7f>
add    $0x1,%rbp
add    $0x14,%rbx
cmp    %rbp,%r14
jne    1150 <Insertion_Sort+0x30>
jmp    117a <Insertion_Sort+0x5a>
xor    %ebp,%ebp
cmp    %r13d,%ebp
jne    1217 <Insertion_Sort+0xf7>
add    $0xffffffff,%r13d
movslq %r13d,%rax
lea    (%rax,%rax,4),%rax
lea    (%r15,%rax,4),%rdi
mov    %r12,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>
mov    %r13,0x10(%rsp)
lea    -0x1(%r13),%eax
cmp    %ebp,%eax
mov    %r15,0x8(%rsp)
jle    11f9 <Insertion_Sort+0xd9>
mov    0x10(%rsp),%rax
movslq %eax,%r15
add    $0xffffffffffffffff,%r15
lea    -0x2(%rax),%r14d
lea    (%r15,%r15,4),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,4),%r13
xchg   %ax,%ax
movslq %r14d,%r14
lea    (%r14,%r14,4),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r13,%rdi
call   1030 <strcpy@plt>
add    $0xffffffffffffffff,%r15
add    $0xffffffff,%r14d
add    $0xffffffffffffffec,%r13
cmp    %rbp,%r15
jg     11d0 <Insertion_Sort+0xb0>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    0x8(%rsp),%r15
mov    0x10(%rsp),%r13
cmp    %r13d,%ebp
je     117a <Insertion_Sort+0x5a>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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