#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 insertionSort1(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);
      else
        break;
    }
  }
}


x86 assembly (clang, -O0):
<insertionSort1>:
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    11c2 <insertionSort1+0xb2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11af <insertionSort1+0x9f>
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    1197 <insertionSort1+0x87>
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    119c <insertionSort1+0x8c>
jmp    11af <insertionSort1+0x9f>
jmp    11a1 <insertionSort1+0x91>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <insertionSort1+0x30>
jmp    11b4 <insertionSort1+0xa4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <insertionSort1+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertionSort1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%esi
jl     1174 <insertionSort1+0x64>
mov    %esi,%r14d
mov    %rdi,%rbx
add    $0xffffffff,%r14d
xor    %r15d,%r15d
mov    $0x2,%r12d
jmp    1149 <insertionSort1+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12d
cmp    %r14d,%r15d
je     1174 <insertionSort1+0x64>
add    $0x1,%r15d
mov    %r12d,%ebp
mov    %ebp,%eax
lea    -0x1(%rax),%ebp
mov    (%rbx,%rbp,4),%ecx
add    $0xfffffffe,%eax
cmp    (%rbx,%rax,4),%ecx
jge    1140 <insertionSort1+0x30>
lea    (%rbx,%rbp,4),%rdi
lea    -0x4(%rdi),%rsi
call   1030 <swap@plt>
cmp    $0x1,%ebp
jg     1150 <insertionSort1+0x40>
jmp    1140 <insertionSort1+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @insertionSort1(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 = %48, %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 %51
12: ; preds = %7
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %6
br label %15
15: ; preds = %44, %12
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %47
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 %43
42: ; preds = %18
br label %47
43: ; preds = %31
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, -1
store i32 %46, i32* %6
br label %15
47: ; preds = %42, %15
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %7
51: ; preds = %7
ret void
}

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