#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 */
scalar_t__ bubblesort(float *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, ...);
int main(void) {
  int num;
  float arr[100];
  printf("Enter number of elements: ");
  if (scanf("%d", &num) != 0) {
    for (size_t i = 0; i < num; i++) {
      if (scanf("%f", &arr[i]) != 0) {
      } else {
        printf("Please enter appropriate input!");
        goto end;
      }
    }
    if (bubblesort(arr, num)) {
      for (size_t i = 0; i < num; i++) {
        printf("%.2f\n", arr[i]);
      }
    } else {
      printf("Sort failed\n");
      goto end;
    }
  } else {
    printf("Please enter appropriate input!");
    goto end;
  }
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     127a <main+0x14a>
movq   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11ec <main+0xbc>
mov    -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11bd <main+0x8d>
jmp    11d0 <main+0xa0>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1292 <main+0x162>
jmp    11d5 <main+0xa5>
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
jmp    1177 <main+0x47>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <bubblesort@plt>
cmp    $0x0,%rax
je     1262 <main+0x132>
movq   $0x0,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    125d <main+0x12d>
mov    -0x1b0(%rbp),%rax
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
jmp    1210 <main+0xe0>
jmp    1275 <main+0x145>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1292 <main+0x162>
jmp    128d <main+0x15d>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1292 <main+0x162>
jmp    1292 <main+0x162>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xeab(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %rax,%rax
je     1204 <main+0xc4>
cmpl   $0x0,0xc(%rsp)
je     11b4 <main+0x74>
lea    0x10(%rsp),%r12
lea    0xe90(%rip),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %rax,%rax
je     1204 <main+0xc4>
add    $0x1,%rbx
movslq 0xc(%rsp),%r14
add    $0x4,%r12
cmp    %r14,%rbx
jb     1190 <main+0x50>
lea    0x10(%rsp),%rdi
mov    %r14d,%esi
call   1060 <bubblesort@plt>
test   %rax,%rax
je     1214 <main+0xd4>
cmpl   $0x0,0xc(%rsp)
je     1220 <main+0xe0>
xor    %ebx,%ebx
lea    0xe6b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movss  0x10(%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jb     11e0 <main+0xa0>
jmp    1220 <main+0xe0>
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0xe0>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [32 x i8] c"Please enter appropriate input!\00"
@.str.4 = [6 x i8] c"%.2f\0A\00"
@.str.5 = [13 x i8] c"Sort failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x float]
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %0
store i64 0, i64* %4
br label %10
10: ; preds = %24, %9
%11 = load i64, i64* %4
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %11, %13
br i1 %14, label %15, label %27
15: ; preds = %10
%16 = load i64, i64* %4
%17 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %16
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %54
23: ; preds = %20
br label %24
24: ; preds = %23
%25 = load i64, i64* %4
%26 = add i64 %25, 1
store i64 %26, i64* %4
br label %10
27: ; preds = %10
%28 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 0
%29 = load i32, i32* %2
%30 = call i64 @bubblesort(float* %28, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %48
32: ; preds = %27
store i64 0, i64* %5
br label %33
33: ; preds = %44, %32
%34 = load i64, i64* %5
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = icmp ult i64 %34, %36
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i64, i64* %5
%40 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %39
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %42)
br label %44
44: ; preds = %38
%45 = load i64, i64* %5
%46 = add i64 %45, 1
store i64 %46, i64* %5
br label %33
47: ; preds = %33
br label %50
48: ; preds = %27
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %54
50: ; preds = %47
br label %53
51: ; preds = %0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %54
53: ; preds = %50
br label %54
54: ; preds = %53, %51, %48, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [32 x i8] c"Please enter appropriate input!\00"
@.str.4 = [6 x i8] c"%.2f\0A\00"
@str = [12 x i8] c"Sort failed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x float]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x float]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %43, label %8
8: ; preds = %0
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %23, label %15
11: ; preds = %15
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %20, %13
br i1 %14, label %15, label %23
15: ; preds = %8, %11
%16 = phi i64 [ %20, %11 ], [ 0, %8 ]
%17 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %16
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %17)
%19 = icmp eq i64 %18, 0
%20 = add nuw i64 %16, 1
br i1 %19, label %21, label %11
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %45
23: ; preds = %11, %8
%24 = phi i32 [ 0, %8 ], [ %12, %11 ]
%25 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%26 = call i64 @bubblesort(float* %25, i32 %24)
%27 = icmp eq i64 %26, 0
br i1 %27, label %41, label %28
28: ; preds = %23
%29 = load i32, i32* %1
%30 = icmp eq i32 %29, 0
br i1 %30, label %45, label %31
31: ; preds = %28, %31
%32 = phi i64 [ %37, %31 ], [ 0, %28 ]
%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* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %35)
%37 = add nuw i64 %32, 1
%38 = load i32, i32* %1
%39 = sext i32 %38 to i64
%40 = icmp ult i64 %37, %39
br i1 %40, label %31, label %45
41: ; preds = %23
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %45
43: ; preds = %0
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %31, %28, %21, %41, %43
ret i32 0
}