#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 */
char EOF;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen_read(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strtok(char *, char *);
int nb_cols_vcf(char *file) {
  char tok;
  FILE *File = fopen_read(file);
  int max = 1, cols = 0;
  int N = 0;
  char *szbuff;
  char *token;
  tok = fgetc(File);
  while (!feof(File) && tok == '#') {
    cols = 1;
    while (tok != '\n' && tok != EOF) {
      tok = fgetc(File);
      cols++;
    }
    if (cols > max)
      max = cols;
    if (!feof(File))
      tok = fgetc(File);
  }
  fclose(File);
  File = fopen_read(file);
  szbuff = (char *)calloc(2 * max, sizeof(char));
  token = fgets(szbuff, 2 * max, File);
  while (szbuff[1] == '#')
    token = fgets(szbuff, 2 * max, File);
  token = strtok(szbuff, " \t\n");
  if (!strcmp(token, "#CHROM")) {
    while (token) {
      N++;
      token = strtok(NULL, " \t\n");
    }
  } else {
    printf("Error: It seems that the line with individual informations is "
           "missing.\n");
    exit(1);
  }
  fclose(File);
  free(szbuff);
  return N - 9;
}


x86 assembly (clang, -O0):
<nb_cols_vcf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <fopen_read@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x9(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x39(%rbp)
jne    1210 <nb_cols_vcf+0x60>
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1220 <nb_cols_vcf+0x70>
jmp    12ae <nb_cols_vcf+0xfe>
movl   $0x1,-0x20(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x3a(%rbp)
je     124f <nb_cols_vcf+0x9f>
movsbl -0x9(%rbp),%eax
mov    0x2da4(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
test   $0x1,%al
jne    125f <nb_cols_vcf+0xaf>
jmp    1279 <nb_cols_vcf+0xc9>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x9(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1227 <nb_cols_vcf+0x77>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    128b <nb_cols_vcf+0xdb>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
jne    12a9 <nb_cols_vcf+0xf9>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    11ea <nb_cols_vcf+0x3a>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <fopen_read@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
shl    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
shl    $0x1,%esi
mov    -0x18(%rbp),%rdx
call   1070 <fgets@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x23,%eax
jne    131c <nb_cols_vcf+0x16c>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
shl    $0x1,%esi
mov    -0x18(%rbp),%rdx
call   1070 <fgets@plt>
mov    %rax,-0x38(%rbp)
jmp    12ef <nb_cols_vcf+0x13f>
mov    -0x30(%rbp),%rdi
lea    0xcd9(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1380 <nb_cols_vcf+0x1d0>
jmp    134e <nb_cols_vcf+0x19e>
cmpq   $0x0,-0x38(%rbp)
je     137b <nb_cols_vcf+0x1cb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc93(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x38(%rbp)
jmp    134e <nb_cols_vcf+0x19e>
jmp    1396 <nb_cols_vcf+0x1e6>
lea    0xc84(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
sub    $0x9,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nb_cols_vcf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   10b0 <fopen_read@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   10a0 <feof@plt>
mov    $0x2,%r15d
cmp    $0x23,%bl
jne    1268 <nb_cols_vcf+0xb8>
test   %eax,%eax
jne    1268 <nb_cols_vcf+0xb8>
mov    $0x1,%r15d
mov    0x2dec(%rip),%r12
nopl   0x0(%rax)
mov    $0x23,%bl
cmpb   $0x23,(%r12)
mov    $0x1,%ebp
je     1237 <nb_cols_vcf+0x87>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
add    $0x1,%ebp
cmp    $0xa,%al
je     1237 <nb_cols_vcf+0x87>
cmp    (%r12),%bl
jne    1220 <nb_cols_vcf+0x70>
cmp    %r15d,%ebp
cmovg  %ebp,%r15d
mov    %r13,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1254 <nb_cols_vcf+0xa4>
mov    %r13,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   10a0 <feof@plt>
cmp    $0x23,%bl
jne    1265 <nb_cols_vcf+0xb5>
test   %eax,%eax
je     1200 <nb_cols_vcf+0x50>
add    %r15d,%r15d
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   10b0 <fopen_read@plt>
mov    %rax,%r14
mov    %r15d,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xchg   %ax,%ax
mov    %r15d,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
cmpb   $0x23,0x1(%rbx)
jne    12a6 <nb_cols_vcf+0xf6>
mov    %rbx,%rdi
jmp    1290 <nb_cols_vcf+0xe0>
lea    0xd53(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strtok@plt>
mov    %rax,%rbp
lea    0xd45(%rip),%rsi
mov    %rax,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    131a <nb_cols_vcf+0x16a>
test   %rbp,%rbp
je     12f4 <nb_cols_vcf+0x144>
mov    $0xfffffff7,%ebp
lea    0xd24(%rip),%r15
nopl   0x0(%rax)
xor    %edi,%edi
mov    %r15,%rsi
call   10c0 <strtok@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    12e0 <nb_cols_vcf+0x130>
jmp    12f9 <nb_cols_vcf+0x149>
mov    $0xfffffff7,%ebp
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcea(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [7 x i8] c"#CHROM\00"
@.str.2 = [72 x i8] c"Error: It seems that the line with individual informations is missing.\0A\00"
define i32 @nb_cols_vcf(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %2
%10 = load i8*, i8** %2
%11 = call i32* @fopen_read(i8* %10)
store i32* %11, i32** %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%12 = load i32*, i32** %4
%13 = call signext i8 @fgetc(i32* %12)
store i8 %13, i8* %3
br label %14
14: ; preds = %55, %1
%15 = load i32*, i32** %4
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 35
br label %22
22: ; preds = %18, %14
%23 = phi i1 [ false, %14 ], [ %21, %18 ]
br i1 %23, label %24, label %56
24: ; preds = %22
store i32 1, i32* %6
br label %25
25: ; preds = %37, %24
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 10
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %31, %33
br label %35
35: ; preds = %29, %25
%36 = phi i1 [ false, %25 ], [ %34, %29 ]
br i1 %36, label %37, label %42
37: ; preds = %35
%38 = load i32*, i32** %4
%39 = call signext i8 @fgetc(i32* %38)
store i8 %39, i8* %3
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %25
42: ; preds = %35
%43 = load i32, i32* %6
%44 = load i32, i32* %5
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load i32, i32* %6
store i32 %47, i32* %5
br label %48
48: ; preds = %46, %42
%49 = load i32*, i32** %4
%50 = call i32 @feof(i32* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %55, label %52
52: ; preds = %48
%53 = load i32*, i32** %4
%54 = call signext i8 @fgetc(i32* %53)
store i8 %54, i8* %3
br label %55
55: ; preds = %52, %48
br label %14
56: ; preds = %22
%57 = load i32*, i32** %4
%58 = call i32 @fclose(i32* %57)
%59 = load i8*, i8** %2
%60 = call i32* @fopen_read(i8* %59)
store i32* %60, i32** %4
%61 = load i32, i32* %5
%62 = mul nsw i32 2, %61
%63 = call i64 @calloc(i32 %62, i32 1)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %8
%65 = load i8*, i8** %8
%66 = load i32, i32* %5
%67 = mul nsw i32 2, %66
%68 = load i32*, i32** %4
%69 = call i8* @fgets(i8* %65, i32 %67, i32* %68)
store i8* %69, i8** %9
br label %70
70: ; preds = %76, %56
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i64 1
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 35
br i1 %75, label %76, label %82
76: ; preds = %70
%77 = load i8*, i8** %8
%78 = load i32, i32* %5
%79 = mul nsw i32 2, %78
%80 = load i32*, i32** %4
%81 = call i8* @fgets(i8* %77, i32 %79, i32* %80)
store i8* %81, i8** %9
br label %70
82: ; preds = %70
%83 = load i8*, i8** %8
%84 = call i8* @strtok(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %84, i8** %9
%85 = load i8*, i8** %9
%86 = call i32 @strcmp(i8* %85, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%87 = icmp ne i32 %86, 0
br i1 %87, label %97, label %88
88: ; preds = %82
br label %89
89: ; preds = %92, %88
%90 = load i8*, i8** %9
%91 = icmp ne i8* %90, null
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = load i32, i32* %7
%94 = add nsw i32 %93, 1
store i32 %94, i32* %7
%95 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %95, i8** %9
br label %89
96: ; preds = %89
br label %100
97: ; preds = %82
%98 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %96
%101 = load i32*, i32** %4
%102 = call i32 @fclose(i32* %101)
%103 = load i8*, i8** %8
%104 = call i32 @free(i8* %103)
%105 = load i32, i32* %7
%106 = sub nsw i32 %105, 9
ret i32 %106
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c" \09\0A\00"
@.str.1 = [7 x i8] c"#CHROM\00"
@str = [71 x i8] c"Error: It seems that the line with individual informations is missing.\00"
define i32 @nb_cols_vcf(i8* %0) {
%2 = tail call i32* @fopen_read(i8* %0)
%3 = tail call signext i8 @fgetc(i32* %2)
%4 = tail call i32 @feof(i32* %2)
%5 = icmp eq i32 %4, 0
%6 = icmp eq i8 %3, 35
%7 = and i1 %6, %5
br i1 %7, label %8, label %37
8: ; preds = %1, %29
%9 = phi i32 [ %24, %29 ], [ 1, %1 ]
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %10, 35
br i1 %11, label %20, label %12
12: ; preds = %8, %12
%13 = phi i32 [ %15, %12 ], [ 1, %8 ]
%14 = tail call signext i8 @fgetc(i32* %2)
%15 = add nuw nsw i32 %13, 1
%16 = icmp ne i8 %14, 10
%17 = load i8, i8* @EOF
%18 = icmp ne i8 %14, %17
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %12, label %20
20: ; preds = %12, %8
%21 = phi i32 [ 1, %8 ], [ %15, %12 ]
%22 = phi i8 [ 35, %8 ], [ %14, %12 ]
%23 = icmp sgt i32 %21, %9
%24 = select i1 %23, i32 %21, i32 %9
%25 = tail call i32 @feof(i32* %2)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = tail call signext i8 @fgetc(i32* %2)
br label %29
29: ; preds = %27, %20
%30 = phi i8 [ %22, %20 ], [ %28, %27 ]
%31 = tail call i32 @feof(i32* %2)
%32 = icmp eq i32 %31, 0
%33 = icmp eq i8 %30, 35
%34 = and i1 %33, %32
br i1 %34, label %8, label %35
35: ; preds = %29
%36 = shl i32 %24, 1
br label %37
37: ; preds = %35, %1
%38 = phi i32 [ 2, %1 ], [ %36, %35 ]
%39 = tail call i32 @fclose(i32* %2)
%40 = tail call i32* @fopen_read(i8* %0)
%41 = tail call i64 @calloc(i32 %38, i32 1)
%42 = inttoptr i64 %41 to i8*
%43 = tail call i8* @fgets(i8* %42, i32 %38, i32* %40)
%44 = getelementptr inbounds i8, i8* %42, i64 1
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 35
br i1 %46, label %47, label %51
47: ; preds = %37, %47
%48 = tail call i8* @fgets(i8* %42, i32 %38, i32* %40)
%49 = load i8, i8* %44
%50 = icmp eq i8 %49, 35
br i1 %50, label %47, label %51
51: ; preds = %47, %37
%52 = tail call i8* @strtok(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%53 = tail call i32 @strcmp(i8* dereferenceable(1) %52, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = icmp eq i8* %52, null
br i1 %56, label %67, label %57
57: ; preds = %55, %57
%58 = phi i32 [ %59, %57 ], [ 0, %55 ]
%59 = add nuw nsw i32 %58, 1
%60 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%61 = icmp eq i8* %60, null
br i1 %61, label %65, label %57
62: ; preds = %51
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%64 = tail call i32 @exit(i32 1)
unreachable
65: ; preds = %57
%66 = add nsw i32 %58, -8
br label %67
67: ; preds = %65, %55
%68 = phi i32 [ -9, %55 ], [ %66, %65 ]
%69 = tail call i32 @fclose(i32* %40)
%70 = tail call i32 @free(i8* %42)
ret i32 %68
}