#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 findkthSortedArrays(int *, int, int *, int, int);
double findMedianSortedArrays(int *nums1, int nums1Size, int *nums2,
                              int nums2Size) {
  int total = nums1Size + nums2Size;
  if (total & 0x1) {
    return findkthSortedArrays(nums1, nums1Size, nums2, nums2Size,
                               total / 2 + 1);
  } else {
    return (findkthSortedArrays(nums1, nums1Size, nums2, nums2Size,
                                total / 2 + 1) +
            findkthSortedArrays(nums1, nums1Size, nums2, nums2Size,
                                total / 2)) /
           2;
  }
}


x86 assembly (clang, -O0):
<findMedianSortedArrays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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
cmp    $0x0,%eax
je     117b <findMedianSortedArrays+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%rdx
mov    %eax,%r8d
add    $0x1,%r8d
call   1030 <findkthSortedArrays@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f0 <findMedianSortedArrays+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x48(%rbp),%rdx
mov    %eax,%r8d
add    $0x1,%r8d
call   1030 <findkthSortedArrays@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x40(%rbp),%rdx
mov    %eax,%r8d
call   1030 <findkthSortedArrays@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%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    %esi,%r13d
mov    %rdi,%r12
lea    (%r15,%r13,1),%r14d
mov    %r14d,%ebx
shr    $0x1f,%ebx
add    %r14d,%ebx
sar    %ebx
lea    0x1(%rbx),%r8d
mov    %rdx,(%rsp)
call   1030 <findkthSortedArrays@plt>
mov    %eax,%ebp
test   $0x1,%r14b
jne    1168 <findMedianSortedArrays+0x58>
mov    %r12,%rdi
mov    %r13d,%esi
mov    (%rsp),%rdx
mov    %r15d,%ecx
mov    %ebx,%r8d
call   1030 <findkthSortedArrays@plt>
add    %ebp,%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
cvtsi2sd %ebp,%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
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = and i32 %14, 1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = load i32, i32* %7
%20 = load i32*, i32** %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = sdiv i32 %22, 2
%24 = add nsw i32 %23, 1
%25 = call i32 @findkthSortedArrays(i32* %18, i32 %19, i32* %20, i32 %21, i32 %24)
%26 = sitofp i32 %25 to double
store double %26, double* %5
br label %46
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 = sdiv i32 %32, 2
%34 = add nsw i32 %33, 1
%35 = call i32 @findkthSortedArrays(i32* %28, i32 %29, i32* %30, i32 %31, 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 = sdiv i32 %40, 2
%42 = call i32 @findkthSortedArrays(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 = %27, %17
%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 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
%8 = sdiv i32 %5, 2
%9 = add nsw i32 %8, 1
%10 = tail call i32 @findkthSortedArrays(i32* %0, i32 %1, i32* %2, i32 %3, i32 %9)
br i1 %7, label %11, label %15
11: ; preds = %4
%12 = tail call i32 @findkthSortedArrays(i32* %0, i32 %1, i32* %2, i32 %3, i32 %8)
%13 = add nsw i32 %12, %10
%14 = sdiv i32 %13, 2
br label %15
15: ; preds = %4, %11
%16 = phi i32 [ %14, %11 ], [ %10, %4 ]
%17 = sitofp i32 %16 to double
ret double %17
}