#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 findK(int *, int, int *, int, int);
double findMedianSortedArrays(int *nums1, int nums1Size, int *nums2,
                              int nums2Size) {
  int k = (nums1Size + nums2Size) / 2;
  if ((nums1Size + nums2Size) % 2)
    return findK(nums1, nums1Size, nums2, nums2Size, k + 1);
  else
    return (findK(nums1, nums1Size, nums2, nums2Size, k) +
            findK(nums1, nums1Size, nums2, nums2Size, k + 1)) /
           2;
}


x86 assembly (clang, -O0):
<findMedianSortedArrays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1177 <findMedianSortedArrays+0x67>
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 <findK@plt>
cvtsi2sd %eax,%xmm0
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 <findK@plt>
mov    %eax,-0x2c(%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 <findK@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findMedianSortedArrays>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
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    1173 <findMedianSortedArrays+0x63>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findK@plt>
mov    %eax,%r13d
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findK@plt>
mov    %eax,%ecx
add    %r13d,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
jmp    1189 <findMedianSortedArrays+0x79>
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1030 <findK@plt>
cvtsi2sd %eax,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%11 = load i32, i32* %7
%12 = load i32, i32* %9
%13 = add nsw i32 %11, %12
%14 = sdiv i32 %13, 2
store i32 %14, i32* %10
%15 = load i32, i32* %7
%16 = load i32, i32* %9
%17 = add nsw i32 %15, %16
%18 = srem i32 %17, 2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %4
%21 = load i32*, i32** %6
%22 = load i32, i32* %7
%23 = load i32*, i32** %8
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = add nsw i32 %25, 1
%27 = call i32 @findK(i32* %21, i32 %22, i32* %23, i32 %24, i32 %26)
%28 = sitofp i32 %27 to double
store double %28, double* %5
br label %46
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 i32 @findK(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 i32 @findK(i32* %36, i32 %37, i32* %38, i32 %39, i32 %41)
%43 = add nsw i32 %35, %42
%44 = sdiv i32 %43, 2
%45 = sitofp i32 %44 to double
store double %45, double* %5
br label %46
46: ; preds = %29, %20
%47 = load double, double* %5
ret double %47
}

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