#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_starting_index(int, int *, int, int);
char toupper(char);
int advance_window_start_to_next_snp_with_start_end_index(
    int window_start_coordinate, int *snp_locations, char *child_sequence,
    int number_of_branch_snps, int start_index, int end_index) {
  int i;
  start_index = find_starting_index(window_start_coordinate, snp_locations,
                                    start_index, end_index);
  for (i = start_index; i < number_of_branch_snps; i++) {
    if (snp_locations[i] >= window_start_coordinate &&
        child_sequence[i] != '-' && toupper(child_sequence[i]) != 'N') {
      return snp_locations[i];
    }
    if (i + 1 == number_of_branch_snps &&
        snp_locations[i] > window_start_coordinate) {
      return snp_locations[i];
    }
  }
  return window_start_coordinate;
}


x86 assembly (clang, -O0):
<advance_window_start_to_next_snp_with_start_end_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1040 <find_starting_index@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1207 <advance_window_start_to_next_snp_with_start_end_index+0xe7>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jl     11be <advance_window_start_to_next_snp_with_start_end_index+0x9e>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11be <advance_window_start_to_next_snp_with_start_end_index+0x9e>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x4e,%eax
je     11be <advance_window_start_to_next_snp_with_start_end_index+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    120d <advance_window_start_to_next_snp_with_start_end_index+0xed>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    11f4 <advance_window_start_to_next_snp_with_start_end_index+0xd4>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jle    11f4 <advance_window_start_to_next_snp_with_start_end_index+0xd4>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    120d <advance_window_start_to_next_snp_with_start_end_index+0xed>
jmp    11f9 <advance_window_start_to_next_snp_with_start_end_index+0xd9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1159 <advance_window_start_to_next_snp_with_start_end_index+0x39>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<advance_window_start_to_next_snp_with_start_end_index>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r13d
mov    %r8d,%edx
mov    %r9d,%ecx
call   1040 <find_starting_index@plt>
mov    %eax,%ebp
sub    %r12d,%ebp
jge    119b <advance_window_start_to_next_snp_with_start_end_index+0x7b>
cltq
lea    (%r15,%rax,4),%r15
add    %rax,%r14
xor    %ebx,%ebx
jmp    1172 <advance_window_start_to_next_snp_with_start_end_index+0x52>
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%eax
cmp    $0xffffffff,%eax
je     1190 <advance_window_start_to_next_snp_with_start_end_index+0x70>
add    $0x1,%rbx
mov    %ebx,%eax
add    %ebp,%eax
je     119b <advance_window_start_to_next_snp_with_start_end_index+0x7b>
cmp    %r13d,(%r15,%rbx,4)
jl     1160 <advance_window_start_to_next_snp_with_start_end_index+0x40>
movzbl (%r14,%rbx,1),%eax
cmp    $0x2d,%al
je     1160 <advance_window_start_to_next_snp_with_start_end_index+0x40>
movsbl %al,%edi
call   1030 <toupper@plt>
cmp    $0x4e,%al
je     1160 <advance_window_start_to_next_snp_with_start_end_index+0x40>
jmp    11ad <advance_window_start_to_next_snp_with_start_end_index+0x8d>
nop
mov    (%r15,%rbx,4),%eax
cmp    %r13d,%eax
jle    1168 <advance_window_start_to_next_snp_with_start_end_index+0x48>
jmp    119e <advance_window_start_to_next_snp_with_start_end_index+0x7e>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15,%rbx,4),%eax
jmp    119e <advance_window_start_to_next_snp_with_start_end_index+0x7e>

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

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