#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void create_phylib_of_snp_sites(char filename[], int number_of_snps,
                                char **bases_for_snps, char **sequence_names,
                                int number_of_samples, int output_reference,
                                char *pseudo_reference_sequence,
                                int snp_locations[]) {
  FILE *phylip_file_pointer;
  int sample_counter;
  int snp_counter;
  phylip_file_pointer = fopen(filename, "w");
  if (output_reference == 1) {
    fprintf(phylip_file_pointer, "%d %d\n", number_of_samples + 1,
            number_of_snps);
    fprintf(phylip_file_pointer, "pseudo_reference_sequence\t");
    for (snp_counter = 0; snp_counter < number_of_snps; snp_counter++) {
      fputc(pseudo_reference_sequence[snp_locations[snp_counter]],
            phylip_file_pointer);
    }
    fprintf(phylip_file_pointer, "\n");
  } else {
    fprintf(phylip_file_pointer, "%d %d\n", number_of_samples, number_of_snps);
  }
  for (sample_counter = 0; sample_counter < number_of_samples;
       sample_counter++) {
    fprintf(phylip_file_pointer, "%s\t", sequence_names[sample_counter]);
    for (snp_counter = 0; snp_counter < number_of_snps; snp_counter++) {
      fputc(bases_for_snps[snp_counter][sample_counter], phylip_file_pointer);
    }
    fprintf(phylip_file_pointer, "\n");
  }
  fclose(phylip_file_pointer);
}


x86 assembly (clang, -O0):
<create_phylib_of_snp_sites>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    1209 <create_phylib_of_snp_sites+0xc9>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
mov    -0xc(%rbp),%ecx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f2 <create_phylib_of_snp_sites+0xb2>
mov    0x10(%rbp),%rax
mov    0x18(%rbp),%rcx
movslq -0x38(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x30(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b9 <create_phylib_of_snp_sites+0x79>
mov    -0x30(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1221 <create_phylib_of_snp_sites+0xe1>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12b2 <create_phylib_of_snp_sites+0x172>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1292 <create_phylib_of_snp_sites+0x152>
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x30(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1259 <create_phylib_of_snp_sites+0x119>
mov    -0x30(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1228 <create_phylib_of_snp_sites+0xe8>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_phylib_of_snp_sites>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x8(%rsp)
mov    %r8d,%r15d
mov    %rcx,0x10(%rsp)
mov    %rdx,%rbx
mov    %esi,%r14d
mov    0x58(%rsp),%r12
mov    0x50(%rsp),%r13
lea    0xe7e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
cmpl   $0x1,0x8(%rsp)
mov    %r14d,0x4(%rsp)
jne    1217 <create_phylib_of_snp_sites+0xc7>
mov    %r15,0x8(%rsp)
lea    0x1(%r15),%edx
lea    0xe58(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1070 <fwrite@plt>
test   %r14d,%r14d
jle    11fb <create_phylib_of_snp_sites+0xab>
mov    0x4(%rsp),%r14d
xor    %r15d,%r15d
nopl   (%rax)
movslq (%r12,%r15,4),%rax
movsbl 0x0(%r13,%rax,1),%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    11e0 <create_phylib_of_snp_sites+0x90>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
mov    0x8(%rsp),%r15
test   %r15d,%r15d
jg     1233 <create_phylib_of_snp_sites+0xe3>
jmp    129c <create_phylib_of_snp_sites+0x14c>
lea    0xde4(%rip),%rsi
mov    %rbp,%rdi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r15d,%r15d
jle    129c <create_phylib_of_snp_sites+0x14c>
mov    %r15d,%r13d
mov    0x4(%rsp),%r14d
xor    %r15d,%r15d
jmp    1256 <create_phylib_of_snp_sites+0x106>
mov    $0xa,%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
add    $0x1,%r15
cmp    %r13,%r15
je     129c <create_phylib_of_snp_sites+0x14c>
mov    0x10(%rsp),%rax
mov    (%rax,%r15,8),%rdx
mov    %rbp,%rdi
lea    0xdbb(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1240 <create_phylib_of_snp_sites+0xf0>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r12,8),%rax
movsbl (%rax,%r15,1),%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    1280 <create_phylib_of_snp_sites+0x130>
jmp    1240 <create_phylib_of_snp_sites+0xf0>
mov    %rbp,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [27 x i8] c"pseudo_reference_sequence\09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [4 x i8] c"%s\09\00"
define void @create_phylib_of_snp_sites(i8* %0, i32 %1, i8** %2, i8** %3, i32 %4, i32 %5, i8* %6, i32* %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8** %2, i8*** %11
store i8** %3, i8*** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i32* %7, i32** %16
%20 = load i8*, i8** %9
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %17
%22 = load i32, i32* %14
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %54
24: ; preds = %8
%25 = load i32*, i32** %17
%26 = load i32, i32* %13
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %10
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32*, i32** %17
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %19
br label %32
32: ; preds = %48, %24
%33 = load i32, i32* %19
%34 = load i32, i32* %10
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %51
36: ; preds = %32
%37 = load i8*, i8** %15
%38 = load i32*, i32** %16
%39 = load i32, i32* %19
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %37, i64 %43
%45 = load i8, i8* %44
%46 = load i32*, i32** %17
%47 = call i32 @fputc(i8 signext %45, i32* %46)
br label %48
48: ; preds = %36
%49 = load i32, i32* %19
%50 = add nsw i32 %49, 1
store i32 %50, i32* %19
br label %32
51: ; preds = %32
%52 = load i32*, i32** %17
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %59
54: ; preds = %8
%55 = load i32*, i32** %17
%56 = load i32, i32* %13
%57 = load i32, i32* %10
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %57)
br label %59
59: ; preds = %54, %51
store i32 0, i32* %18
br label %60
60: ; preds = %94, %59
%61 = load i32, i32* %18
%62 = load i32, i32* %13
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %97
64: ; preds = %60
%65 = load i32*, i32** %17
%66 = load i8**, i8*** %12
%67 = load i32, i32* %18
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %70)
store i32 0, i32* %19
br label %72
72: ; preds = %88, %64
%73 = load i32, i32* %19
%74 = load i32, i32* %10
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %91
76: ; preds = %72
%77 = load i8**, i8*** %11
%78 = load i32, i32* %19
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = load i32, i32* %18
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = load i32*, i32** %17
%87 = call i32 @fputc(i8 signext %85, i32* %86)
br label %88
88: ; preds = %76
%89 = load i32, i32* %19
%90 = add nsw i32 %89, 1
store i32 %90, i32* %19
br label %72
91: ; preds = %72
%92 = load i32*, i32** %17
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %94
94: ; preds = %91
%95 = load i32, i32* %18
%96 = add nsw i32 %95, 1
store i32 %96, i32* %18
br label %60
97: ; preds = %60
%98 = load i32*, i32** %17
%99 = call i32 @fclose(i32* %98)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [27 x i8] c"pseudo_reference_sequence\09\00"
@.str.4 = [4 x i8] c"%s\09\00"
define void @create_phylib_of_snp_sites(i8* nocapture %0, i32 %1, i8** nocapture %2, i8** nocapture %3, i32 %4, i32 %5, i8* nocapture %6, i32* nocapture %7) {
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %5, 1
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = add nsw i32 %4, 1
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %1)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 26, i64 1, i32* %9)
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = zext i32 %1 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %26, %18 ]
%20 = getelementptr inbounds i32, i32* %7, i64 %19
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %6, i64 %22
%24 = load i8, i8* %23
%25 = tail call i32 @fputc(i8 signext %24, i32* %9)
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %28, label %18
28: ; preds = %18, %11
%29 = tail call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 10, i32* %9)
br label %32
30: ; preds = %8
%31 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %1)
br label %32
32: ; preds = %30, %28
%33 = icmp sgt i32 %4, 0
br i1 %33, label %34, label %56
34: ; preds = %32
%35 = icmp sgt i32 %1, 0
%36 = zext i32 %4 to i64
%37 = zext i32 %1 to i64
br label %38
38: ; preds = %34, %52
%39 = phi i64 [ 0, %34 ], [ %54, %52 ]
%40 = getelementptr inbounds i8*, i8** %3, i64 %39
%41 = load i8*, i8** %40
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %41)
br i1 %35, label %43, label %52
43: ; preds = %38, %43
%44 = phi i64 [ %50, %43 ], [ 0, %38 ]
%45 = getelementptr inbounds i8*, i8** %2, i64 %44
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i64 %39
%48 = load i8, i8* %47
%49 = tail call i32 @fputc(i8 signext %48, i32* %9)
%50 = add nuw nsw i64 %44, 1
%51 = icmp eq i64 %50, %37
br i1 %51, label %52, label %43
52: ; preds = %43, %38
%53 = tail call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 10, i32* %9)
%54 = add nuw nsw i64 %39, 1
%55 = icmp eq i64 %54, %36
br i1 %55, label %56, label %38
56: ; preds = %52, %32
%57 = tail call i32 @fclose(i32* %9)
ret void
}