#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*/ bubbleSort(unsigned int *, int);
int /*<<< orphan*/ printArray(unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
void median(unsigned int answer[]) {
  printf("\n%s\n%s\n%s\n%s", "********", " Median", "********",
         "The unsorted array of responses is");
  printArray(answer);
  bubbleSort(answer, 100);
  printf("%s", "\n\nThe sorted array is");
  printArray(answer);
  if (100 / 2 != 0) {
    printf("\n\nThe median is element %u of\n"
           "the sorted %u element array.\n"
           "For this run the median is %u\n\n",
           100 / 2, 100, answer[100 / 2]);
  } else {
    printf("\n\nThe median is element %u of\n"
           "the sorted %u element array.\n"
           "For this run the median is %u\n\n",
           100 / 2, 100, ((answer[100 / 2] + answer[(100 / 2) + 1]) / 2));
  }
  return;
}


x86 assembly (clang, -O0):
<median>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
lea    0xec3(%rip),%rcx
lea    0xec5(%rip),%rdx
lea    0xec6(%rip),%r8
mov    %rcx,%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <printArray@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
call   1040 <bubbleSort@plt>
lea    0xe8a(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <printArray@plt>
mov    -0x8(%rbp),%rax
mov    0xc8(%rax),%ecx
lea    0xeaf(%rip),%rdi
mov    $0x32,%esi
mov    $0x64,%edx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<median>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
lea    0xed4(%rip),%rdx
lea    0xec4(%rip),%rcx
lea    0xece(%rip),%r8
mov    %rcx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <printArray@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <bubbleSort@plt>
lea    0xe94(%rip),%rdi
lea    0xec4(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <printArray@plt>
mov    0xc8(%rbx),%ecx
lea    0xebe(%rip),%rdi
mov    $0x32,%esi
mov    $0x64,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"\0A%s\0A%s\0A%s\0A%s\00"
@.str.1 = [9 x i8] c"********\00"
@.str.2 = [8 x i8] c" Median\00"
@.str.3 = [35 x i8] c"The unsorted array of responses is\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [22 x i8] c"\0A\0AThe sorted array is\00"
@.str.6 = [91 x i8] c"\0A\0AThe median is element %u of\0Athe sorted %u element array.\0AFor this run the median is %u\0A\0A\00"
define void @median(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%4 = load i32*, i32** %2
%5 = call i32 @printArray(i32* %4)
%6 = load i32*, i32** %2
%7 = call i32 @bubbleSort(i32* %6, i32 100)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @printArray(i32* %9)
%11 = load i32*, i32** %2
%12 = getelementptr inbounds i32, i32* %11, i64 50
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.6, i64 0, i64 0), i32 50, i32 100, i32 %13)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\0A%s\0A%s\0A%s\0A%s\00"
@.str.1 = [9 x i8] c"********\00"
@.str.2 = [8 x i8] c" Median\00"
@.str.3 = [35 x i8] c"The unsorted array of responses is\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [22 x i8] c"\0A\0AThe sorted array is\00"
@.str.6 = [91 x i8] c"\0A\0AThe median is element %u of\0Athe sorted %u element array.\0AFor this run the median is %u\0A\0A\00"
define void @median(i32* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32 @printArray(i32* %0)
%4 = tail call i32 @bubbleSort(i32* %0, i32 100)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%6 = tail call i32 @printArray(i32* %0)
%7 = getelementptr inbounds i32, i32* %0, i64 50
%8 = load i32, i32* %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str.6, i64 0, i64 0), i32 50, i32 100, i32 %8)
ret void
}