#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int DataCounter(char *NameINPUT, int *nrow, int *ncol, char *format) {
  FILE *INPUTFile;
  long long nbbn = 0;
  long long nbsp = 0;
  long long res;
  int currentchar;
  int prevchar;
  if ((INPUTFile = fopen(NameINPUT, "r")) == NULL) {
    printf("Error, invalid input file\n");
    return 1;
  }
  currentchar = fgetc(INPUTFile);
  while (currentchar != EOF) {
    if (currentchar == 10) {
      nbbn++;
      if (prevchar != 32 && prevchar != '\t') {
        nbsp++;
      }
    }
    if ((currentchar == 32 || prevchar == '\t') &&
        (prevchar != 32 || prevchar != '\t'))
      nbsp++;
    prevchar = currentchar;
    currentchar = fgetc(INPUTFile);
  }
  fclose(INPUTFile);
  if (!strcmp(format, "genotypes")) {
    *nrow = (int)nbbn;
    if (nbbn > 0) {
      *ncol = nbsp / nbbn;
    } else {
      *ncol = res;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<DataCounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11ae <DataCounter+0x5e>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ba <DataCounter+0x16a>
mov    -0x30(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%eax
je     1252 <DataCounter+0x102>
cmpl   $0xa,-0x4c(%rbp)
jne    1207 <DataCounter+0xb7>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x20,-0x50(%rbp)
je     1202 <DataCounter+0xb2>
cmpl   $0x9,-0x50(%rbp)
je     1202 <DataCounter+0xb2>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1207 <DataCounter+0xb7>
cmpl   $0x20,-0x4c(%rbp)
je     121b <DataCounter+0xcb>
cmpl   $0x9,-0x50(%rbp)
jne    123b <DataCounter+0xeb>
cmpl   $0x20,-0x50(%rbp)
jne    122f <DataCounter+0xdf>
cmpl   $0x9,-0x50(%rbp)
je     123b <DataCounter+0xeb>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x4c(%rbp)
jmp    11ba <DataCounter+0x6a>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12b3 <DataCounter+0x163>
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x38(%rbp)
jle    12a2 <DataCounter+0x152>
mov    -0x40(%rbp),%rax
cqto
idivq  -0x38(%rbp)
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12ae <DataCounter+0x15e>
mov    -0x48(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12b3 <DataCounter+0x163>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DataCounter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e5 <DataCounter+0x95>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e5e(%rip),%r12
cmp    (%r12),%eax
mov    %r15,0x8(%rsp)
mov    %rbx,0x10(%rsp)
jne    11f8 <DataCounter+0xa8>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xe54(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1265 <DataCounter+0x115>
mov    0x10(%rsp),%rax
mov    %r15d,(%rax)
test   %r15,%r15
jle    1265 <DataCounter+0x115>
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     1257 <DataCounter+0x107>
mov    %rbx,%rax
cqto
idiv   %r15
jmp    125e <DataCounter+0x10e>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1267 <DataCounter+0x117>
mov    %eax,%r14d
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    123d <DataCounter+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x20,%r14d
sete   %al
cmp    $0x9,%ecx
sete   %cl
or     %al,%cl
movzbl %cl,%eax
add    %rax,%rbx
mov    %rbp,%rdi
call   1050 <fgetc@plt>
mov    %r14d,%ecx
mov    %eax,%r14d
cmp    (%r12),%eax
je     119f <DataCounter+0x4f>
cmp    $0xa,%r14d
jne    1210 <DataCounter+0xc0>
add    $0x1,%r15
cmp    $0x9,%ecx
je     1210 <DataCounter+0xc0>
cmp    $0x20,%ecx
je     1210 <DataCounter+0xc0>
add    $0x1,%rbx
jmp    1210 <DataCounter+0xc0>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Error, invalid input file\0A\00"
@EOF = global i32 0
@.str.2 = [10 x i8] c"genotypes\00"
define i32 @DataCounter(i8* %0, i32* %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i64 0, i64* %11
store i64 0, i64* %12
%16 = load i8*, i8** %6
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %10
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %86
21: ; preds = %4
%22 = load i32*, i32** %10
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %14
br label %24
24: ; preds = %58, %21
%25 = load i32, i32* %14
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %62
28: ; preds = %24
%29 = load i32, i32* %14
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %43
31: ; preds = %28
%32 = load i64, i64* %11
%33 = add nsw i64 %32, 1
store i64 %33, i64* %11
%34 = load i32, i32* %15
%35 = icmp ne i32 %34, 32
br i1 %35, label %36, label %42
36: ; preds = %31
%37 = load i32, i32* %15
%38 = icmp ne i32 %37, 9
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i64, i64* %12
%41 = add nsw i64 %40, 1
store i64 %41, i64* %12
br label %42
42: ; preds = %39, %36, %31
br label %43
43: ; preds = %42, %28
%44 = load i32, i32* %14
%45 = icmp eq i32 %44, 32
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %15
%48 = icmp eq i32 %47, 9
br i1 %48, label %49, label %58
49: ; preds = %46, %43
%50 = load i32, i32* %15
%51 = icmp ne i32 %50, 32
br i1 %51, label %55, label %52
52: ; preds = %49
%53 = load i32, i32* %15
%54 = icmp ne i32 %53, 9
br i1 %54, label %55, label %58
55: ; preds = %52, %49
%56 = load i64, i64* %12
%57 = add nsw i64 %56, 1
store i64 %57, i64* %12
br label %58
58: ; preds = %55, %52, %46
%59 = load i32, i32* %14
store i32 %59, i32* %15
%60 = load i32*, i32** %10
%61 = call i32 @fgetc(i32* %60)
store i32 %61, i32* %14
br label %24
62: ; preds = %24
%63 = load i32*, i32** %10
%64 = call i32 @fclose(i32* %63)
%65 = load i8*, i8** %9
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %85, label %68
68: ; preds = %62
%69 = load i64, i64* %11
%70 = trunc i64 %69 to i32
%71 = load i32*, i32** %7
store i32 %70, i32* %71
%72 = load i64, i64* %11
%73 = icmp sgt i64 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %68
%75 = load i64, i64* %12
%76 = load i64, i64* %11
%77 = sdiv i64 %75, %76
%78 = trunc i64 %77 to i32
%79 = load i32*, i32** %8
store i32 %78, i32* %79
br label %84
80: ; preds = %68
%81 = load i64, i64* %13
%82 = trunc i64 %81 to i32
%83 = load i32*, i32** %8
store i32 %82, i32* %83
br label %84
84: ; preds = %80, %74
br label %85
85: ; preds = %84, %62
store i32 0, i32* %5
br label %86
86: ; preds = %85, %19
%87 = load i32, i32* %5
ret i32 %87
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.2 = [10 x i8] c"genotypes\00"
@str = [26 x i8] c"Error, invalid input file\00"
define i32 @DataCounter(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i8* nocapture %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %46
9: ; preds = %4
%10 = tail call i32 @fgetc(i32* %5)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %34, label %13
13: ; preds = %9, %23
%14 = phi i32 [ %15, %23 ], [ undef, %9 ]
%15 = phi i32 [ %31, %23 ], [ %10, %9 ]
%16 = phi i64 [ %30, %23 ], [ 0, %9 ]
%17 = phi i64 [ %24, %23 ], [ 0, %9 ]
%18 = icmp eq i32 %15, 10
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = add nsw i64 %17, 1
switch i32 %14, label %21 [
i32 32, label %23
i32 9, label %23
]
21: ; preds = %19
%22 = add nsw i64 %16, 1
br label %23
23: ; preds = %19, %19, %21, %13
%24 = phi i64 [ %20, %21 ], [ %20, %19 ], [ %17, %13 ], [ %20, %19 ]
%25 = phi i64 [ %22, %21 ], [ %16, %19 ], [ %16, %13 ], [ %16, %19 ]
%26 = icmp eq i32 %15, 32
%27 = icmp eq i32 %14, 9
%28 = select i1 %26, i1 true, i1 %27
%29 = zext i1 %28 to i64
%30 = add nsw i64 %25, %29
%31 = tail call i32 @fgetc(i32* %5)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %13
34: ; preds = %23, %9
%35 = phi i64 [ 0, %9 ], [ %24, %23 ]
%36 = phi i64 [ 0, %9 ], [ %30, %23 ]
%37 = tail call i32 @fclose(i32* %5)
%38 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = trunc i64 %35 to i32
store i32 %41, i32* %1
%42 = icmp sgt i64 %35, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = sdiv i64 %36, %35
%45 = trunc i64 %44 to i32
store i32 %45, i32* %2
br label %46
46: ; preds = %34, %43, %40, %7
%47 = phi i32 [ 1, %7 ], [ 0, %40 ], [ 0, %43 ], [ 0, %34 ]
ret i32 %47
}