#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *read_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ split_string_and_return_specific_index(char *, char *, int,
                                                          int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void get_column_names(FILE *vcf_file_pointer, char **column_names,
                      int number_of_columns) {
  rewind(vcf_file_pointer);
  char *szBuffer;
  szBuffer = (char *)calloc(65536, sizeof(char));
  char result[100] = {0};
  int i;
  do {
    szBuffer[0] = '\0';
    szBuffer = read_line(szBuffer, vcf_file_pointer);
    if (szBuffer[0] == '\0' || szBuffer[0] != '#') {
      break;
    }
    split_string_and_return_specific_index(result, szBuffer, 0, 100000);
    if (strcmp(result, "#CHROM") == 0) {
      for (i = 0; i < number_of_columns; i++) {
        split_string_and_return_specific_index(result, szBuffer, i, 100000);
        memcpy(column_names[i], result, (strlen(result) + 1) * sizeof(char));
      }
    }
  } while (szBuffer[0] != '\0');
  free(szBuffer);
}


x86 assembly (clang, -O0):
<get_column_names>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rewind@plt>
mov    $0x10000,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10a0 <read_line@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120d <get_column_names+0x7d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1212 <get_column_names+0x82>
jmp    12f6 <get_column_names+0x166>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
mov    $0x186a0,%ecx
call   10b0 <split_string_and_return_specific_index@plt>
lea    -0x90(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12e1 <get_column_names+0x151>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12dc <get_column_names+0x14c>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x94(%rbp),%edx
mov    $0x186a0,%ecx
call   10b0 <split_string_and_return_specific_index@plt>
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1250 <get_column_names+0xc0>
jmp    12e1 <get_column_names+0x151>
jmp    12e6 <get_column_names+0x156>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d5 <get_column_names+0x45>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_column_names>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edx,%ebx
mov    %rsi,%r12
mov    %rdi,0x8(%rsp)
call   1050 <rewind@plt>
mov    $0x10000,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
mov    %ebx,0x4(%rsp)
mov    %ebx,%r15d
lea    0x10(%rsp),%rbx
jmp    11fa <get_column_names+0x7a>
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,0x0(%rbp)
je     128b <get_column_names+0x10b>
movb   $0x0,0x0(%rbp)
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
call   1090 <read_line@plt>
mov    %rax,%rbp
cmpb   $0x23,(%rax)
jne    128b <get_column_names+0x10b>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
mov    $0x186a0,%ecx
call   10a0 <split_string_and_return_specific_index@plt>
mov    %rbx,%rdi
lea    0xdd1(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11f0 <get_column_names+0x70>
cmpl   $0x0,0x4(%rsp)
jle    11f0 <get_column_names+0x70>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    $0x186a0,%ecx
call   10a0 <split_string_and_return_specific_index@plt>
mov    (%r12,%r13,8),%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <memcpy@plt>
add    $0x1,%r13
cmp    %r13,%r15
jne    1250 <get_column_names+0xd0>
jmp    11f0 <get_column_names+0x70>
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"#CHROM\00"
define void @get_column_names(i32* %0, i8** %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [100 x i8]
%9 = alloca i32
store i32* %0, i32** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%10 = load i32*, i32** %4
%11 = call i32 @rewind(i32* %10)
%12 = call i64 @calloc(i32 65536, i32 1)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = bitcast [100 x i8]* %8 to i8*
br label %15
15: ; preds = %68, %3
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 0, i8* %17
%18 = load i8*, i8** %7
%19 = load i32*, i32** %4
%20 = call i8* @read_line(i8* %18, i32* %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %15
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 35
br i1 %31, label %32, label %33
32: ; preds = %26, %15
br label %74
33: ; preds = %26
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%35 = load i8*, i8** %7
%36 = call i32 @split_string_and_return_specific_index(i8* %34, i8* %35, i32 0, i32 100000)
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %67
40: ; preds = %33
store i32 0, i32* %9
br label %41
41: ; preds = %63, %40
%42 = load i32, i32* %9
%43 = load i32, i32* %6
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %66
45: ; preds = %41
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%47 = load i8*, i8** %7
%48 = load i32, i32* %9
%49 = call i32 @split_string_and_return_specific_index(i8* %46, i8* %47, i32 %48, i32 100000)
%50 = load i8**, i8*** %5
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = add nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 1
%61 = trunc i64 %60 to i32
%62 = call i32 @memcpy(i8* %54, i8* %55, i32 %61)
br label %63
63: ; preds = %45
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %41
66: ; preds = %41
br label %67
67: ; preds = %66, %33
br label %68
68: ; preds = %67
%69 = load i8*, i8** %7
%70 = getelementptr inbounds i8, i8* %69, i64 0
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %15, label %74
74: ; preds = %68, %32
%75 = load i8*, i8** %7
%76 = call i32 @free(i8* %75)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"#CHROM\00"
define void @get_column_names(i32* %0, i8** nocapture %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = tail call i32 @rewind(i32* %0)
%6 = tail call i64 @calloc(i32 65536, i32 1)
%7 = inttoptr i64 %6 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = icmp slt i32 %2, 1
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %32, %3
%12 = phi i8* [ %7, %3 ], [ %13, %32 ]
store i8 0, i8* %12
%13 = call i8* @read_line(i8* %12, i32* %0)
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 35
br i1 %15, label %16, label %35
16: ; preds = %11
%17 = call i32 @split_string_and_return_specific_index(i8* %8, i8* %13, i32 0, i32 100000)
%18 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
%20 = or i1 %19, %9
br i1 %20, label %32, label %21
21: ; preds = %16, %21
%22 = phi i64 [ %30, %21 ], [ 0, %16 ]
%23 = trunc i64 %22 to i32
%24 = call i32 @split_string_and_return_specific_index(i8* %8, i8* %13, i32 %23, i32 100000)
%25 = getelementptr inbounds i8*, i8** %1, i64 %22
%26 = load i8*, i8** %25
%27 = call i32 @strlen(i8* %8)
%28 = add nsw i32 %27, 1
%29 = call i32 @memcpy(i8* %26, i8* %8, i32 %28)
%30 = add nuw nsw i64 %22, 1
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %21
32: ; preds = %21, %16
%33 = load i8, i8* %13
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %11
35: ; preds = %11, %32
%36 = call i32 @free(i8* %13)
ret void
}