#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*/ u1_csort_swap(int *, int *);
void u1_ins_sort(int *a, const long long len) {
  int *x = a + 1, *y;
  for (; x < a + len; x++)
    for (y = x; y > a && (*(y) < *((y - 1))); y--)
      u1_csort_swap(y, y - 1);
}


x86 assembly (clang, -O0):
<u1_ins_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    11be <u1_ins_sort+0xae>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
jbe    1176 <u1_ins_sort+0x66>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
cmp    -0x4(%rcx),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1186 <u1_ins_sort+0x76>
jmp    11a8 <u1_ins_sort+0x98>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0xfffffffffffffffc,%rsi
call   1030 <u1_csort_swap@plt>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
jmp    1150 <u1_ins_sort+0x40>
jmp    11ad <u1_ins_sort+0x9d>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <u1_ins_sort+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u1_ins_sort>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%rsi
jl     116d <u1_ins_sort+0x5d>
mov    %rdi,%r14
lea    (%rdi,%rsi,4),%r15
lea    0x4(%rdi),%r12
jmp    1139 <u1_ins_sort+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x4,%r12
cmp    %r15,%r12
jae    116d <u1_ins_sort+0x5d>
cmp    %r14,%r12
jbe    1130 <u1_ins_sort+0x20>
mov    %r12,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rdi),%eax
cmp    -0x4(%rdi),%eax
jge    1130 <u1_ins_sort+0x20>
lea    -0x4(%rdi),%rbx
mov    %rbx,%rsi
call   1030 <u1_csort_swap@plt>
mov    %rbx,%rdi
cmp    %r14,%rbx
ja     1150 <u1_ins_sort+0x40>
jmp    1130 <u1_ins_sort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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