#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 FILENAME_MAX;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ output_vcf_header(int /*<<< orphan*/ *, char **, int, int);
int /*<<< orphan*/ output_vcf_snps(int /*<<< orphan*/ *, char **, int *, int,
                                   int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void create_vcf_file(char filename[], int snp_locations[], int number_of_snps,
                     char **bases_for_snps, char **sequence_names,
                     int number_of_samples, size_t length_of_genome,
                     char pseudo_reference_sequence[]) {
  FILE *vcf_file_pointer;
  char *base_filename;
  base_filename = (char *)malloc(FILENAME_MAX * sizeof(char));
  strcpy(base_filename, filename);
  vcf_file_pointer = fopen(base_filename, "w");
  output_vcf_header(vcf_file_pointer, sequence_names, number_of_samples,
                    (int)length_of_genome);
  output_vcf_snps(vcf_file_pointer, bases_for_snps, snp_locations,
                  number_of_snps, number_of_samples, pseudo_reference_sequence);
  fclose(vcf_file_pointer);
  free(base_filename);
}


x86 assembly (clang, -O0):
<create_vcf_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
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    %r9d,-0x2c(%rbp)
mov    0x2e4a(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    0x10(%rbp),%rax
mov    %eax,%ecx
call   1090 <output_vcf_header@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    0x18(%rbp),%r9
call   1060 <output_vcf_snps@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_vcf_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r13d
mov    %r8,%r14
mov    %rcx,0x20(%rsp)
mov    %edx,0xc(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%r15
mov    0x68(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x60(%rsp),%r12d
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xe39(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1090 <output_vcf_header@plt>
mov    %rbx,%rdi
mov    0x20(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    %r13d,%r8d
mov    0x18(%rsp),%r9
call   1060 <output_vcf_snps@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@.str = [2 x i8] c"w\00"
define void @create_vcf_file(i8* %0, i32* %1, i32 %2, i8** %3, i8** %4, i32 %5, i64 %6, i8* %7) {
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i32*
%18 = alloca i8*
store i8* %0, i8** %9
store i32* %1, i32** %10
store i32 %2, i32* %11
store i8** %3, i8*** %12
store i8** %4, i8*** %13
store i32 %5, i32* %14
store i64 %6, i64* %15
store i8* %7, i8** %16
%19 = load i32, i32* @FILENAME_MAX
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %18
%25 = load i8*, i8** %18
%26 = load i8*, i8** %9
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %18
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %17
%30 = load i32*, i32** %17
%31 = load i8**, i8*** %13
%32 = load i32, i32* %14
%33 = load i64, i64* %15
%34 = trunc i64 %33 to i32
%35 = call i32 @output_vcf_header(i32* %30, i8** %31, i32 %32, i32 %34)
%36 = load i32*, i32** %17
%37 = load i8**, i8*** %12
%38 = load i32*, i32** %10
%39 = load i32, i32* %11
%40 = load i32, i32* %14
%41 = load i8*, i8** %16
%42 = call i32 @output_vcf_snps(i32* %36, i8** %37, i32* %38, i32 %39, i32 %40, i8* %41)
%43 = load i32*, i32** %17
%44 = call i32 @fclose(i32* %43)
%45 = load i8*, i8** %18
%46 = call i32 @free(i8* %45)
ret void
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@.str = [2 x i8] c"w\00"
define void @create_vcf_file(i8* %0, i32* %1, i32 %2, i8** %3, i8** %4, i32 %5, i64 %6, i8* %7) {
%9 = load i32, i32* @FILENAME_MAX
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @strcpy(i8* %11, i8* %0)
%13 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = trunc i64 %6 to i32
%15 = tail call i32 @output_vcf_header(i32* %13, i8** %4, i32 %5, i32 %14)
%16 = tail call i32 @output_vcf_snps(i32* %13, i8** %3, i32* %1, i32 %2, i32 %5, i8* %7)
%17 = tail call i32 @fclose(i32* %13)
%18 = tail call i32 @free(i8* %11)
ret void
}