#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__ insertion_sort(int *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  int i, j, a[100];
  int temp = 0;
  srand(120);
  for (i = 0; i < 100; i++)
    a[i] = rand() % 100;
  if (insertion_sort(a) == 0) {
    for (i = 0; i < 100; i++)
      printf("%d\t", a[i]);
  } else
    printf("bubble sort unsuccessful!!!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1b4(%rbp)
mov    $0x78,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11a6 <main+0x66>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0x14(%rbp),%rax
mov    %edx,-0x1b0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x34>
lea    -0x1b0(%rbp),%rdi
call   1050 <insertion_sort@plt>
cmp    $0x0,%rax
jne    11f9 <main+0xb9>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11f4 <main+0xb4>
movslq -0x14(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <main+0x83>
jmp    1207 <main+0xc7>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    $0x78,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1170 <main+0x20>
mov    %rsp,%rdi
call   1060 <insertion_sort@plt>
test   %rax,%rax
je     11ba <main+0x6a>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
jmp    11e7 <main+0x97>
lea    0xe3f(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11d0 <main+0x80>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [29 x i8] c"bubble sort unsuccessful!!!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i32]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = call i32 @srand(i32 120)
store i32 0, i32* %6
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 100
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 %18
store i32 %16, i32* %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 0
%25 = call i64 @insertion_sort(i32* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %23
store i32 0, i32* %6
br label %28
28: ; preds = %37, %27
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 100
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %28
40: ; preds = %28
br label %43
41: ; preds = %23
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
@str = [28 x i8] c"bubble sort unsuccessful!!!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
%5 = tail call i32 @srand(i32 120)
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %11, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %7
store i32 %9, i32* %10
%11 = add nuw nsw i64 %7, 1
%12 = icmp eq i64 %11, 100
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%15 = call i64 @insertion_sort(i32* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %13, %17
%18 = phi i64 [ %22, %17 ], [ 0, %13 ]
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %18, 1
%23 = icmp eq i64 %22, 100
br i1 %23, label %26, label %17
24: ; preds = %13
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %17, %24
ret i32 0
}