#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_read(char *);
int nb_cols_geno(char *file) {
  FILE *fp = fopen_read(file);
  int cols = 0;
  int c;
  c = fgetc(fp);
  while ((c != EOF) && (c != 10) && (c != 13)) {
    cols++;
    c = fgetc(fp);
  }
  fclose(fp);
  return cols;
}


x86 assembly (clang, -O0):
<nb_cols_geno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fopen_read@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
mov    0x2e80(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x19(%rbp)
je     118c <nb_cols_geno+0x5c>
xor    %eax,%eax
cmpl   $0xa,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     118c <nb_cols_geno+0x5c>
cmpl   $0xd,-0x18(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119c <nb_cols_geno+0x6c>
jmp    11b6 <nb_cols_geno+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
jmp    115c <nb_cols_geno+0x2c>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nb_cols_geno>:
push   %rbp
push   %r14
push   %rbx
call   1050 <fopen_read@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e9d(%rip),%r14
xor    %ebp,%ebp
cmp    (%r14),%eax
je     117a <nb_cols_geno+0x4a>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xa,%eax
je     117a <nb_cols_geno+0x4a>
cmp    $0xd,%eax
je     117a <nb_cols_geno+0x4a>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    (%r14),%eax
jne    1160 <nb_cols_geno+0x30>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @nb_cols_geno(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen_read(i8* %6)
store i32* %7, i32** %3
store i32 0, i32* %4
%8 = load i32*, i32** %3
%9 = call i32 @fgetc(i32* %8)
store i32 %9, i32* %5
br label %10
10: ; preds = %22, %1
%11 = load i32, i32* %5
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 13
br label %20
20: ; preds = %17, %14, %10
%21 = phi i1 [ false, %14 ], [ false, %10 ], [ %19, %17 ]
br i1 %21, label %22, label %27
22: ; preds = %20
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = load i32*, i32** %3
%26 = call i32 @fgetc(i32* %25)
store i32 %26, i32* %5
br label %10
27: ; preds = %20
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @nb_cols_geno(i8* %0) {
%2 = tail call i32* @fopen_read(i8* %0)
%3 = tail call i32 @fgetc(i32* %2)
%4 = load i32, i32* @EOF
%5 = freeze i32 %4
%6 = icmp eq i32 %3, %5
br i1 %6, label %16, label %7
7: ; preds = %1, %10
%8 = phi i32 [ %12, %10 ], [ %3, %1 ]
%9 = phi i32 [ %11, %10 ], [ 0, %1 ]
switch i32 %8, label %10 [
i32 13, label %16
i32 10, label %16
]
10: ; preds = %7
%11 = add nuw nsw i32 %9, 1
%12 = tail call i32 @fgetc(i32* %2)
%13 = load i32, i32* @EOF
%14 = freeze i32 %13
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %7
16: ; preds = %10, %7, %7, %1
%17 = phi i32 [ 0, %1 ], [ %9, %7 ], [ %9, %7 ], [ %11, %10 ]
%18 = tail call i32 @fclose(i32* %2)
ret i32 %17
}