#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*/ bucket_sort(float *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main() {
  float array[100];
  int n = 100;
  int j, k;
  for (k = 0; k < n; k++) {
    array[k] = (double)(rand() % 1000) / 1000;
  }
  bucket_sort(array, n);
  for (j = 0; j < n; j++) {
    printf("%f ", array[j]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x1a4(%rbp)
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    11af <main+0x7f>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xe7d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x1ac(%rbp),%rax
movss  %xmm0,-0x1a0(%rbp,%rax,4)
ff ff
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    1156 <main+0x26>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1040 <bucket_sort@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    1213 <main+0xe3>
movslq -0x1a8(%rbp),%rax
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xe10(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11cb <main+0x9b>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe7c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1150 <main+0x10>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1050 <bucket_sort@plt>
xor    %ebx,%ebx
lea    0xe5b(%rip),%r14
nopl   (%rax)
movss  (%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x float]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %3
store i32 0, i32* %5
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 1000
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 1.000000e+03
%15 = fptrunc double %14 to float
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %17
store float %15, float* %18
br label %19
19: ; preds = %10
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %6
22: ; preds = %6
%23 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i32 @bucket_sort(float* %23, i32 %24)
store i32 0, i32* %4
br label %26
26: ; preds = %37, %22
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %32
%34 = load float, float* %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %26
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f \00"
define i32 @main() {
%1 = alloca [100 x float]
%2 = bitcast [100 x float]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %11, %3 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 1000
%7 = sitofp i32 %6 to double
%8 = fdiv double %7, 1.000000e+03
%9 = fptrunc double %8 to float
%10 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 %4
store float %9, float* %10
%11 = add nuw nsw i64 %4, 1
%12 = icmp eq i64 %11, 100
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 0
%15 = call i32 @bucket_sort(float* %14, i32 100)
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ 0, %13 ], [ %22, %16 ]
%18 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 %17
%19 = load float, float* %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %20)
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, 100
br i1 %23, label %24, label %16
24: ; preds = %16
%25 = call i32 @putchar(i32 10)
ret i32 0
}