#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 findKth(int *, int, int *, int, int);
double findMedianSortedArrays(int *nums1, int nums1Size, int *nums2,
                              int nums2Size) {
  int k = nums1Size + nums2Size, oe = k & 1;
  k >>= 1;
  if (oe)
    return findKth(nums1, nums1Size, nums2, nums2Size, k + 1);
  else
    return (findKth(nums1, nums1Size, nums2, nums2Size, k) +
            findKth(nums1, nums1Size, nums2, nums2Size, k + 1)) /
           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
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1170 <findMedianSortedArrays+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
add    $0x1,%r8d
call   1030 <findKth@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <findMedianSortedArrays+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <findKth@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
add    $0x1,%r8d
call   1030 <findKth@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe45(%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),%eax
mov    %eax,%ebp
sar    %ebp
test   $0x1,%al
jne    117d <findMedianSortedArrays+0x6d>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findKth@plt>
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findKth@plt>
addsd  0x8(%rsp),%xmm0
mulsd  0xe90(%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 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
store i32 %14, i32* %10
%15 = load i32, i32* %10
%16 = and i32 %15, 1
store i32 %16, i32* %11
%17 = load i32, i32* %10
%18 = ashr i32 %17, 1
store i32 %18, i32* %10
%19 = load i32, i32* %11
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %4
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = load i32*, i32** %8
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
%28 = call double @findKth(i32* %22, i32 %23, i32* %24, i32 %25, i32 %27)
store double %28, double* %5
br label %45
29: ; preds = %4
%30 = load i32*, i32** %6
%31 = load i32, i32* %7
%32 = load i32*, i32** %8
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = call double @findKth(i32* %30, i32 %31, i32* %32, i32 %33, i32 %34)
%36 = load i32*, i32** %6
%37 = load i32, i32* %7
%38 = load i32*, i32** %8
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
%42 = call double @findKth(i32* %36, i32 %37, i32* %38, i32 %39, i32 %41)
%43 = fadd double %35, %42
%44 = fdiv double %43, 2.000000e+00
store double %44, double* %5
br label %45
45: ; preds = %29, %21
%46 = load double, double* %5
ret double %46
}

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