int calculate_number_of_snps_excluding_gaps(
    char *ancestor_sequence, char *child_sequence, int child_sequence_size,
    int *branch_snp_coords, int *snp_locations, char *branch_snp_sequence,
    char *branch_snp_ancestor_sequence) {
  int i;
  int number_of_branch_snp_sites = 0;
  for (i = 0; i < child_sequence_size; i++) {
    branch_snp_coords[i] = 0;
    if (ancestor_sequence[i] == '\0' || child_sequence[i] == '\0') {
      break;
    }
    if (child_sequence[i] != ancestor_sequence[i] && child_sequence[i] != '-' &&
        child_sequence[i] != 'N' && child_sequence[i] != '.' &&
        ancestor_sequence[i] != '-' && ancestor_sequence[i] != 'N') {
      branch_snp_coords[number_of_branch_snp_sites] = snp_locations[i];
      branch_snp_sequence[number_of_branch_snp_sites] = child_sequence[i];
      branch_snp_ancestor_sequence[number_of_branch_snp_sites] =
          ancestor_sequence[i];
      number_of_branch_snp_sites++;
    }
  }
  branch_snp_sequence[number_of_branch_snp_sites] = '\0';
  branch_snp_ancestor_sequence[number_of_branch_snp_sites] = '\0';
  return number_of_branch_snp_sites;
}


x86 assembly (clang, -O0):
<calculate_number_of_snps_excluding_gaps>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125e <calculate_number_of_snps_excluding_gaps+0x15e>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1172 <calculate_number_of_snps_excluding_gaps+0x72>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1177 <calculate_number_of_snps_excluding_gaps+0x77>
jmp    125e <calculate_number_of_snps_excluding_gaps+0x15e>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x4e,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x4e,%eax
je     124b <calculate_number_of_snps_excluding_gaps+0x14b>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1250 <calculate_number_of_snps_excluding_gaps+0x150>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    112d <calculate_number_of_snps_excluding_gaps+0x2d>
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_number_of_snps_excluding_gaps>:
push   %r14
push   %rbx
mov    0x18(%rsp),%r10
test   %edx,%edx
jle    117b <calculate_number_of_snps_excluding_gaps+0x7b>
mov    %edx,%r11d
xor    %edx,%edx
xor    %r14d,%r14d
jmp    1129 <calculate_number_of_snps_excluding_gaps+0x29>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rdx
cmp    %rdx,%r11
je     117e <calculate_number_of_snps_excluding_gaps+0x7e>
movl   $0x0,(%rcx,%rdx,4)
movzbl (%rdi,%rdx,1),%ebx
test   %bl,%bl
je     117e <calculate_number_of_snps_excluding_gaps+0x7e>
movzbl (%rsi,%rdx,1),%eax
test   %al,%al
je     117e <calculate_number_of_snps_excluding_gaps+0x7e>
cmp    $0x2e,%al
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
cmp    $0x4e,%al
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
cmp    %bl,%al
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
cmp    $0x2d,%al
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
cmp    $0x2d,%bl
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
cmp    $0x4e,%bl
je     1120 <calculate_number_of_snps_excluding_gaps+0x20>
mov    (%r8,%rdx,4),%eax
movslq %r14d,%r14
mov    %eax,(%rcx,%r14,4)
movzbl (%rsi,%rdx,1),%eax
mov    %al,(%r9,%r14,1)
movzbl (%rdi,%rdx,1),%eax
mov    %al,(%r10,%r14,1)
add    $0x1,%r14d
jmp    1120 <calculate_number_of_snps_excluding_gaps+0x20>
xor    %r14d,%r14d
movslq %r14d,%rax
movb   $0x0,(%r9,%rax,1)
movb   $0x0,(%r10,%rax,1)
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @calculate_number_of_snps_excluding_gaps(i8* %0, i8* %1, i32 %2, i32* %3, i32* %4, i8* %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i8* %5, i8** %13
store i8* %6, i8** %14
store i32 0, i32* %16
store i32 0, i32* %15
br label %17
17: ; preds = %127, %7
%18 = load i32, i32* %15
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %130
21: ; preds = %17
%22 = load i32*, i32** %11
%23 = load i32, i32* %15
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 0, i32* %25
%26 = load i8*, i8** %8
%27 = load i32, i32* %15
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %21
%34 = load i8*, i8** %9
%35 = load i32, i32* %15
%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 eq i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33, %21
br label %130
42: ; preds = %33
%43 = load i8*, i8** %9
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = load i8*, i8** %8
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %48, %54
br i1 %55, label %56, label %126
56: ; preds = %42
%57 = load i8*, i8** %9
%58 = load i32, i32* %15
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 45
br i1 %63, label %64, label %126
64: ; preds = %56
%65 = load i8*, i8** %9
%66 = load i32, i32* %15
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 78
br i1 %71, label %72, label %126
72: ; preds = %64
%73 = load i8*, i8** %9
%74 = load i32, i32* %15
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp ne i32 %78, 46
br i1 %79, label %80, label %126
80: ; preds = %72
%81 = load i8*, i8** %8
%82 = load i32, i32* %15
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp ne i32 %86, 45
br i1 %87, label %88, label %126
88: ; preds = %80
%89 = load i8*, i8** %8
%90 = load i32, i32* %15
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %89, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 78
br i1 %95, label %96, label %126
96: ; preds = %88
%97 = load i32*, i32** %12
%98 = load i32, i32* %15
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i32, i32* %97, i64 %99
%101 = load i32, i32* %100
%102 = load i32*, i32** %11
%103 = load i32, i32* %16
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %102, i64 %104
store i32 %101, i32* %105
%106 = load i8*, i8** %9
%107 = load i32, i32* %15
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
%110 = load i8, i8* %109
%111 = load i8*, i8** %13
%112 = load i32, i32* %16
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
store i8 %110, i8* %114
%115 = load i8*, i8** %8
%116 = load i32, i32* %15
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
%119 = load i8, i8* %118
%120 = load i8*, i8** %14
%121 = load i32, i32* %16
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %120, i64 %122
store i8 %119, i8* %123
%124 = load i32, i32* %16
%125 = add nsw i32 %124, 1
store i32 %125, i32* %16
br label %126
126: ; preds = %96, %88, %80, %72, %64, %56, %42
br label %127
127: ; preds = %126
%128 = load i32, i32* %15
%129 = add nsw i32 %128, 1
store i32 %129, i32* %15
br label %17
130: ; preds = %41, %17
%131 = load i8*, i8** %13
%132 = load i32, i32* %16
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %131, i64 %133
store i8 0, i8* %134
%135 = load i8*, i8** %14
%136 = load i32, i32* %16
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %135, i64 %137
store i8 0, i8* %138
%139 = load i32, i32* %16
ret i32 %139
}

LLVM IR (-O2):
define i32 @calculate_number_of_snps_excluding_gaps(i8* nocapture %0, i8* nocapture %1, i32 %2, i32* nocapture writeonly %3, i32* nocapture %4, i8* nocapture writeonly %5, i8* nocapture writeonly %6) {
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %48
9: ; preds = %7
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %44
%12 = phi i64 [ 0, %9 ], [ %46, %44 ]
%13 = phi i32 [ 0, %9 ], [ %45, %44 ]
%14 = getelementptr inbounds i32, i32* %3, i64 %12
store i32 0, i32* %14
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %48, label %18
18: ; preds = %11
%19 = getelementptr inbounds i8, i8* %1, i64 %12
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %48, label %22
22: ; preds = %18
%23 = icmp eq i8 %20, %16
%24 = icmp eq i8 %20, 45
%25 = or i1 %23, %24
%26 = icmp eq i8 %20, 78
%27 = or i1 %26, %25
%28 = icmp eq i8 %20, 46
%29 = or i1 %28, %27
%30 = icmp eq i8 %16, 45
%31 = select i1 %29, i1 true, i1 %30
%32 = icmp eq i8 %16, 78
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %44, label %34
34: ; preds = %22
%35 = getelementptr inbounds i32, i32* %4, i64 %12
%36 = load i32, i32* %35
%37 = sext i32 %13 to i64
%38 = getelementptr inbounds i32, i32* %3, i64 %37
store i32 %36, i32* %38
%39 = load i8, i8* %19
%40 = getelementptr inbounds i8, i8* %5, i64 %37
store i8 %39, i8* %40
%41 = load i8, i8* %15
%42 = getelementptr inbounds i8, i8* %6, i64 %37
store i8 %41, i8* %42
%43 = add nsw i32 %13, 1
br label %44
44: ; preds = %22, %34
%45 = phi i32 [ %43, %34 ], [ %13, %22 ]
%46 = add nuw nsw i64 %12, 1
%47 = icmp eq i64 %46, %10
br i1 %47, label %48, label %11
48: ; preds = %44, %18, %11, %7
%49 = phi i32 [ 0, %7 ], [ %13, %11 ], [ %13, %18 ], [ %45, %44 ]
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %5, i64 %50
store i8 0, i8* %51
%52 = getelementptr inbounds i8, i8* %6, i64 %50
store i8 0, i8* %52
ret i32 %49
}