#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 size_t uint32_t;

/* Variables and functions */
bool ref_kmer_snp_proximity_check(const uint32_t pos, bool *snp_locations,
                                  size_t snp_locs_size) {
  if (pos >= snp_locs_size)
    return false;
  const uint32_t lo = pos > (101 - 32) ? pos - (101 - 32) : 0;
  const uint32_t hi =
      (pos < snp_locs_size - (101 - 1)) ? pos + (101 - 1) : snp_locs_size - 1;
  for (uint32_t i = lo; i <= hi; i++) {
    if (snp_locations[i])
      return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<ref_kmer_snp_proximity_check>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     112a <ref_kmer_snp_proximity_check+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <ref_kmer_snp_proximity_check+0xe4>
cmpq   $0x45,-0x10(%rbp)
jbe    1146 <ref_kmer_snp_proximity_check+0x46>
mov    -0x10(%rbp),%rax
sub    $0x45,%rax
mov    %rax,-0x40(%rbp)
jmp    1151 <ref_kmer_snp_proximity_check+0x51>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    1151 <ref_kmer_snp_proximity_check+0x51>
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x64,%rcx
cmp    %rcx,%rax
jae    117f <ref_kmer_snp_proximity_check+0x7f>
mov    -0x10(%rbp),%rax
add    $0x64,%rax
mov    %rax,-0x48(%rbp)
jmp    118b <ref_kmer_snp_proximity_check+0x8b>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     11dd <ref_kmer_snp_proximity_check+0xdd>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11c7 <ref_kmer_snp_proximity_check+0xc7>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <ref_kmer_snp_proximity_check+0xe4>
jmp    11cc <ref_kmer_snp_proximity_check+0xcc>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    119b <ref_kmer_snp_proximity_check+0x9b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ref_kmer_snp_proximity_check>:
xor    %eax,%eax
cmp    %rdx,%rdi
jae    115b <ref_kmer_snp_proximity_check+0x5b>
xor    %eax,%eax
mov    %rdi,%rcx
sub    $0x45,%rcx
mov    $0x0,%r8d
cmovae %rcx,%r8
lea    -0x64(%rdx),%rcx
lea    0x64(%rdi),%r9
add    $0xffffffffffffffff,%rdx
cmp    %rdi,%rcx
cmova  %r9,%rdx
cmp    %rdx,%r8
ja     115b <ref_kmer_snp_proximity_check+0x5b>
xor    %eax,%eax
sub    $0x45,%rdi
cmovae %rdi,%rax
add    $0x1,%rax
mov    -0x4(%rsi,%rax,4),%ecx
test   %ecx,%ecx
jne    1154 <ref_kmer_snp_proximity_check+0x54>
lea    0x1(%rax),%rdi
cmp    %rdx,%rax
mov    %rdi,%rax
jbe    1140 <ref_kmer_snp_proximity_check+0x40>
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
ret

LLVM IR (-O0):
define i32 @ref_kmer_snp_proximity_check(i64 %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %5
store i32* %1, i32** %6
store i64 %2, i64* %7
%11 = load i64, i64* %5
%12 = load i64, i64* %7
%13 = icmp uge i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %53
15: ; preds = %3
%16 = load i64, i64* %5
%17 = icmp ugt i64 %16, 69
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i64, i64* %5
%20 = sub i64 %19, 69
br label %22
21: ; preds = %15
br label %22
22: ; preds = %21, %18
%23 = phi i64 [ %20, %18 ], [ 0, %21 ]
store i64 %23, i64* %8
%24 = load i64, i64* %5
%25 = load i64, i64* %7
%26 = sub i64 %25, 100
%27 = icmp ult i64 %24, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i64, i64* %5
%30 = add i64 %29, 100
br label %34
31: ; preds = %22
%32 = load i64, i64* %7
%33 = sub i64 %32, 1
br label %34
34: ; preds = %31, %28
%35 = phi i64 [ %30, %28 ], [ %33, %31 ]
store i64 %35, i64* %9
%36 = load i64, i64* %8
store i64 %36, i64* %10
br label %37
37: ; preds = %49, %34
%38 = load i64, i64* %10
%39 = load i64, i64* %9
%40 = icmp ule i64 %38, %39
br i1 %40, label %41, label %52
41: ; preds = %37
%42 = load i32*, i32** %6
%43 = load i64, i64* %10
%44 = getelementptr inbounds i32, i32* %42, i64 %43
%45 = load i32, i32* %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 1, i32* %4
br label %53
48: ; preds = %41
br label %49
49: ; preds = %48
%50 = load i64, i64* %10
%51 = add i64 %50, 1
store i64 %51, i64* %10
br label %37
52: ; preds = %37
store i32 0, i32* %4
br label %53
53: ; preds = %52, %47, %14
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @ref_kmer_snp_proximity_check(i64 %0, i32* nocapture %1, i64 %2) {
%4 = icmp ult i64 %0, %2
br i1 %4, label %5, label %25
5: ; preds = %3
%6 = tail call i64 @llvm.usub.sat.i64(i64 %0, i64 69)
%7 = add i64 %2, -100
%8 = icmp ugt i64 %7, %0
%9 = add i64 %0, 100
%10 = add i64 %2, -1
%11 = select i1 %8, i64 %9, i64 %10
%12 = icmp ugt i64 %6, %11
br i1 %12, label %25, label %13
13: ; preds = %5, %13
%14 = phi i64 [ %18, %13 ], [ %6, %5 ]
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
%18 = add i64 %14, 1
%19 = xor i1 %17, true
%20 = icmp ugt i64 %18, %11
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %13
22: ; preds = %13
%23 = xor i1 %17, true
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %5, %22, %3
%26 = phi i32 [ 0, %3 ], [ 0, %5 ], [ %24, %22 ]
ret i32 %26
}