#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*/ frame();
int /*<<< orphan*/ swap(int *, int, int);
void sort_insertion(int array[360]) {
  for (int i = 1; i < 360; i++) {
    for (int j = i; j > 0 && array[j - 1] > array[j]; j--) {
      swap(array, j, j - 1);
    }
    frame();
  }
}


x86 assembly (clang, -O0):
<sort_insertion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x168,-0xc(%rbp)
jge    11bb <sort_insertion+0x9b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jle    1176 <sort_insertion+0x56>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1186 <sort_insertion+0x66>
jmp    11a6 <sort_insertion+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
call   1040 <swap@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <sort_insertion+0x26>
mov    $0x0,%al
call   1030 <frame@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <sort_insertion+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_insertion>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%ebp
jmp    1152 <sort_insertion+0x32>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <frame@plt>
add    $0x1,%ebp
cmp    $0x168,%ebp
je     1189 <sort_insertion+0x69>
mov    %ebp,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%r15),%ebx
mov    (%r14,%rbx,4),%eax
mov    %r15d,%ecx
cmp    (%r14,%rcx,4),%eax
jle    1140 <sort_insertion+0x20>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1040 <swap@plt>
cmp    $0x1,%r15d
mov    %ebx,%r15d
jg     1160 <sort_insertion+0x40>
jmp    1140 <sort_insertion+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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