#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 floor(int);
float findMedian(int numbers[], int numbersCount) {
  int foo;
  float median;
  if (numbersCount % 2 == 1) {
    foo = floor(numbersCount / 2);
    median = numbers[foo];
  } else {
    int a, b;
    foo = numbersCount / 2;
    a = numbers[foo--];
    b = numbers[foo];
    median = ((float)a + (float)b) / (float)2;
  }
  return median;
}


x86 assembly (clang, -O0):
<findMedian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    115f <findMedian+0x4f>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <floor@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11b2 <findMedian+0xa2>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x10(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  0xe57(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findMedian>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
mov    %eax,%edi
sar    %edi
and    $0xfffffffe,%eax
sub    %eax,%esi
cmp    $0x1,%esi
jne    1137 <findMedian+0x27>
call   1030 <floor@plt>
cltq
cvtsi2ssl (%rbx,%rax,4),%xmm0
pop    %rbx
ret
movslq %edi,%rax
movsd  -0x4(%rbx,%rax,4),%xmm0
cvtdq2ps %xmm0,%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
addss  %xmm1,%xmm0
mulss  0xeaa(%rip),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @findMedian(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 2
%15 = call i32 @floor(i32 %14)
store i32 %15, i32* %5
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = sitofp i32 %20 to float
store float %21, float* %6
br label %42
22: ; preds = %2
%23 = load i32, i32* %4
%24 = sdiv i32 %23, 2
store i32 %24, i32* %5
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = add nsw i32 %26, -1
store i32 %27, i32* %5
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
%30 = load i32, i32* %29
store i32 %30, i32* %7
%31 = load i32*, i32** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %8
%36 = load i32, i32* %7
%37 = sitofp i32 %36 to float
%38 = load i32, i32* %8
%39 = sitofp i32 %38 to float
%40 = fadd float %37, %39
%41 = fdiv float %40, 2.000000e+00
store float %41, float* %6
br label %42
42: ; preds = %22, %12
%43 = load float, float* %6
ret float %43
}

LLVM IR (-O2):
define float @findMedian(i32* nocapture %0, i32 %1) {
%3 = srem i32 %1, 2
%4 = icmp eq i32 %3, 1
%5 = sdiv i32 %1, 2
br i1 %4, label %6, label %12
6: ; preds = %2
%7 = tail call i32 @floor(i32 %5)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = sitofp i32 %10 to float
br label %23
12: ; preds = %2
%13 = add nsw i32 %5, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = bitcast i32* %15 to <2 x i32>*
%17 = load <2 x i32>, <2 x i32>* %16
%18 = sitofp <2 x i32> %17 to <2 x float>
%19 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%20 = fadd <2 x float> %19, %18
%21 = extractelement <2 x float> %20, i64 0
%22 = fmul float %21, 5.000000e-01
br label %23
23: ; preds = %12, %6
%24 = phi float [ %11, %6 ], [ %22, %12 ]
ret float %24
}