#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 */
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ sorter_sqrt_sort_swap_1(scalar_t__ *, scalar_t__ *);
void sorter_sqrt_sort_sort_ins(int64_t *arr, int len) {
  int i, j;
  for (i = 1; i < len; i++) {
    for (j = i - 1; j >= 0 && ((*(arr + (j + 1))) - (*(arr + j))) < 0; j--) {
      sorter_sqrt_sort_swap_1(arr + j, arr + (j + 1));
    }
  }
}


x86 assembly (clang, -O0):
<sorter_sqrt_sort_sort_ins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <sorter_sqrt_sort_sort_ins+0xb9>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jl     1171 <sorter_sqrt_sort_sort_ins+0x61>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
sub    (%rcx,%rdx,8),%rax
cmp    $0x0,%rax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1181 <sorter_sqrt_sort_sort_ins+0x71>
jmp    11b6 <sorter_sqrt_sort_sort_ins+0xa6>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <sorter_sqrt_sort_swap_1@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <sorter_sqrt_sort_sort_ins+0x2b>
jmp    11bb <sorter_sqrt_sort_sort_ins+0xab>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <sorter_sqrt_sort_sort_ins+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorter_sqrt_sort_sort_ins>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%esi
jl     1176 <sorter_sqrt_sort_sort_ins+0x66>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x1,%r15d
mov    $0x2,%r12d
jmp    114d <sorter_sqrt_sort_sort_ins+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0x1,%r12d
cmp    %r14d,%r15d
je     1176 <sorter_sqrt_sort_sort_ins+0x66>
mov    %r12d,%ebp
mov    %ebp,%eax
lea    -0x1(%rax),%ebp
add    $0xfffffffe,%eax
mov    (%rbx,%rbp,8),%rcx
cmp    (%rbx,%rax,8),%rcx
jge    1140 <sorter_sqrt_sort_sort_ins+0x30>
lea    (%rbx,%rbp,8),%rsi
lea    (%rbx,%rax,8),%rdi
call   1030 <sorter_sqrt_sort_swap_1@plt>
cmp    $0x1,%ebp
jg     1150 <sorter_sqrt_sort_sort_ins+0x40>
jmp    1140 <sorter_sqrt_sort_sort_ins+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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