#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 find_matching_coordinate_index(int, int *, int, int);
int find_starting_index(int, int *, int /*<<< orphan*/, int);
int flag_recombinations_in_window(int window_start_coordinate,
                                  int window_end_coordinate, int number_of_snps,
                                  int *branch_snp_sites, int *recombinations,
                                  int number_of_recombinations,
                                  int *snp_locations, int total_num_snps) {
  int i;
  int number_of_snps_in_block = 0;
  int start_index = find_starting_index(window_start_coordinate,
                                        branch_snp_sites, 0, number_of_snps);
  for (i = start_index; i < number_of_snps; i++) {
    if (branch_snp_sites[i] >= window_start_coordinate &&
        branch_snp_sites[i] <= window_end_coordinate) {
      recombinations[number_of_recombinations + number_of_snps_in_block] =
          find_matching_coordinate_index(branch_snp_sites[i], snp_locations,
                                         total_num_snps, i);
      number_of_snps_in_block++;
    }
    if (branch_snp_sites[i] > window_end_coordinate) {
      break;
    }
  }
  return number_of_snps_in_block;
}


x86 assembly (clang, -O0):
<flag_recombinations_in_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
call   1040 <find_starting_index@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fa <flag_recombinations_in_window+0xda>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jl     11ce <flag_recombinations_in_window+0xae>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jg     11ce <flag_recombinations_in_window+0xae>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x10(%rbp),%rsi
mov    0x18(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1030 <find_matching_coordinate_index@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jle    11e7 <flag_recombinations_in_window+0xc7>
jmp    11fa <flag_recombinations_in_window+0xda>
jmp    11ec <flag_recombinations_in_window+0xcc>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1165 <flag_recombinations_in_window+0x45>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flag_recombinations_in_window>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r13
mov    %edx,%r15d
mov    %esi,%ebp
xor    %ebx,%ebx
mov    %edi,0x4(%rsp)
mov    %rcx,%rsi
xor    %edx,%edx
mov    %r15d,%ecx
call   1040 <find_starting_index@plt>
cmp    %r15d,%eax
jge    11bf <flag_recombinations_in_window+0x9f>
mov    %eax,%r14d
movslq %eax,%r12
movslq %r15d,%r15
add    $0x1,%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    -0x4(%r13,%r12,4),%edi
cmp    0x4(%rsp),%edi
jl     11aa <flag_recombinations_in_window+0x8a>
cmp    %ebp,%edi
jg     11aa <flag_recombinations_in_window+0x8a>
mov    0x50(%rsp),%rsi
mov    0x58(%rsp),%edx
mov    %r14d,%ecx
call   1030 <find_matching_coordinate_index@plt>
mov    0x10(%rsp),%rcx
add    %ebx,%ecx
movslq %ecx,%rcx
mov    0x8(%rsp),%rdx
mov    %eax,(%rdx,%rcx,4)
add    $0x1,%ebx
mov    -0x4(%r13,%r12,4),%edi
cmp    %ebp,%edi
jg     11bf <flag_recombinations_in_window+0x9f>
add    $0x1,%r14d
lea    0x1(%r12),%rax
cmp    %r15,%r12
mov    %rax,%r12
jl     1170 <flag_recombinations_in_window+0x50>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @flag_recombinations_in_window(i32 %0, i32 %1, i32 %2, i32* %3, i32* nocapture writeonly %4, i32 %5, i32* %6, i32 %7) {
%9 = tail call i32 @find_starting_index(i32 %0, i32* %3, i32 0, i32 %2)
%10 = icmp slt i32 %9, %2
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = sext i32 %9 to i64
%13 = sext i32 %2 to i64
br label %14
14: ; preds = %30, %11
%15 = phi i64 [ %34, %30 ], [ %12, %11 ]
%16 = phi i32 [ %32, %30 ], [ 0, %11 ]
%17 = getelementptr inbounds i32, i32* %3, i64 %15
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, %0
%20 = icmp sgt i32 %18, %1
%21 = or i1 %19, %20
br i1 %21, label %30, label %22
22: ; preds = %14
%23 = trunc i64 %15 to i32
%24 = tail call i32 @find_matching_coordinate_index(i32 %18, i32* %6, i32 %7, i32 %23)
%25 = add nsw i32 %16, %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %4, i64 %26
store i32 %24, i32* %27
%28 = add nsw i32 %16, 1
%29 = load i32, i32* %17
br label %30
30: ; preds = %22, %14
%31 = phi i32 [ %29, %22 ], [ %18, %14 ]
%32 = phi i32 [ %28, %22 ], [ %16, %14 ]
%33 = icmp sle i32 %31, %1
%34 = add nsw i64 %15, 1
%35 = icmp slt i64 %34, %13
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %14, label %37
37: ; preds = %30, %8
%38 = phi i32 [ 0, %8 ], [ %32, %30 ]
ret i32 %38
}