#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*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int sscanf(char *, char *, double *, int *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int countNDoubles(FILE *fp) {
  int lineno, ch, np, i;
  char buf[2048], *s;
  double dummy;
  lineno = 0;
  while (!feof(fp)) {
    if ((ch = fgetc(fp)) == '#') {
      {
        char buf[2048];
        while (!feof(fp))
          if (!fgets(buf, 2048 - 1, fp) || buf[strlen(buf) - 1] == '\n')
            break;
      };
      ++lineno;
      continue;
    }
    if (feof(fp))
      return 0;
    ungetc(ch, fp);
    ++lineno;
    if (!fgets(buf, 2048 - 1, fp)) {
      fprintf(stderr, "countNDoubles(): error reading input file, line %d\n",
              lineno);
      exit(1);
    }
    for (np = i = 0, s = buf; 1; ++np, s += i) {
      ch = sscanf(s, "%lf%n", &dummy, &i);
      if (ch == 0 || ch == EOF)
        break;
    }
    rewind(fp);
    return np;
  }
  return 0;
}


x86 assembly (clang, -O0):
<countNDoubles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c5 <countNDoubles+0x35>
jmp    1375 <countNDoubles+0x1e5>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x23,%eax
jne    1256 <countNDoubles+0xc6>
jmp    11df <countNDoubles+0x4f>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fe <countNDoubles+0x6e>
jmp    1248 <countNDoubles+0xb8>
lea    -0x1030(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x7ff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
je     123e <countNDoubles+0xae>
lea    -0x1030(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x1030(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1243 <countNDoubles+0xb3>
jmp    1248 <countNDoubles+0xb8>
jmp    11df <countNDoubles+0x4f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <countNDoubles+0x16>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1275 <countNDoubles+0xe5>
movl   $0x0,-0x4(%rbp)
jmp    137c <countNDoubles+0x1ec>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <ungetc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x7ff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    12ca <countNDoubles+0x13a>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd45(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    12f5 <countNDoubles+0x165>
jmp    1361 <countNDoubles+0x1d1>
mov    -0x828(%rbp),%rdi
lea    0xd31(%rip),%rsi
lea    -0x830(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   10a0 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1332 <countNDoubles+0x1a2>
mov    -0x18(%rbp),%eax
mov    0x2cbe(%rip),%rcx
cmp    (%rcx),%eax
jne    1337 <countNDoubles+0x1a7>
jmp    1361 <countNDoubles+0x1d1>
jmp    133c <countNDoubles+0x1ac>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x828(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x828(%rbp)
jmp    12e6 <countNDoubles+0x156>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    137c <countNDoubles+0x1ec>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countNDoubles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rdi,%rbx
call   1080 <feof@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11c6 <countNDoubles+0x36>
mov    %r14d,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
lea    0x10(%rsp),%rbp
jmp    11f1 <countNDoubles+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r15d
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11b1 <countNDoubles+0x21>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0x23,%eax
jne    1234 <countNDoubles+0xa4>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11e0 <countNDoubles+0x50>
mov    %rbp,%rdi
mov    $0x7ff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     11e0 <countNDoubles+0x50>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbp,1)
jne    1200 <countNDoubles+0x70>
jmp    11e0 <countNDoubles+0x50>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11b1 <countNDoubles+0x21>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1090 <ungetc@plt>
lea    0x10(%rsp),%rdi
mov    $0x7ff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     12fc <countNDoubles+0x16c>
movl   $0x0,0x4(%rsp)
lea    0xdb8(%rip),%rsi
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rbp,%rdi
call   10a0 <sscanf@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     12ef <countNDoubles+0x15f>
mov    0x2d47(%rip),%rcx
cmp    (%rcx),%eax
je     12ef <countNDoubles+0x15f>
xor    %r14d,%r14d
lea    0xd85(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%r13
nopl   0x0(%rax)
mov    %rbp,%rax
add    $0x1,%r14d
movslq 0x4(%rsp),%rbp
add    %rax,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   10a0 <sscanf@plt>
test   %eax,%eax
je     12ef <countNDoubles+0x15f>
mov    0x2cfd(%rip),%rcx
cmp    (%rcx),%eax
jne    12c0 <countNDoubles+0x130>
mov    %rbx,%rdi
call   1040 <rewind@plt>
jmp    11b1 <countNDoubles+0x21>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
mov    %r15d,%edx
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"countNDoubles(): error reading input file, line %d\0A\00"
@.str.1 = [6 x i8] c"%lf%n\00"
@EOF = global i32 0
define i32 @countNDoubles(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2048 x i8]
%9 = alloca i8*
%10 = alloca double
%11 = alloca [2048 x i8]
store i32* %0, i32** %3
store i32 0, i32* %4
br label %12
12: ; preds = %43, %1
%13 = load i32*, i32** %3
%14 = call i64 @feof(i32* %13)
%15 = icmp ne i64 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %91
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = call i32 @fgetc(i32* %18)
store i32 %19, i32* %5
%20 = icmp eq i32 %19, 35
br i1 %20, label %21, label %46
21: ; preds = %17
br label %22
22: ; preds = %42, %21
%23 = load i32*, i32** %3
%24 = call i64 @feof(i32* %23)
%25 = icmp ne i64 %24, 0
%26 = xor i1 %25, true
br i1 %26, label %27, label %43
27: ; preds = %22
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%29 = load i32*, i32** %3
%30 = call i32 @fgets(i8* %28, i32 2047, i32* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %27
%33 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %42
41: ; preds = %32, %27
br label %43
42: ; preds = %32
br label %22
43: ; preds = %41, %22
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %12
46: ; preds = %17
%47 = load i32*, i32** %3
%48 = call i64 @feof(i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 0, i32* %2
br label %92
51: ; preds = %46
%52 = load i32, i32* %5
%53 = load i32*, i32** %3
%54 = call i32 @ungetc(i32 %52, i32* %53)
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%58 = load i32*, i32** %3
%59 = call i32 @fgets(i8* %57, i32 2047, i32* %58)
%60 = icmp ne i32 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %51
%62 = load i32, i32* @stderr
%63 = load i32, i32* %4
%64 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %51
store i32 0, i32* %7
store i32 0, i32* %6
%67 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
store i8* %67, i8** %9
br label %68
68: ; preds = %80, %66
br i1 true, label %69, label %87
69: ; preds = %68
%70 = load i8*, i8** %9
%71 = call i32 @sscanf(i8* %70, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double* %10, i32* %7)
store i32 %71, i32* %5
%72 = load i32, i32* %5
%73 = icmp eq i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %69
%75 = load i32, i32* %5
%76 = load i32, i32* @EOF
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %79
78: ; preds = %74, %69
br label %87
79: ; preds = %74
br label %80
80: ; preds = %79
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
%83 = load i32, i32* %7
%84 = load i8*, i8** %9
%85 = sext i32 %83 to i64
%86 = getelementptr inbounds i8, i8* %84, i64 %85
store i8* %86, i8** %9
br label %68
87: ; preds = %78, %68
%88 = load i32*, i32** %3
%89 = call i32 @rewind(i32* %88)
%90 = load i32, i32* %6
store i32 %90, i32* %2
br label %92
91: ; preds = %12
store i32 0, i32* %2
br label %92
92: ; preds = %91, %87, %50
%93 = load i32, i32* %2
ret i32 %93
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"countNDoubles(): error reading input file, line %d\0A\00"
@.str.1 = [6 x i8] c"%lf%n\00"
@EOF = global i32 0
define i32 @countNDoubles(i32* nocapture %0) {
%2 = alloca i32
%3 = alloca [2048 x i8]
%4 = alloca double
%5 = alloca [2048 x i8]
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%8 = bitcast double* %4 to i8*
%9 = call i64 @feof(i32* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %67
11: ; preds = %1
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
br label %13
13: ; preds = %11, %31
%14 = phi i32 [ 1, %11 ], [ %32, %31 ]
%15 = call i32 @fgetc(i32* %0)
%16 = icmp eq i32 %15, 35
br i1 %16, label %17, label %35
17: ; preds = %13
br label %18
18: ; preds = %24, %17
%19 = call i64 @feof(i32* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = call i32 @fgets(i8* %12, i32 2047, i32* %0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = call i32 @strlen(i8* %12)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 10
br i1 %30, label %31, label %18
31: ; preds = %21, %24, %18
%32 = add i32 %14, 1
%33 = call i64 @feof(i32* %0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %13, label %67
35: ; preds = %13
%36 = call i64 @feof(i32* %0)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %67
38: ; preds = %35
%39 = call i32 @ungetc(i32 %15, i32* %0)
%40 = call i32 @fgets(i8* %7, i32 2047, i32* %0)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %14)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %38
store i32 0, i32* %2
%47 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double* %4, i32* %2)
%48 = icmp eq i32 %47, 0
%49 = load i32, i32* @EOF
%50 = icmp eq i32 %47, %49
%51 = select i1 %48, i1 true, i1 %50
br i1 %51, label %64, label %52
52: ; preds = %46, %52
%53 = phi i8* [ %58, %52 ], [ %7, %46 ]
%54 = phi i32 [ %55, %52 ], [ 0, %46 ]
%55 = add nuw nsw i32 %54, 1
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
%59 = call i32 @sscanf(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double* %4, i32* %2)
%60 = icmp eq i32 %59, 0
%61 = load i32, i32* @EOF
%62 = icmp eq i32 %59, %61
%63 = select i1 %60, i1 true, i1 %62
br i1 %63, label %64, label %52
64: ; preds = %52, %46
%65 = phi i32 [ 0, %46 ], [ %55, %52 ]
%66 = call i32 @rewind(i32* %0)
br label %67
67: ; preds = %31, %1, %35, %64
%68 = phi i32 [ %65, %64 ], [ 0, %35 ], [ 0, %1 ], [ 0, %31 ]
ret i32 %68
}