#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 */
double FindKthMin(int *, int, int *, int, int);
double findMedianSortedArrays(int *nums1, int nums1Size, int *nums2,
                              int nums2Size) {
  int mLeftIndex = (nums1Size + nums2Size + 1) >> 1;
  int mRightIndex = (nums1Size + nums2Size + 2) >> 1;
  if ((nums1Size + nums2Size) & 1) {
    return FindKthMin(nums1, nums1Size, nums2, nums2Size, mLeftIndex);
  }
  return (FindKthMin(nums1, nums1Size, nums2, nums2Size, mLeftIndex) +
          FindKthMin(nums1, nums1Size, nums2, nums2Size, mRightIndex)) /
         2.0;
}


x86 assembly (clang, -O0):
<findMedianSortedArrays>:
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
add    $0x1,%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
add    $0x2,%eax
sar    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1177 <findMedianSortedArrays+0x67>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <FindKthMin@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11c7 <findMedianSortedArrays+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <FindKthMin@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1030 <FindKthMin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findMedianSortedArrays>:
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),%ebp
lea    (%r15,%rbx,1),%r8d
add    $0x1,%r8d
sar    %r8d
test   $0x1,%bpl
jne    1185 <findMedianSortedArrays+0x75>
add    $0x2,%ebp
sar    %ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1030 <FindKthMin@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <FindKthMin@plt>
addsd  0x8(%rsp),%xmm0
mulsd  0xe88(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <FindKthMin@plt>

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

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