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


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
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118b <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
add    $0x1,%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%rdx
mov    %eax,%r8d
call   1030 <findOne@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <findMedianSortedArrays+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x38(%rbp),%rdx
mov    %eax,%r8d
call   1040 <findTwo@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findMedianSortedArrays>:
lea    (%rcx,%rsi,1),%r9d
test   $0x1,%r9b
jne    113c <findMedianSortedArrays+0x1c>
mov    %r9d,%r8d
shr    $0x1f,%r8d
add    %r9d,%r8d
sar    %r8d
jmp    1040 <findTwo@plt>
mov    %r9d,%eax
add    $0x1,%eax
shr    $0x1f,%eax
lea    (%r9,%rax,1),%r8d
add    $0x1,%r8d
sar    %r8d
jmp    1030 <findOne@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
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 = srem i32 %14, 2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
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 = add nsw i32 %22, 1
%24 = sdiv i32 %23, 2
%25 = call double @findOne(i32* %18, i32 %19, i32* %20, i32 %21, i32 %24)
store double %25, double* %5
br label %34
26: ; preds = %4
%27 = load i32*, i32** %6
%28 = load i32, i32* %7
%29 = load i32*, i32** %8
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = sdiv i32 %31, 2
%33 = call double @findTwo(i32* %27, i32 %28, i32* %29, i32 %30, i32 %32)
store double %33, double* %5
br label %34
34: ; preds = %26, %17
%35 = load double, double* %5
ret double %35
}

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
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = add nsw i32 %5, 1
%10 = sdiv i32 %9, 2
%11 = tail call double @findOne(i32* %0, i32 %1, i32* %2, i32 %3, i32 %10)
br label %15
12: ; preds = %4
%13 = sdiv i32 %5, 2
%14 = tail call double @findTwo(i32* %0, i32 %1, i32* %2, i32 %3, i32 %13)
br label %15
15: ; preds = %12, %8
%16 = phi double [ %11, %8 ], [ %14, %12 ]
ret double %16
}