#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 */
typedef scalar_t__ uint16_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
size_t advanceUntil(scalar_t__ const *, int /*<<< orphan*/, int /*<<< orphan*/,
                    scalar_t__);
bool intersect_skewed_uint16_nonempty(const uint16_t *small, size_t size_s,
                                      const uint16_t *large, size_t size_l) {
  size_t idx_l = 0, idx_s = 0;
  if (0 == size_s) {
    return false;
  }
  uint16_t val_l = large[idx_l], val_s = small[idx_s];
  while (true) {
    if (val_l < val_s) {
      idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
      if (idx_l == size_l)
        break;
      val_l = large[idx_l];
    } else if (val_s < val_l) {
      idx_s++;
      if (idx_s == size_s)
        break;
      val_s = small[idx_s];
    } else {
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<intersect_skewed_uint16_nonempty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1150 <intersect_skewed_uint16_nonempty+0x40>
movl   $0x0,-0x4(%rbp)
jmp    1222 <intersect_skewed_uint16_nonempty+0x112>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x48(%rbp),%rax
jge    11c3 <intersect_skewed_uint16_nonempty+0xb3>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
mov    -0x48(%rbp),%rcx
call   1030 <advanceUntil@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    11ae <intersect_skewed_uint16_nonempty+0x9e>
jmp    121b <intersect_skewed_uint16_nonempty+0x10b>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
jmp    1216 <intersect_skewed_uint16_nonempty+0x106>
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jge    1205 <intersect_skewed_uint16_nonempty+0xf5>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11f0 <intersect_skewed_uint16_nonempty+0xe0>
jmp    121b <intersect_skewed_uint16_nonempty+0x10b>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
jmp    1211 <intersect_skewed_uint16_nonempty+0x101>
movl   $0x1,-0x4(%rbp)
jmp    1222 <intersect_skewed_uint16_nonempty+0x112>
jmp    1216 <intersect_skewed_uint16_nonempty+0x106>
jmp    1170 <intersect_skewed_uint16_nonempty+0x60>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersect_skewed_uint16_nonempty>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     116e <intersect_skewed_uint16_nonempty+0x5e>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
mov    (%rdi),%rbx
add    $0xffffffffffffffff,%r13
xor    %eax,%eax
xor    %ebp,%ebp
mov    (%r15,%rax,8),%rcx
cmp    %rbx,%rcx
jl     1155 <intersect_skewed_uint16_nonempty+0x45>
jle    1172 <intersect_skewed_uint16_nonempty+0x62>
cmp    %rbp,%r13
je     116e <intersect_skewed_uint16_nonempty+0x5e>
mov    0x8(%r12,%rbp,8),%rbx
add    $0x1,%rbp
cmp    %rbx,%rcx
jge    1140 <intersect_skewed_uint16_nonempty+0x30>
mov    %r15,%rdi
mov    %eax,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
call   1030 <advanceUntil@plt>
xor    %ecx,%ecx
cmp    %r14,%rax
jne    1137 <intersect_skewed_uint16_nonempty+0x27>
jmp    1177 <intersect_skewed_uint16_nonempty+0x67>
xor    %ecx,%ecx
jmp    1177 <intersect_skewed_uint16_nonempty+0x67>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @intersect_skewed_uint16_nonempty(i64* %0, i64 %1, i64* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
store i64* %0, i64** %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i64 %3, i64* %9
store i64 0, i64* %10
store i64 0, i64* %11
%14 = load i64, i64* %7
%15 = icmp eq i64 0, %14
br i1 %15, label %16, label %17
16: ; preds = %4
store i32 0, i32* %5
br label %67
17: ; preds = %4
%18 = load i64*, i64** %8
%19 = load i64, i64* %10
%20 = getelementptr inbounds i64, i64* %18, i64 %19
%21 = load i64, i64* %20
store i64 %21, i64* %12
%22 = load i64*, i64** %6
%23 = load i64, i64* %11
%24 = getelementptr inbounds i64, i64* %22, i64 %23
%25 = load i64, i64* %24
store i64 %25, i64* %13
br label %26
26: ; preds = %17, %65
%27 = load i64, i64* %12
%28 = load i64, i64* %13
%29 = icmp slt i64 %27, %28
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = load i64*, i64** %8
%32 = load i64, i64* %10
%33 = trunc i64 %32 to i32
%34 = load i64, i64* %9
%35 = trunc i64 %34 to i32
%36 = load i64, i64* %13
%37 = call i64 @advanceUntil(i64* %31, i32 %33, i32 %35, i64 %36)
store i64 %37, i64* %10
%38 = load i64, i64* %10
%39 = load i64, i64* %9
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %30
br label %66
42: ; preds = %30
%43 = load i64*, i64** %8
%44 = load i64, i64* %10
%45 = getelementptr inbounds i64, i64* %43, i64 %44
%46 = load i64, i64* %45
store i64 %46, i64* %12
br label %65
47: ; preds = %26
%48 = load i64, i64* %13
%49 = load i64, i64* %12
%50 = icmp slt i64 %48, %49
br i1 %50, label %51, label %63
51: ; preds = %47
%52 = load i64, i64* %11
%53 = add i64 %52, 1
store i64 %53, i64* %11
%54 = load i64, i64* %11
%55 = load i64, i64* %7
%56 = icmp eq i64 %54, %55
br i1 %56, label %57, label %58
57: ; preds = %51
br label %66
58: ; preds = %51
%59 = load i64*, i64** %6
%60 = load i64, i64* %11
%61 = getelementptr inbounds i64, i64* %59, i64 %60
%62 = load i64, i64* %61
store i64 %62, i64* %13
br label %64
63: ; preds = %47
store i32 1, i32* %5
br label %67
64: ; preds = %58
br label %65
65: ; preds = %64, %42
br label %26
66: ; preds = %57, %41
store i32 0, i32* %5
br label %67
67: ; preds = %66, %63, %16
%68 = load i32, i32* %5
ret i32 %68
}

LLVM IR (-O2):
define i32 @intersect_skewed_uint16_nonempty(i64* nocapture %0, i64 %1, i64* %2, i64 %3) {
%5 = icmp eq i64 %1, 0
br i1 %5, label %33, label %6
6: ; preds = %4
%7 = load i64, i64* %0
%8 = trunc i64 %3 to i32
br label %9
9: ; preds = %23, %6
%10 = phi i64 [ %21, %23 ], [ 0, %6 ]
%11 = phi i64 [ %16, %23 ], [ 0, %6 ]
%12 = phi i64* [ %24, %23 ], [ %2, %6 ]
%13 = phi i64 [ %17, %23 ], [ %7, %6 ]
%14 = load i64, i64* %12
br label %15
15: ; preds = %9, %30
%16 = phi i64 [ %28, %30 ], [ %11, %9 ]
%17 = phi i64 [ %32, %30 ], [ %13, %9 ]
%18 = icmp slt i64 %14, %17
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = trunc i64 %10 to i32
%21 = tail call i64 @advanceUntil(i64* %2, i32 %20, i32 %8, i64 %17)
%22 = icmp eq i64 %21, %3
br i1 %22, label %33, label %23
23: ; preds = %19
%24 = getelementptr inbounds i64, i64* %2, i64 %21
br label %9
25: ; preds = %15
%26 = icmp slt i64 %17, %14
br i1 %26, label %27, label %33
27: ; preds = %25
%28 = add i64 %16, 1
%29 = icmp eq i64 %28, %1
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = getelementptr inbounds i64, i64* %0, i64 %28
%32 = load i64, i64* %31
br label %15
33: ; preds = %25, %27, %19, %4
%34 = phi i32 [ 0, %4 ], [ 1, %25 ], [ 0, %27 ], [ 0, %19 ]
ret i32 %34
}