#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 *, ...);
int main(void) {
  char operation = 0;
  float number_1 = 0, number_2 = 0, number_3 = 0, result = 0;
  printf("Please enter 3 real numbers.\n");
  scanf("%f %f %f", &number_1, &number_2, &number_3);
  while ((operation != 'a') && (operation != 'A') && (operation != 'm') &&
         (operation != 'M')) {
    printf("Please enter the requested operation.\n");
    printf("\tm/M : Median \n\ta/A : Average\n");
    scanf(" %c", &operation);
    if ((operation != 'a') && (operation != 'A') && (operation != 'm') &&
        (operation != 'M')) {
      printf("Invalid option.\n");
    }
  }
  switch (operation) {
  case 'a':
  case 'A':
    result = (number_1 + number_2 + number_3) / 3;
    printf("The average is %f\n", result);
    break;
  case 'm':
  case 'M':
    if (((number_1 <= number_2) && (number_1 >= number_3)) ||
        ((number_1 <= number_3) && (number_1 >= number_2)))
      result = number_1;
    else if (((number_2 <= number_1) && (number_2 >= number_3)) ||
             ((number_2 <= number_3) && (number_2 >= number_1)))
      result = number_2;
    else if (((number_3 <= number_1) && (number_3 >= number_2)) ||
             ((number_3 <= number_2) && (number_3 >= number_1)))
      result = number_3;
    printf("The median is %f\n", result);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x61,%ecx
mov    %al,-0x19(%rbp)
je     11be <main+0x9e>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x19(%rbp)
je     11be <main+0x9e>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6d,%ecx
mov    %al,-0x19(%rbp)
je     11be <main+0x9e>
movsbl -0x5(%rbp),%eax
cmp    $0x4d,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11ce <main+0xae>
jmp    1243 <main+0x123>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
je     123e <main+0x11e>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
je     123e <main+0x11e>
movsbl -0x5(%rbp),%eax
cmp    $0x6d,%eax
je     123e <main+0x11e>
movsbl -0x5(%rbp),%eax
cmp    $0x4d,%eax
je     123e <main+0x11e>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117b <main+0x5b>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x41,%eax
je     128b <main+0x16b>
jmp    1258 <main+0x138>
mov    -0x20(%rbp),%eax
sub    $0x4d,%eax
je     12c7 <main+0x1a7>
jmp    1269 <main+0x149>
mov    -0x20(%rbp),%eax
sub    $0x61,%eax
je     128b <main+0x16b>
jmp    127a <main+0x15a>
mov    -0x20(%rbp),%eax
sub    $0x6d,%eax
je     12c7 <main+0x1a7>
jmp    13dc <main+0x2bc>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xd5e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdcb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    13dc <main+0x2bc>
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     12e9 <main+0x1c9>
movss  -0xc(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jae    130b <main+0x1eb>
movss  -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     131a <main+0x1fa>
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     131a <main+0x1fa>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    13c5 <main+0x2a5>
movss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     133c <main+0x21c>
movss  -0x10(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jae    135e <main+0x23e>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     136d <main+0x24d>
movss  -0x10(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     136d <main+0x24d>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    13c0 <main+0x2a0>
movss  -0x14(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     138f <main+0x26f>
movss  -0x14(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jae    13b1 <main+0x291>
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     13bb <main+0x29b>
movss  -0x14(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     13bb <main+0x29b>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    13c0 <main+0x2a0>
jmp    13c5 <main+0x2a5>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcc4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0xb(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec8(%rip),%r14
lea    0xee7(%rip),%r15
lea    0xe74(%rip),%r12
lea    0xb(%rsp),%rbx
lea    0xef2(%rip),%r13
movabs $0x100100001001,%rbp
xor    %eax,%eax
jmp    11c0 <main+0x90>
mov    %r13,%rdi
call   1030 <puts@plt>
movzbl 0xb(%rsp),%eax
cmp    $0x60,%al
jg     11d0 <main+0xa0>
cmp    $0x41,%al
je     120d <main+0xdd>
cmp    $0x4d,%al
jne    11d8 <main+0xa8>
jmp    1230 <main+0x100>
xchg   %ax,%ax
cmp    $0x61,%al
je     120d <main+0xdd>
cmp    $0x6d,%al
je     1230 <main+0x100>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xb(%rsp),%eax
lea    -0x41(%rax),%ecx
cmp    $0x2c,%cl
ja     11b3 <main+0x83>
movzbl %cl,%ecx
bt     %rcx,%rbp
jb     11c0 <main+0x90>
jmp    11b3 <main+0x83>
movss  0x14(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
divss  0xdd9(%rip),%xmm0
lea    0xde3(%rip),%rdi
jmp    1260 <main+0x130>
movss  0x14(%rsp),%xmm1
movss  0x10(%rsp),%xmm2
ucomiss %xmm1,%xmm2
movss  0xc(%rsp),%xmm0
lea    0xdd8(%rip),%rdi
jb     1253 <main+0x123>
ucomiss %xmm0,%xmm1
jae    125d <main+0x12d>
ucomiss %xmm1,%xmm0
jb     127c <main+0x14c>
ucomiss %xmm2,%xmm1
jb     127c <main+0x14c>
movaps %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
ucomiss %xmm2,%xmm1
jb     1286 <main+0x156>
ucomiss %xmm0,%xmm2
jae    1290 <main+0x160>
ucomiss %xmm2,%xmm0
jb     1295 <main+0x165>
ucomiss %xmm1,%xmm2
jb     1295 <main+0x165>
movaps %xmm2,%xmm0
jmp    1260 <main+0x130>
ucomiss %xmm0,%xmm1
jb     129f <main+0x16f>
ucomiss %xmm2,%xmm0
jae    1260 <main+0x130>
ucomiss %xmm0,%xmm2
jb     12a9 <main+0x179>
ucomiss %xmm1,%xmm0
jae    1260 <main+0x130>
xorps  %xmm0,%xmm0
jmp    1260 <main+0x130>

LLVM IR (-O0):
@.str = [30 x i8] c"Please enter 3 real numbers.\0A\00"
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.2 = [39 x i8] c"Please enter the requested operation.\0A\00"
@.str.3 = [31 x i8] c"\09m/M : Median \0A\09a/A : Average\0A\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [17 x i8] c"Invalid option.\0A\00"
@.str.6 = [19 x i8] c"The average is %f\0A\00"
@.str.7 = [18 x i8] c"The median is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i8 0, i8* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4, float* %5)
br label %9
9: ; preds = %48, %0
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 97
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 65
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 109
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 77
br label %25
25: ; preds = %21, %17, %13, %9
%26 = phi i1 [ false, %17 ], [ false, %13 ], [ false, %9 ], [ %24, %21 ]
br i1 %26, label %27, label %49
27: ; preds = %25
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 97
br i1 %33, label %34, label %48
34: ; preds = %27
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 65
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 109
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i8, i8* %2
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 77
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %42, %38, %34, %27
br label %9
49: ; preds = %25
%50 = load i8, i8* %2
%51 = sext i8 %50 to i32
switch i32 %51, label %122 [
i32 97, label %52
i32 65, label %52
i32 109, label %62
i32 77, label %62
]
52: ; preds = %49, %49
%53 = load float, float* %3
%54 = load float, float* %4
%55 = fadd float %53, %54
%56 = load float, float* %5
%57 = fadd float %55, %56
%58 = fdiv float %57, 3.000000e+00
store float %58, float* %6
%59 = load float, float* %6
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %60)
br label %122
62: ; preds = %49, %49
%63 = load float, float* %3
%64 = load float, float* %4
%65 = fcmp ole float %63, %64
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load float, float* %3
%68 = load float, float* %5
%69 = fcmp oge float %67, %68
br i1 %69, label %78, label %70
70: ; preds = %66, %62
%71 = load float, float* %3
%72 = load float, float* %5
%73 = fcmp ole float %71, %72
br i1 %73, label %74, label %80
74: ; preds = %70
%75 = load float, float* %3
%76 = load float, float* %4
%77 = fcmp oge float %75, %76
br i1 %77, label %78, label %80
78: ; preds = %74, %66
%79 = load float, float* %3
store float %79, float* %6
br label %118
80: ; preds = %74, %70
%81 = load float, float* %4
%82 = load float, float* %3
%83 = fcmp ole float %81, %82
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = load float, float* %4
%86 = load float, float* %5
%87 = fcmp oge float %85, %86
br i1 %87, label %96, label %88
88: ; preds = %84, %80
%89 = load float, float* %4
%90 = load float, float* %5
%91 = fcmp ole float %89, %90
br i1 %91, label %92, label %98
92: ; preds = %88
%93 = load float, float* %4
%94 = load float, float* %3
%95 = fcmp oge float %93, %94
br i1 %95, label %96, label %98
96: ; preds = %92, %84
%97 = load float, float* %4
store float %97, float* %6
br label %117
98: ; preds = %92, %88
%99 = load float, float* %5
%100 = load float, float* %3
%101 = fcmp ole float %99, %100
br i1 %101, label %102, label %106
102: ; preds = %98
%103 = load float, float* %5
%104 = load float, float* %4
%105 = fcmp oge float %103, %104
br i1 %105, label %114, label %106
106: ; preds = %102, %98
%107 = load float, float* %5
%108 = load float, float* %4
%109 = fcmp ole float %107, %108
br i1 %109, label %110, label %116
110: ; preds = %106
%111 = load float, float* %5
%112 = load float, float* %3
%113 = fcmp oge float %111, %112
br i1 %113, label %114, label %116
114: ; preds = %110, %102
%115 = load float, float* %5
store float %115, float* %6
br label %116
116: ; preds = %114, %110, %106
br label %117
117: ; preds = %116, %96
br label %118
118: ; preds = %117, %78
%119 = load float, float* %6
%120 = fpext float %119 to double
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), double %120)
br label %122
122: ; preds = %49, %118, %52
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.6 = [19 x i8] c"The average is %f\0A\00"
@.str.7 = [18 x i8] c"The median is %f\0A\00"
@str = [29 x i8] c"Please enter 3 real numbers.\00"
@str.8 = [38 x i8] c"Please enter the requested operation.\00"
@str.9 = [30 x i8] c"\09m/M : Median \0A\09a/A : Average\00"
@str.10 = [16 x i8] c"Invalid option.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = alloca float
store i8 0, i8* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%7 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4)
br label %10
10: ; preds = %17, %0
%11 = phi i8 [ 0, %0 ], [ %18, %17 ]
switch i8 %11, label %12 [
i8 97, label %22
i8 65, label %22
i8 109, label %29
i8 77, label %29
]
12: ; preds = %10
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%16 = load i8, i8* %1
switch i8 %16, label %19 [
i8 109, label %17
i8 97, label %17
i8 77, label %17
i8 65, label %17
]
17: ; preds = %12, %12, %12, %12, %19
%18 = phi i8 [ %16, %12 ], [ %16, %12 ], [ %16, %12 ], [ %16, %12 ], [ %21, %19 ]
br label %10
19: ; preds = %12
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%21 = load i8, i8* %1
br label %17
22: ; preds = %10, %10
%23 = load float, float* %2
%24 = load float, float* %3
%25 = fadd float %23, %24
%26 = load float, float* %4
%27 = fadd float %25, %26
%28 = fdiv float %27, 3.000000e+00
br label %51
29: ; preds = %10, %10
%30 = load float, float* %2
%31 = load float, float* %3
%32 = fcmp ugt float %30, %31
%33 = load float, float* %4
%34 = fcmp ult float %30, %33
%35 = select i1 %32, i1 true, i1 %34
br i1 %35, label %36, label %51
36: ; preds = %29
%37 = fcmp ugt float %30, %33
%38 = fcmp ult float %30, %31
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = fcmp ult float %31, %33
%42 = select i1 %38, i1 true, i1 %41
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = fcmp ugt float %31, %33
%45 = select i1 %44, i1 true, i1 %32
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = select i1 %34, i1 true, i1 %44
br i1 %47, label %48, label %50
48: ; preds = %46
%49 = select i1 %41, i1 true, i1 %37
br i1 %49, label %51, label %50
50: ; preds = %48, %46
br label %51
51: ; preds = %48, %50, %36, %29, %43, %40, %22
%52 = phi float [ %28, %22 ], [ %33, %50 ], [ 0.000000e+00, %48 ], [ %30, %36 ], [ %30, %29 ], [ %31, %43 ], [ %31, %40 ]
%53 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), %22 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %50 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %48 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %36 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %29 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %43 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %40 ]
%54 = fpext float %52 to double
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %53, double %54)
ret i32 0
}