#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 */
typedef int /*<<< orphan*/ d;
typedef int /*<<< orphan*/ c;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int median(int *, int);
int /*<<< orphan*/ printf(char *, int);
int sort_median(int *, int);
int main(int argc, char **argv) {
  int a[] = {1, 3, 4, -3231, 5, 99, 2};
  int b[] = {1, 3, 4, 5, 99, 2, 88, 88, 88, 55, 6};
  int c[] = {-1, -4, 0, 3};
  int d[] = {3, 5};
  printf("%d\n", median(a, sizeof(a) / sizeof(int)));
  printf("%d\n", median(b, sizeof(b) / sizeof(int)));
  printf("%d\n", median(c, sizeof(c) / sizeof(int)));
  printf("%d\n", median(d, sizeof(d) / sizeof(int)));
  printf("%d\n", sort_median(a, sizeof(a) / sizeof(int)));
  printf("%d\n", sort_median(b, sizeof(b) / sizeof(int)));
  printf("%d\n", sort_median(c, sizeof(c) / sizeof(int)));
  printf("%x\n", sort_median(d, sizeof(d) / sizeof(int)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x2c,%edx
call   1050 <memcpy@plt>
mov    0xeb8(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x7,%esi
call   1030 <median@plt>
mov    %eax,%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0xb,%esi
call   1030 <median@plt>
mov    %eax,%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x4,%esi
call   1030 <median@plt>
mov    %eax,%esi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
lea    -0x78(%rbp),%rdi
mov    $0x2,%esi
call   1030 <median@plt>
mov    %eax,%esi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x7,%esi
call   1060 <sort_median@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0xb,%esi
call   1060 <sort_median@plt>
mov    %eax,%esi
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x4,%esi
call   1060 <sort_median@plt>
mov    %eax,%esi
lea    0xdf7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x78(%rbp),%rdi
mov    $0x2,%esi
call   1060 <sort_median@plt>
mov    %eax,%esi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
movups 0xec8(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xee0(%rip),%xmm0
movups %xmm0,0x5c(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x500000003,%rax
mov    %rax,0x8(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x7,%esi
call   1030 <median@plt>
lea    0xeb3(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    $0xb,%esi
call   1030 <median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x4,%esi
call   1030 <median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    $0x2,%esi
call   1030 <median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1050 <sort_median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0xb,%esi
call   1050 <sort_median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x4,%esi
call   1050 <sort_median@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r13,%rdi
mov    $0x2,%esi
call   1050 <sort_median@plt>
lea    0xe00(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [7 x i32] [i32 1, i32 3, i32 4, i32 -3231, i32 5, i32 99, i32 2]
@__const.main.b = [11 x i32] [i32 1, i32 3, i32 4, i32 5, i32 99, i32 2, i32 88, i32 88, i32 88, i32 55, i32 6]
@__const.main.c = [4 x i32] [i32 -1, i32 -4, i32 0, i32 3]
@__const.main.d = [2 x i32] [i32 3, i32 5]
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [7 x i32]
%6 = alloca [11 x i32]
%7 = alloca [4 x i32]
%8 = alloca [2 x i32]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = bitcast [7 x i32]* %5 to i8*
%10 = bitcast [11 x i32]* %6 to i8*
%11 = bitcast [4 x i32]* %7 to i8*
%12 = bitcast [2 x i32]* %8 to i8*
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 0
%14 = call i32 @median(i32* %13, i32 7)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [11 x i32], [11 x i32]* %6, i64 0, i64 0
%17 = call i32 @median(i32* %16, i32 11)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%20 = call i32 @median(i32* %19, i32 4)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%23 = call i32 @median(i32* %22, i32 2)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 0
%26 = call i32 @sort_median(i32* %25, i32 7)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [11 x i32], [11 x i32]* %6, i64 0, i64 0
%29 = call i32 @sort_median(i32* %28, i32 11)
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%32 = call i32 @sort_median(i32* %31, i32 4)
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%35 = call i32 @sort_median(i32* %34, i32 2)
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [7 x i32] [i32 1, i32 3, i32 4, i32 -3231, i32 5, i32 99, i32 2]
@__const.main.b = [11 x i32] [i32 1, i32 3, i32 4, i32 5, i32 99, i32 2, i32 88, i32 88, i32 88, i32 55, i32 6]
@__const.main.c = [4 x i32] [i32 -1, i32 -4, i32 0, i32 3]
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i32]
%4 = alloca [11 x i32]
%5 = alloca [4 x i32]
%6 = alloca i64
%7 = bitcast [7 x i32]* %3 to i8*
%8 = bitcast [11 x i32]* %4 to i8*
%9 = bitcast [4 x i32]* %5 to i8*
%10 = bitcast i64* %6 to i8*
store i64 21474836483, i64* %6
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%12 = call i32 @median(i32* %11, i32 7)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%15 = call i32 @median(i32* %14, i32 11)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%18 = call i32 @median(i32* %17, i32 4)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = bitcast i64* %6 to i32*
%21 = call i32 @median(i32* %20, i32 2)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 @sort_median(i32* %11, i32 7)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 @sort_median(i32* %14, i32 11)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = call i32 @sort_median(i32* %17, i32 4)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = call i32 @sort_median(i32* %20, i32 2)
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 0
}