#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]))) {
    if (data[2] <= data[1]) {
      temp = data[2];
      data[2] = data[1];
      data[1] = temp;
    }
    if (data[3] <= data[2]) {
      temp = data[3];
      data[3] = data[2];
      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    120d <main+0xed>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11d7 <main+0xb7>
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  -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1208 <main+0xe8>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1169 <main+0x49>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0xeea(%rip),%rdi
call   1040 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
nopl   0x0(%rax)
ucomiss %xmm0,%xmm1
jb     1170 <main+0x50>
movss  0x18(%rsp),%xmm2
ucomiss %xmm1,%xmm2
jae    11b7 <main+0x97>
ucomiss %xmm1,%xmm0
jae    1190 <main+0x70>
movaps %xmm1,%xmm2
ucomiss 0x18(%rsp),%xmm2
jb     1160 <main+0x40>
jmp    11ac <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movaps %xmm0,%xmm2
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
ucomiss 0x18(%rsp),%xmm2
jb     1160 <main+0x40>
movss  %xmm2,0x18(%rsp)
movaps %xmm2,%xmm1
jmp    1160 <main+0x40>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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 = [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 = %53, %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 %54
24: ; preds = %21
%25 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%26 = load float, float* %25
%27 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%28 = load float, float* %27
%29 = fcmp ole float %26, %28
br i1 %29, label %30, label %38
30: ; preds = %24
%31 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%32 = load float, float* %31
store float %32, float* %3
%33 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
%34 = load float, float* %33
%35 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
store float %34, float* %35
%36 = load float, float* %3
%37 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
store float %36, float* %37
br label %38
38: ; preds = %30, %24
%39 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%40 = load float, float* %39
%41 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%42 = load float, float* %41
%43 = fcmp ole float %40, %42
br i1 %43, label %44, label %53
44: ; preds = %38
%45 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%46 = load float, float* %45
store float %46, float* %3
%47 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%48 = load float, float* %47
%49 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
store float %48, float* %49
%50 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 3
%51 = load float, float* %50
%52 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
store float %51, float* %52
br label %53
53: ; preds = %44, %38
br label %9
54: ; preds = %21
%55 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
%56 = load float, float* %55
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %57)
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 = [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
br label %10
10: ; preds = %26, %0
%11 = phi float [ %9, %0 ], [ %21, %26 ]
%12 = phi float [ %8, %0 ], [ %22, %26 ]
%13 = fcmp ugt float %12, %11
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load float, float* %6
%16 = fcmp ugt float %11, %15
br i1 %16, label %17, label %27
17: ; preds = %10, %14
%18 = fcmp ugt float %11, %12
br i1 %18, label %20, label %19
19: ; preds = %17
store float %12, float* %5
store float %11, float* %4
br label %20
20: ; preds = %19, %17
%21 = phi float [ %12, %19 ], [ %11, %17 ]
%22 = phi float [ %11, %19 ], [ %12, %17 ]
%23 = load float, float* %6
%24 = fcmp ugt float %23, %21
br i1 %24, label %26, label %25
25: ; preds = %20
store float %21, float* %6
br label %26
26: ; preds = %25, %20
br label %10
27: ; preds = %14
%28 = fpext float %11 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %28)
ret i32 0
}