#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*/ simple_sort_swapper(double *, double *);
void simple_sort(double ints[], int sizeofInts) {
  int limit;
  for (limit = sizeofInts - 1; limit > 0; limit--) {
    int i;
    for (i = 0; i < limit; i++) {
      if (ints[i] > ints[i + 1]) {
        simple_sort_swapper(&ints[i], &ints[i + 1]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<simple_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11b7 <simple_sort+0xa7>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a4 <simple_sort+0x94>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    1191 <simple_sort+0x81>
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 <simple_sort_swapper@plt>
jmp    1196 <simple_sort+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <simple_sort+0x29>
jmp    11a9 <simple_sort+0x99>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <simple_sort+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     1176 <simple_sort+0x66>
mov    %esi,%r15d
mov    %rdi,%r14
lea    -0x1(%r15),%r12d
add    $0x8,%r14
jmp    113a <simple_sort+0x2a>
add    $0xffffffffffffffff,%r12
cmp    $0x3,%r13d
jl     1176 <simple_sort+0x66>
mov    %r15d,%r13d
lea    -0x1(%r13),%r15d
mov    %r14,%rbx
xor    %ebp,%ebp
jmp    1159 <simple_sort+0x49>
nopl   0x0(%rax,%rax,1)
add    $0x8,%rbx
cmp    %rbp,%r12
je     1130 <simple_sort+0x20>
movsd  -0x8(%rbx),%xmm0
add    $0x1,%rbp
ucomisd (%rbx),%xmm0
jbe    1150 <simple_sort+0x40>
lea    -0x8(%rbx),%rdi
mov    %rbx,%rsi
call   1030 <simple_sort_swapper@plt>
jmp    1150 <simple_sort+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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