#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*/ swap(int *, int *);
void insertionSort(int *Array, int size) {
  int i = 1, j;
  while (i < size) {
    j = i;
    while (j > 0) {
      if (Array[j] < Array[j - 1])
        swap(&Array[j], &Array[j - 1]);
      j = j - 1;
    }
    i = i + 1;
  }
}


x86 assembly (clang, -O0):
<insertionSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <insertionSort+0x96>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1198 <insertionSort+0x88>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    118a <insertionSort+0x7a>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <insertionSort+0x28>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <insertionSort+0x16>
add    $0x20,%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     1187 <insertionSort+0x77>
mov    %rdi,%r14
mov    %esi,%eax
mov    %rax,(%rsp)
lea    0x4(%rdi),%r12
mov    $0x1,%r13d
mov    $0x2,%r15d
jmp    1152 <insertionSort+0x42>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
add    $0x1,%r15
add    $0x4,%r12
cmp    (%rsp),%r13
je     1187 <insertionSort+0x77>
mov    %r12,%rbx
mov    %r15,%rbp
jmp    116e <insertionSort+0x5e>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbp
add    $0xfffffffffffffffc,%rbx
cmp    $0x1,%rbp
jle    1140 <insertionSort+0x30>
mov    (%rbx),%ecx
lea    -0x2(%rbp),%eax
cmp    (%r14,%rax,4),%ecx
jge    1160 <insertionSort+0x50>
lea    (%r14,%rax,4),%rsi
mov    %rbx,%rdi
call   1030 <swap@plt>
jmp    1160 <insertionSort+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @insertionSort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 1, i32* %5
br label %7
7: ; preds = %43, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %46
11: ; preds = %7
%12 = load i32, i32* %5
store i32 %12, i32* %6
br label %13
13: ; preds = %40, %11
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %3
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
%27 = load i32, i32* %26
%28 = icmp slt i32 %21, %27
br i1 %28, label %29, label %40
29: ; preds = %16
%30 = load i32*, i32** %3
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32*, i32** %3
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %34, i64 %37
%39 = call i32 @swap(i32* %33, i32* %38)
br label %40
40: ; preds = %29, %16
%41 = load i32, i32* %6
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %6
br label %13
43: ; preds = %13
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %7
46: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @insertionSort(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %21
%7 = phi i64 [ 1, %4 ], [ %22, %21 ]
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ %7, %6 ], [ %12, %19 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i64 %9, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = icmp slt i32 %11, %15
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @swap(i32* %10, i32* %14)
br label %19
19: ; preds = %17, %8
%20 = icmp sgt i64 %9, 1
br i1 %20, label %8, label %21
21: ; preds = %19
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %6
24: ; preds = %21, %2
ret void
}