#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 get_number_of_columns(char *);
char *read_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/
split_string_and_return_specific_index(char *, char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int get_number_of_columns_from_file(FILE *vcf_file_pointer) {
  rewind(vcf_file_pointer);
  char result[100] = {0};
  char *szBuffer;
  szBuffer = (char *)calloc(65536, sizeof(char));
  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) {
      int number_of_columns = get_number_of_columns(szBuffer);
      free(szBuffer);
      return number_of_columns;
    }
  } while (szBuffer[0] != '\0');
  free(szBuffer);
  return 0;
}


x86 assembly (clang, -O0):
<get_number_of_columns_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    $0x10000,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x88(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <read_line@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1205 <get_number_of_columns_from_file+0x85>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     120a <get_number_of_columns_from_file+0x8a>
jmp    127f <get_number_of_columns_from_file+0xff>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rsi
xor    %edx,%edx
mov    $0x186a0,%ecx
call   10a0 <split_string_and_return_specific_index@plt>
lea    -0x80(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1267 <get_number_of_columns_from_file+0xe7>
mov    -0x88(%rbp),%rdi
call   1060 <get_number_of_columns@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1292 <get_number_of_columns_from_file+0x112>
jmp    126c <get_number_of_columns_from_file+0xec>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11be <get_number_of_columns_from_file+0x3e>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_number_of_columns_from_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%r14
call   1040 <rewind@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x10000,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    %rsp,%rbp
xor    %r15d,%r15d
lea    0xe35(%rip),%r12
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <read_line@plt>
mov    %rax,%rbx
cmpb   $0x23,(%rax)
jne    121a <get_number_of_columns_from_file+0xaa>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x186a0,%ecx
call   1090 <split_string_and_return_specific_index@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     120f <get_number_of_columns_from_file+0x9f>
cmpb   $0x0,(%rbx)
jne    11d0 <get_number_of_columns_from_file+0x60>
jmp    121a <get_number_of_columns_from_file+0xaa>
mov    %rbx,%rdi
call   1050 <get_number_of_columns@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"#CHROM\00"
define i32 @get_number_of_columns_from_file(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i32 @rewind(i32* %7)
%9 = bitcast [100 x i8]* %4 to i8*
%10 = call i64 @calloc(i32 65536, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
br label %12
12: ; preds = %44, %1
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 0, i8* %14
%15 = load i8*, i8** %5
%16 = load i32*, i32** %3
%17 = call i8* @read_line(i8* %15, i32* %16)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %12
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 35
br i1 %28, label %29, label %30
29: ; preds = %23, %12
br label %50
30: ; preds = %23
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%32 = load i8*, i8** %5
%33 = call i32 @split_string_and_return_specific_index(i8* %31, i8* %32, i32 0, i32 100000)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %30
%38 = load i8*, i8** %5
%39 = call i32 @get_number_of_columns(i8* %38)
store i32 %39, i32* %6
%40 = load i8*, i8** %5
%41 = call i32 @free(i8* %40)
%42 = load i32, i32* %6
store i32 %42, i32* %2
br label %53
43: ; preds = %30
br label %44
44: ; preds = %43
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 0
br i1 %49, label %12, label %50
50: ; preds = %44, %29
%51 = load i8*, i8** %5
%52 = call i32 @free(i8* %51)
store i32 0, i32* %2
br label %53
53: ; preds = %50, %37
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
@.str = [7 x i8] c"#CHROM\00"
define i32 @get_number_of_columns_from_file(i32* %0) {
%2 = alloca [100 x i8]
%3 = tail call i32 @rewind(i32* %0)
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @calloc(i32 65536, i32 1)
%6 = inttoptr i64 %5 to i8*
br label %7
7: ; preds = %18, %1
%8 = phi i8* [ %6, %1 ], [ %9, %18 ]
store i8 0, i8* %8
%9 = call i8* @read_line(i8* %8, i32* %0)
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 35
br i1 %11, label %12, label %21
12: ; preds = %7
%13 = call i32 @split_string_and_return_specific_index(i8* %4, i8* %9, i32 0, i32 100000)
%14 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @get_number_of_columns(i8* %9)
br label %21
18: ; preds = %12
%19 = load i8, i8* %9
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %18, %7, %16
%22 = phi i32 [ %17, %16 ], [ 0, %7 ], [ 0, %18 ]
%23 = call i32 @free(i8* %9)
ret i32 %22
}