#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 insertionSort0(int *nums, int size) {
  for (int i = 0; i < size - 1; i++) {
    for (int j = i + 1; j > 0; j--) {
      if (nums[j] < nums[j - 1])
        swap(nums + j, nums + j - 1);
    }
  }
}


x86 assembly (clang, -O0):
<insertionSort0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b8 <insertionSort0+0xa8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a5 <insertionSort0+0x95>
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    1192 <insertionSort0+0x82>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
add    $0xfffffffffffffffc,%rsi
call   1030 <swap@plt>
jmp    1197 <insertionSort0+0x87>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <insertionSort0+0x30>
jmp    11aa <insertionSort0+0x9a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <insertionSort0+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertionSort0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     1187 <insertionSort0+0x77>
mov    %rdi,%r14
mov    %esi,%eax
mov    %rax,(%rsp)
lea    0x4(%rdi),%r12
mov    $0x1,%r13d
mov    $0x2,%r15d
jmp    1152 <insertionSort0+0x42>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
add    $0x1,%r15
add    $0x4,%r12
cmp    (%rsp),%r13
je     1187 <insertionSort0+0x77>
mov    %r12,%rbx
mov    %r15,%rbp
jmp    116e <insertionSort0+0x5e>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbp
add    $0xfffffffffffffffc,%rbx
cmp    $0x1,%rbp
jle    1140 <insertionSort0+0x30>
mov    (%rbx),%eax
lea    -0x2(%rbp),%ecx
cmp    (%r14,%rcx,4),%eax
jge    1160 <insertionSort0+0x50>
lea    -0x4(%rbx),%rsi
mov    %rbx,%rdi
call   1030 <swap@plt>
jmp    1160 <insertionSort0+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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