#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*/ printData(int *, int);
int /*<<< orphan*/ printf(char *, int, int);
void insertionSort(int data[], int size) {
  int i, j;
  int temp;
  printf("%2c, %2c: ", 'i', 'j');
  printData(data, size);
  for (i = 1; i < size; i++) {
    temp = data[i];
    for (j = i; (j > 0) && (data[j - 1] > temp); j--) {
      data[j] = data[j - 1];
      printf("      : %2d->%2d\n", j - 1, j);
    }
    if (j != i) {
      data[j] = temp;
    }
    printf("%2d, %2d: ", i, j);
    printData(data, size);
  }
}


x86 assembly (clang, -O0):
<insertionSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x69,%esi
mov    $0x6a,%edx
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <printData@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1234 <insertionSort+0x114>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jle    11a0 <insertionSort+0x80>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b0 <insertionSort+0x90>
jmp    11ee <insertionSort+0xce>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <insertionSort+0x58>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1208 <insertionSort+0xe8>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <printData@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <insertionSort+0x38>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertionSort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec6(%rip),%rdi
mov    $0x69,%esi
mov    $0x6a,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printData@plt>
mov    %ebp,0x4(%rsp)
cmp    $0x2,%ebp
jl     1206 <insertionSort+0xe6>
mov    0x4(%rsp),%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r13d
xor    %ebp,%ebp
lea    0xe93(%rip),%r15
jmp    11b1 <insertionSort+0x91>
nopw   0x0(%rax,%rax,1)
lea    0xe96(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    0x4(%rsp),%esi
call   1040 <printData@plt>
add    $0x1,%r13
mov    0x10(%rsp),%rbp
add    $0x1,%rbp
cmp    0x8(%rsp),%r13
je     1206 <insertionSort+0xe6>
mov    (%rbx,%r13,4),%r14d
mov    %rbp,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
mov    (%rbx,%rax,4),%eax
cmp    %r14d,%eax
jle    11f0 <insertionSort+0xd0>
lea    0x1(%rbp),%r12
mov    %eax,0x4(%rbx,%rbp,4)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%r12
jg     11c0 <insertionSort+0xa0>
xor    %ebp,%ebp
jmp    11f3 <insertionSort+0xd3>
nopl   (%rax)
add    $0x1,%ebp
mov    %ebp,%eax
cmp    %rax,%r13
je     1180 <insertionSort+0x60>
movslq %ebp,%rax
mov    %r14d,(%rbx,%rax,4)
jmp    1180 <insertionSort+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"%2c, %2c: \00"
@.str.1 = [18 x i8] c" : %2d->%2d\0A\00"
@.str.2 = [11 x i8] c"%2d, %2d: \00"
define void @insertionSort(i32* %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 105, i32 106)
%4 = tail call i32 @printData(i32* %0, i32 %1)
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %40
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %34
%9 = phi i64 [ 1, %6 ], [ %38, %34 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
br label %12
12: ; preds = %8, %20
%13 = phi i64 [ %9, %8 ], [ %14, %20 ]
%14 = add nsw i64 %13, -1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = icmp sgt i32 %17, %11
%19 = trunc i64 %13 to i32
br i1 %18, label %20, label %25
20: ; preds = %12
%21 = trunc i64 %14 to i32
%22 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %17, i32* %22
%23 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %19)
%24 = icmp sgt i64 %13, 1
br i1 %24, label %12, label %27
25: ; preds = %12
%26 = trunc i64 %13 to i32
br label %27
27: ; preds = %20, %25
%28 = phi i32 [ %26, %25 ], [ 0, %20 ]
%29 = zext i32 %28 to i64
%30 = icmp eq i64 %9, %29
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = sext i32 %28 to i64
%33 = getelementptr inbounds i32, i32* %0, i64 %32
store i32 %11, i32* %33
br label %34
34: ; preds = %31, %27
%35 = trunc i64 %9 to i32
%36 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %28)
%37 = tail call i32 @printData(i32* %0, i32 %1)
%38 = add nuw nsw i64 %9, 1
%39 = icmp eq i64 %38, %7
br i1 %39, label %40, label %8
40: ; preds = %34, %2
ret void
}