#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 *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
int main() {
  float data[3], temp = 0;
  printf("Please enter three numbers separated by spaces > ");
  scanf("%f%f%f", &data[1], &data[2], &data[3]);
  while (!((data[1] <= data[2]) && (data[2] <= data[3]))) {
    printf("Before swaps:  %f, %f, %f\n", data[1], data[2], data[3]);
    if (data[2] < data[1]) {
      temp = data[2];
      data[2] = data[1];
      data[1] = temp;
      printf("Swap 2 & 1 for %f, %f, %f\n", data[1], data[2], data[3]);
    }
    if (data[3] < data[2]) {
      temp = data[2];
      data[2] = data[3];
      data[3] = temp;
      printf("Swap 2 & 3 for %f, %f, %f\n", data[1], data[2], data[3]);
    }
    printf("After swaps: %f, %f, %f\n", data[1], data[2], data[3]);
  }
  printf("%.0f is the median\n", data[2]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rsi
add    $0x4,%rsi
lea    -0x10(%rbp),%rdx
add    $0x8,%rdx
lea    -0x10(%rbp),%rcx
add    $0xc,%rcx
lea    0xece(%rip),%rdi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
xor    %eax,%eax
ucomiss %xmm1,%xmm0
mov    %al,-0x15(%rbp)
jb     1194 <main+0x74>
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    11a6 <main+0x86>
jmp    12b1 <main+0x191>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x4(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe71(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1229 <main+0x109>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x4(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe32(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1283 <main+0x163>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x4(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdf3(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x4(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xde5(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1169 <main+0x49>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0xee3(%rip),%rdi
call   1040 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movss  0x18(%rsp),%xmm2
jb     1174 <main+0x54>
ucomiss %xmm1,%xmm2
jae    1270 <main+0x150>
lea    0xebe(%rip),%r12
lea    0xed2(%rip),%r14
lea    0xee6(%rip),%r15
lea    0xefa(%rip),%rbx
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
mov    %r12,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm1
movss  0x14(%rsp),%xmm2
ucomiss %xmm2,%xmm1
jbe    11e8 <main+0xc8>
movss  %xmm1,0x14(%rsp)
movss  %xmm2,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x18(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r14,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm2
movss  0x18(%rsp),%xmm3
ucomiss %xmm3,%xmm2
jbe    122a <main+0x10a>
movss  %xmm3,0x14(%rsp)
movss  %xmm2,0x18(%rsp)
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
cvtss2sd %xmm2,%xmm2
mov    %r15,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm2
movss  0x18(%rsp),%xmm3
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movss  0x18(%rsp),%xmm2
jb     1190 <main+0x70>
ucomiss %xmm1,%xmm2
jb     1190 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe25(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Please enter three numbers separated by spaces > \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [27 x i8] c"Before swaps: %f, %f, %f\0A\00"
@.str.3 = [27 x i8] c"Swap 2 & 1 for %f, %f, %f\0A\00"
@.str.4 = [27 x i8] c"Swap 2 & 3 for %f, %f, %f\0A\00"
@.str.5 = [25 x i8] c"After swaps: %f, %f, %f\0A\00"
@.str.6 = [20 x i8] c"%.0f is the median\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x float]
%3 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%6 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%7 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %5, float* %6, float* %7)
br label %9
9: ; preds = %82, %0
%10 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%11 = load float, float* %10
%12 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%13 = load float, float* %12
%14 = fcmp ole float %11, %13
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%17 = load float, float* %16
%18 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%19 = load float, float* %18
%20 = fcmp ole float %17, %19
br label %21
21: ; preds = %15, %9
%22 = phi i1 [ false, %9 ], [ %20, %15 ]
%23 = xor i1 %22, true
br i1 %23, label %24, label %93
24: ; preds = %21
%25 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%32 = load float, float* %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %27, double %30, double %33)
%35 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%36 = load float, float* %35
%37 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%38 = load float, float* %37
%39 = fcmp olt float %36, %38
br i1 %39, label %40, label %58
40: ; preds = %24
%41 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%42 = load float, float* %41
store float %42, float* %3
%43 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%44 = load float, float* %43
%45 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
store float %44, float* %45
%46 = load float, float* %3
%47 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
store float %46, float* %47
%48 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%49 = load float, float* %48
%50 = fpext float %49 to double
%51 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%52 = load float, float* %51
%53 = fpext float %52 to double
%54 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), double %50, double %53, double %56)
br label %58
58: ; preds = %40, %24
%59 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%60 = load float, float* %59
%61 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%62 = load float, float* %61
%63 = fcmp olt float %60, %62
br i1 %63, label %64, label %82
64: ; preds = %58
%65 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%66 = load float, float* %65
store float %66, float* %3
%67 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%68 = load float, float* %67
%69 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
store float %68, float* %69
%70 = load float, float* %3
%71 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
store float %70, float* %71
%72 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%73 = load float, float* %72
%74 = fpext float %73 to double
%75 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%76 = load float, float* %75
%77 = fpext float %76 to double
%78 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%79 = load float, float* %78
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %74, double %77, double %80)
br label %82
82: ; preds = %64, %58
%83 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%84 = load float, float* %83
%85 = fpext float %84 to double
%86 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%87 = load float, float* %86
%88 = fpext float %87 to double
%89 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%90 = load float, float* %89
%91 = fpext float %90 to double
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %85, double %88, double %91)
br label %9
93: ; preds = %21
%94 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%95 = load float, float* %94
%96 = fpext float %95 to double
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), double %96)
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"Please enter three numbers separated by spaces > \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [27 x i8] c"Before swaps: %f, %f, %f\0A\00"
@.str.3 = [27 x i8] c"Swap 2 & 1 for %f, %f, %f\0A\00"
@.str.4 = [27 x i8] c"Swap 2 & 3 for %f, %f, %f\0A\00"
@.str.5 = [25 x i8] c"After swaps: %f, %f, %f\0A\00"
@.str.6 = [20 x i8] c"%.0f is the median\0A\00"
define i32 @main() {
%1 = alloca [3 x float]
%2 = bitcast [3 x float]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%5 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%6 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 3
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %4, float* %5, float* %6)
%8 = load float, float* %4
%9 = load float, float* %5
%10 = fcmp ugt float %8, %9
%11 = load float, float* %6
%12 = fcmp ugt float %9, %11
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %58
14: ; preds = %0, %44
%15 = phi float [ %55, %44 ], [ %11, %0 ]
%16 = phi float [ %53, %44 ], [ %9, %0 ]
%17 = phi float [ %52, %44 ], [ %8, %0 ]
%18 = fpext float %17 to double
%19 = fpext float %16 to double
%20 = fpext float %15 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %18, double %19, double %20)
%22 = load float, float* %5
%23 = load float, float* %4
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %32
25: ; preds = %14
store float %23, float* %5
store float %22, float* %4
%26 = fpext float %22 to double
%27 = fpext float %23 to double
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), double %26, double %27, double %29)
%31 = load float, float* %5
br label %32
32: ; preds = %25, %14
%33 = phi float [ %31, %25 ], [ %22, %14 ]
%34 = load float, float* %6
%35 = fcmp olt float %34, %33
br i1 %35, label %36, label %44
36: ; preds = %32
store float %34, float* %5
store float %33, float* %6
%37 = load float, float* %4
%38 = fpext float %37 to double
%39 = fpext float %34 to double
%40 = fpext float %33 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %38, double %39, double %40)
%42 = load float, float* %5
%43 = load float, float* %6
br label %44
44: ; preds = %36, %32
%45 = phi float [ %43, %36 ], [ %34, %32 ]
%46 = phi float [ %42, %36 ], [ %33, %32 ]
%47 = load float, float* %4
%48 = fpext float %47 to double
%49 = fpext float %46 to double
%50 = fpext float %45 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %48, double %49, double %50)
%52 = load float, float* %4
%53 = load float, float* %5
%54 = fcmp ugt float %52, %53
%55 = load float, float* %6
%56 = fcmp ugt float %53, %55
%57 = select i1 %54, i1 true, i1 %56
br i1 %57, label %14, label %58
58: ; preds = %44, %0
%59 = phi float [ %9, %0 ], [ %53, %44 ]
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), double %60)
ret i32 0
}