#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int read_toas(FILE *toafile, double **toas) {
  char line[200];
  int ii, numtoa;
  numtoa = 0;
  while (!feof(toafile)) {
    fgets(line, 200, toafile);
    if (line[0] == '#')
      continue;
    else
      numtoa++;
  }
  numtoa--;
  *toas = (double *)malloc(sizeof(double) * numtoa);
  rewind(toafile);
  ii = 0;
  while (ii < numtoa) {
    fgets(line, 200, toafile);
    if (line[0] == '#')
      continue;
    else {
      sscanf(line, "%lf\n", &(*toas)[ii]);
      ii++;
    }
  }
  return numtoa;
}


x86 assembly (clang, -O0):
<read_toas>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118b <read_toas+0x3b>
jmp    11c9 <read_toas+0x79>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xc8,%esi
call   1040 <fgets@plt>
movsbl -0xe0(%rbp),%eax
cmp    $0x23,%eax
jne    11b5 <read_toas+0x65>
jmp    116d <read_toas+0x1d>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    116d <read_toas+0x1d>
mov    -0xe8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xe8(%rbp)
movslq -0xe8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
jge    127f <read_toas+0x12f>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xc8,%esi
call   1040 <fgets@plt>
movsbl -0xe0(%rbp),%eax
cmp    $0x23,%eax
jne    1243 <read_toas+0xf3>
jmp    1207 <read_toas+0xb7>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
movslq -0xe4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd9a(%rip),%rsi
call   1070 <sscanf@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1207 <read_toas+0xb7>
mov    -0xe8(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_toas>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11a8 <read_toas+0x58>
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0xc8,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
xor    %eax,%eax
cmpb   $0x23,0x10(%rsp)
setne  %al
add    %eax,%ebp
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     1180 <read_toas+0x30>
lea    -0x1(%rbp),%eax
mov    %eax,0xc(%rsp)
lea    -0x8(,%rbp,8),%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <rewind@plt>
cmp    $0x2,%ebp
jl     1216 <read_toas+0xc6>
mov    0xc(%rsp),%r13d
xor    %r15d,%r15d
lea    0x10(%rsp),%rbp
lea    0xe21(%rip),%r12
nop
mov    %rbp,%rdi
mov    $0xc8,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
cmpb   $0x23,0x10(%rsp)
je     11e0 <read_toas+0x90>
lea    0x0(,%r15,8),%rdx
add    (%r14),%rdx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <sscanf@plt>
add    $0x1,%r15
cmp    %r13,%r15
jne    11e0 <read_toas+0x90>
mov    0xc(%rsp),%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
define i32 @read_toas(i32* %0, double** %1) {
%3 = alloca i32*
%4 = alloca double**
%5 = alloca [200 x i8]
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store double** %1, double*** %4
store i32 0, i32* %7
br label %8
8: ; preds = %25, %21, %2
%9 = load i32*, i32** %3
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i32 @fgets(i8* %14, i32 200, i32* %15)
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 35
br i1 %20, label %21, label %22
21: ; preds = %13
br label %8
22: ; preds = %13
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %25
25: ; preds = %22
br label %8
26: ; preds = %8
%27 = load i32, i32* %7
%28 = add nsw i32 %27, -1
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = mul i64 8, %30
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to double*
%35 = load double**, double*** %4
store double* %34, double** %35
%36 = load i32*, i32** %3
%37 = call i32 @rewind(i32* %36)
store i32 0, i32* %6
br label %38
38: ; preds = %61, %50, %26
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %62
42: ; preds = %38
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%44 = load i32*, i32** %3
%45 = call i32 @fgets(i8* %43, i32 200, i32* %44)
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 35
br i1 %49, label %50, label %51
50: ; preds = %42
br label %38
51: ; preds = %42
%52 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%53 = load double**, double*** %4
%54 = load double*, double** %53
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %57)
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %61
61: ; preds = %51
br label %38
62: ; preds = %38
%63 = load i32, i32* %7
ret i32 %63
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
define i32 @read_toas(i32* nocapture %0, double** nocapture %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = call i32 @feof(i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2, %7
%8 = phi i32 [ %13, %7 ], [ 0, %2 ]
%9 = call i32 @fgets(i8* %4, i32 200, i32* %0)
%10 = load i8, i8* %4
%11 = icmp ne i8 %10, 35
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %8, %12
%14 = call i32 @feof(i32* %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %7, %2
%17 = phi i32 [ 0, %2 ], [ %13, %7 ]
%18 = add nsw i32 %17, -1
%19 = shl i32 %18, 3
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %1
%22 = call i32 @rewind(i32* %0)
%23 = icmp sgt i32 %17, 1
br i1 %23, label %24, label %38
24: ; preds = %16
%25 = zext i32 %18 to i64
br label %26
26: ; preds = %24, %32
%27 = phi i64 [ 0, %24 ], [ %36, %32 ]
br label %28
28: ; preds = %26, %28
%29 = call i32 @fgets(i8* %4, i32 200, i32* %0)
%30 = load i8, i8* %4
%31 = icmp eq i8 %30, 35
br i1 %31, label %28, label %32
32: ; preds = %28
%33 = load double*, double** %1
%34 = getelementptr inbounds double, double* %33, i64 %27
%35 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %34)
%36 = add nuw nsw i64 %27, 1
%37 = icmp eq i64 %36, %25
br i1 %37, label %38, label %26
38: ; preds = %32, %16
ret i32 %18
}