#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*/ printf(char *);
void bubble_sortf(float *array, size_t len) {
  if (!array || len <= 0) {
    printf("invalid parament\n");
    return;
  }
  do {
    float *s = (float *)array;
    float *e = s + len - 1;
    float *p, *q;
    for (q = e; q > s; q--) {
      for (p = s; p < q; p++) {
        if (p[0] > p[1]) {
          float t = p[0];
          p[0] = p[1];
          p[1] = t;
        }
      }
    }
  } while (0);
}


x86 assembly (clang, -O0):
<bubble_sortf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1136 <bubble_sortf+0x26>
cmpq   $0x0,-0x10(%rbp)
ja     1147 <bubble_sortf+0x37>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <bubble_sortf+0xfa>
jmp    114c <bubble_sortf+0x3c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1205 <bubble_sortf+0xf5>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    11ef <bubble_sortf+0xdf>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x28(%rbp),%rax
ucomiss 0x4(%rax),%xmm0
jbe    11d9 <bubble_sortf+0xc9>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,0x4(%rax)
jmp    11de <bubble_sortf+0xce>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <bubble_sortf+0x79>
jmp    11f4 <bubble_sortf+0xe4>
mov    -0x30(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x30(%rbp)
jmp    1173 <bubble_sortf+0x63>
jmp    120a <bubble_sortf+0xfa>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bubble_sortf>:
test   %rdi,%rdi
je     1174 <bubble_sortf+0x64>
test   %rsi,%rsi
je     1174 <bubble_sortf+0x64>
lea    (%rdi,%rsi,4),%rax
add    $0xfffffffffffffffc,%rax
jmp    1134 <bubble_sortf+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xfffffffffffffffc,%rax
cmp    %rdi,%rax
jbe    1180 <bubble_sortf+0x70>
movss  (%rdi),%xmm0
mov    %rdi,%rdx
jmp    1161 <bubble_sortf+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm1,(%rdx)
movss  %xmm0,0x4(%rdx)
mov    %rcx,%rdx
cmp    %rax,%rcx
jae    1130 <bubble_sortf+0x20>
lea    0x4(%rdx),%rcx
movss  0x4(%rdx),%xmm1
ucomiss %xmm1,%xmm0
ja     1150 <bubble_sortf+0x40>
movaps %xmm1,%xmm0
jmp    1159 <bubble_sortf+0x49>
lea    0xe85(%rip),%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@.str = [18 x i8] c"invalid parament\0A\00"
define void @bubble_sortf(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float
store float* %0, float** %3
store i64 %1, i64* %4
%10 = load float*, float** %3
%11 = icmp ne float* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i64, i64* %4
%14 = icmp ule i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %2
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %64
17: ; preds = %12
br label %18
18: ; preds = %17
%19 = load float*, float** %3
store float* %19, float** %5
%20 = load float*, float** %5
%21 = load i64, i64* %4
%22 = getelementptr inbounds float, float* %20, i64 %21
%23 = getelementptr inbounds float, float* %22, i64 -1
store float* %23, float** %6
%24 = load float*, float** %6
store float* %24, float** %8
br label %25
25: ; preds = %60, %18
%26 = load float*, float** %8
%27 = load float*, float** %5
%28 = icmp ugt float* %26, %27
br i1 %28, label %29, label %63
29: ; preds = %25
%30 = load float*, float** %5
store float* %30, float** %7
br label %31
31: ; preds = %56, %29
%32 = load float*, float** %7
%33 = load float*, float** %8
%34 = icmp ult float* %32, %33
br i1 %34, label %35, label %59
35: ; preds = %31
%36 = load float*, float** %7
%37 = getelementptr inbounds float, float* %36, i64 0
%38 = load float, float* %37
%39 = load float*, float** %7
%40 = getelementptr inbounds float, float* %39, i64 1
%41 = load float, float* %40
%42 = fcmp ogt float %38, %41
br i1 %42, label %43, label %55
43: ; preds = %35
%44 = load float*, float** %7
%45 = getelementptr inbounds float, float* %44, i64 0
%46 = load float, float* %45
store float %46, float* %9
%47 = load float*, float** %7
%48 = getelementptr inbounds float, float* %47, i64 1
%49 = load float, float* %48
%50 = load float*, float** %7
%51 = getelementptr inbounds float, float* %50, i64 0
store float %49, float* %51
%52 = load float, float* %9
%53 = load float*, float** %7
%54 = getelementptr inbounds float, float* %53, i64 1
store float %52, float* %54
br label %55
55: ; preds = %43, %35
br label %56
56: ; preds = %55
%57 = load float*, float** %7
%58 = getelementptr inbounds float, float* %57, i32 1
store float* %58, float** %7
br label %31
59: ; preds = %31
br label %60
60: ; preds = %59
%61 = load float*, float** %8
%62 = getelementptr inbounds float, float* %61, i32 -1
store float* %62, float** %8
br label %25
63: ; preds = %25
br label %64
64: ; preds = %15, %63
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c"invalid parament\00"
define void @bubble_sortf(float* %0, i64 %1) {
%3 = icmp eq float* %0, null
%4 = icmp eq i64 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %28
8: ; preds = %2
%9 = getelementptr inbounds float, float* %0, i64 %1
%10 = getelementptr inbounds float, float* %9, i64 -1
%11 = icmp ugt float* %10, %0
br i1 %11, label %15, label %28
12: ; preds = %25
%13 = getelementptr inbounds float, float* %16, i64 -1
%14 = icmp ugt float* %13, %0
br i1 %14, label %15, label %28
15: ; preds = %8, %12
%16 = phi float* [ %13, %12 ], [ %10, %8 ]
%17 = load float, float* %0
br label %18
18: ; preds = %15, %25
%19 = phi float [ %26, %25 ], [ %17, %15 ]
%20 = phi float* [ %21, %25 ], [ %0, %15 ]
%21 = getelementptr inbounds float, float* %20, i64 1
%22 = load float, float* %21
%23 = fcmp ogt float %19, %22
br i1 %23, label %24, label %25
24: ; preds = %18
store float %22, float* %20
store float %19, float* %21
br label %25
25: ; preds = %18, %24
%26 = phi float [ %22, %18 ], [ %19, %24 ]
%27 = icmp ult float* %21, %16
br i1 %27, label %18, label %12
28: ; preds = %12, %8, %6
ret void
}