#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 */
float findkth(int *, int, int *, int, int);
float search(int *bufferm, int m, int *buffern, int n) {
  if ((m + n) % 2 == 0)
    return (findkth(bufferm, m, buffern, n, (m + n) / 2) +
            findkth(bufferm, m, buffern, n, ((m + n) / 2 + 1))) /
           2.0;
  else
    return findkth(bufferm, m, buffern, n, ((m + n) / 2 + 1));
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11cc <search+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x38(%rbp),%rdx
mov    %eax,%r8d
call   1030 <findkth@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%rdx
mov    %eax,%r8d
add    $0x1,%r8d
call   1030 <findkth@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe46(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1203 <search+0xf3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x40(%rbp),%rdx
mov    %eax,%r8d
add    $0x1,%r8d
call   1030 <findkth@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%r12
lea    (%r15,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
test   $0x1,%al
jne    1182 <search+0x72>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findkth@plt>
movss  %xmm0,0xc(%rsp)
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findkth@plt>
addss  0xc(%rsp),%xmm0
mulss  0xe8b(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <findkth@plt>

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

LLVM IR (-O2):
define float @search(i32* %0, i32 %1, i32* %2, i32 %3) {
%5 = add nsw i32 %3, %1
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
%8 = sdiv i32 %5, 2
br i1 %7, label %9, label %15
9: ; preds = %4
%10 = tail call float @findkth(i32* %0, i32 %1, i32* %2, i32 %3, i32 %8)
%11 = add nsw i32 %8, 1
%12 = tail call float @findkth(i32* %0, i32 %1, i32* %2, i32 %3, i32 %11)
%13 = fadd float %10, %12
%14 = fmul float %13, 5.000000e-01
br label %18
15: ; preds = %4
%16 = add nsw i32 %8, 1
%17 = tail call float @findkth(i32* %0, i32 %1, i32* %2, i32 %3, i32 %16)
br label %18
18: ; preds = %15, %9
%19 = phi float [ %14, %9 ], [ %17, %15 ]
ret float %19
}