#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*/ assert(int);
float *bucket_sort(float *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("bucket sort\n");
  float expected[10] = {.12, .17, .21, .23, .26, .39, .68, .72, .78, .94};
  float arr[10] = {.78, .17, .39, .26, .72, .94, .21, .12, .23, .68};
  float *result = bucket_sort(arr, 10);
  for (int i = 0; i < 10; i++) {
    printf("expected: %f actual: %f\n", expected[i], result[i]);
    assert(expected[i] == result[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xec8(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xee3(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1050 <bucket_sort@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
cmpl   $0xa,-0x6c(%rbp)
jge    120d <main+0xcd>
movslq -0x6c(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x68(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe3d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movslq -0x6c(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x6c(%rbp),%rcx
ucomiss (%rax,%rcx,4),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11a0 <main+0x60>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf73(%rip),%rdi
call   1030 <puts@plt>
mov    0xf46(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xf2a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xf0e(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1060 <bucket_sort@plt>
mov    %rax,%rbx
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm1
lea    0xf13(%rip),%r14
movsd  0xe63(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xea1(%rip),%xmm0
cmpeqss (%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x4(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe34(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xe6e(%rip),%xmm0
cmpeqss 0x4(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x8(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe04(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xe3a(%rip),%xmm0
cmpeqss 0x8(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0xc(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xdd4(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xe06(%rip),%xmm0
cmpeqss 0xc(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x10(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xda4(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xdd2(%rip),%xmm0
cmpeqss 0x10(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x14(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xd74(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xd9e(%rip),%xmm0
cmpeqss 0x14(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x18(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xd44(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xd6a(%rip),%xmm0
cmpeqss 0x18(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x1c(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xd14(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xd36(%rip),%xmm0
cmpeqss 0x1c(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x20(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xce4(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xd02(%rip),%xmm0
cmpeqss 0x20(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
movss  0x24(%rbx),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xcb4(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xcce(%rip),%xmm0
cmpeqss 0x24(%rbx),%xmm0
movd   %xmm0,%edi
and    $0x1,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"bucket sort\0A\00"
@__const.main.expected = [10 x float] [float 0x3FBEB851E0000000, float 0x3FC5C28F60000000, float 0x3FCAE147A0000000, float 0x3FCD70A3E0000000, float 0x3FD0A3D700000000, float 0x3FD8F5C280000000, float 0x3FE5C28F60000000, float 0x3FE70A3D80000000, float 0x3FE8F5C280000000, float 0x3FEE147AE0000000]
@__const.main.arr = [10 x float] [float 0x3FE8F5C280000000, float 0x3FC5C28F60000000, float 0x3FD8F5C280000000, float 0x3FD0A3D700000000, float 0x3FE70A3D80000000, float 0x3FEE147AE0000000, float 0x3FCAE147A0000000, float 0x3FBEB851E0000000, float 0x3FCD70A3E0000000, float 0x3FE5C28F60000000]
@.str.1 = [25 x i8] c"expected: %f actual: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x float]
%3 = alloca [10 x float]
%4 = alloca float*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [10 x float]* %2 to i8*
%8 = bitcast [10 x float]* %3 to i8*
%9 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%10 = call float* @bucket_sort(float* %9, i32 10)
store float* %10, float** %4
store i32 0, i32* %5
br label %11
11: ; preds = %39, %0
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %42
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %16
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = load float*, float** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
%24 = load float, float* %23
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %19, double %25)
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %28
%30 = load float, float* %29
%31 = load float*, float** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = load float, float* %34
%36 = fcmp oeq float %30, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
br label %39
39: ; preds = %14
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %11
42: ; preds = %11
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@__const.main.arr = [10 x float] [float 0x3FE8F5C280000000, float 0x3FC5C28F60000000, float 0x3FD8F5C280000000, float 0x3FD0A3D700000000, float 0x3FE70A3D80000000, float 0x3FEE147AE0000000, float 0x3FCAE147A0000000, float 0x3FBEB851E0000000, float 0x3FCD70A3E0000000, float 0x3FE5C28F60000000]
@.str.1 = [25 x i8] c"expected: %f actual: %f\0A\00"
@str = [12 x i8] c"bucket sort\00"
define i32 @main() {
%1 = alloca [10 x float]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%3 = bitcast [10 x float]* %1 to i8*
%4 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 0
%5 = call float* @bucket_sort(float* %4, i32 10)
%6 = load float, float* %5
%7 = fpext float %6 to double
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FBEB851E0000000, double %7)
%9 = load float, float* %5
%10 = fcmp oeq float %9, 0x3FBEB851E0000000
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds float, float* %5, i64 1
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FC5C28F60000000, double %15)
%17 = load float, float* %13
%18 = fcmp oeq float %17, 0x3FC5C28F60000000
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds float, float* %5, i64 2
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FCAE147A0000000, double %23)
%25 = load float, float* %21
%26 = fcmp oeq float %25, 0x3FCAE147A0000000
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds float, float* %5, i64 3
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FCD70A3E0000000, double %31)
%33 = load float, float* %29
%34 = fcmp oeq float %33, 0x3FCD70A3E0000000
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = getelementptr inbounds float, float* %5, i64 4
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FD0A3D700000000, double %39)
%41 = load float, float* %37
%42 = fcmp oeq float %41, 0x3FD0A3D700000000
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = getelementptr inbounds float, float* %5, i64 5
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FD8F5C280000000, double %47)
%49 = load float, float* %45
%50 = fcmp oeq float %49, 0x3FD8F5C280000000
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = getelementptr inbounds float, float* %5, i64 6
%54 = load float, float* %53
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FE5C28F60000000, double %55)
%57 = load float, float* %53
%58 = fcmp oeq float %57, 0x3FE5C28F60000000
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = getelementptr inbounds float, float* %5, i64 7
%62 = load float, float* %61
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FE70A3D80000000, double %63)
%65 = load float, float* %61
%66 = fcmp oeq float %65, 0x3FE70A3D80000000
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = getelementptr inbounds float, float* %5, i64 8
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FE8F5C280000000, double %71)
%73 = load float, float* %69
%74 = fcmp oeq float %73, 0x3FE8F5C280000000
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = getelementptr inbounds float, float* %5, i64 9
%78 = load float, float* %77
%79 = fpext float %78 to double
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double 0x3FEE147AE0000000, double %79)
%81 = load float, float* %77
%82 = fcmp oeq float %81, 0x3FEE147AE0000000
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
ret i32 0
}