#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 */

/* Variables and functions */
int EOF;
scalar_t__ feof(int /*<<< orphan*/);
char fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int fscanf(int /*<<< orphan*/, char *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
double *xmalloc(int);
double *xrealloc(double *, int);
int llegeixx(double **x) {
  int veclen = 1024;
  int len = 0;
  double tx;
  int c;
  *x = xmalloc(veclen * sizeof(double));
  while (!feof(stdin)) {
    if (len == veclen) {
      veclen *= 2;
      *x = xrealloc(*x, veclen * sizeof(double));
    }
    c = fgetc(stdin);
    if (c == EOF)
      break;
    if (c == '\n')
      continue;
    else if (c == '#') {
      while (fgetc(stdin) != '\n' || feof(stdin))
        ;
      continue;
    } else
      ungetc(c, stdin);
    if (fscanf(stdin, "%lf", &tx) == 1) {
      (*x)[len] = tx;
      len++;
    } else {
      while (fgetc(stdin) != '\n' || feof(stdin))
        ;
      fprintf(stderr, "Error at data entry %d. Ignoring a line\n", len);
    }
  }
  fprintf(stderr, "# %d dades llegides.\n", len);
  return len;
}


x86 assembly (clang, -O0):
<llegeixx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <xmalloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1080 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c7 <llegeixx+0x57>
jmp    135f <llegeixx+0x1ef>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11fc <llegeixx+0x8c>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <xrealloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   1060 <fgetc@plt>
movsbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2dc6(%rip),%rcx
cmp    (%rcx),%eax
jne    1227 <llegeixx+0xb7>
jmp    135f <llegeixx+0x1ef>
cmpl   $0xa,-0x1c(%rbp)
jne    1236 <llegeixx+0xc6>
jmp    11a3 <llegeixx+0x33>
cmpl   $0x23,-0x1c(%rbp)
jne    1296 <llegeixx+0x126>
jmp    1245 <llegeixx+0xd5>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1060 <fgetc@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1d(%rbp)
jne    127c <llegeixx+0x10c>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1080 <feof@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    128c <llegeixx+0x11c>
jmp    1291 <llegeixx+0x121>
jmp    1245 <llegeixx+0xd5>
jmp    11a3 <llegeixx+0x33>
mov    -0x1c(%rbp),%edi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
call   1090 <ungetc@plt>
jmp    12ac <llegeixx+0x13c>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12f1 <llegeixx+0x181>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    135a <llegeixx+0x1ea>
jmp    12f6 <llegeixx+0x186>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   1060 <fgetc@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1e(%rbp)
jne    132d <llegeixx+0x1bd>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
call   1080 <feof@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    133d <llegeixx+0x1cd>
jmp    1342 <llegeixx+0x1d2>
jmp    12f6 <llegeixx+0x186>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xcaf(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11a3 <llegeixx+0x33>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xcbb(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llegeixx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2000,%edi
call   1050 <xmalloc@plt>
mov    %rax,(%r14)
mov    0x2e56(%rip),%r13
mov    0x0(%r13),%edi
call   1080 <feof@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11ca <llegeixx+0x5a>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %ebx,%edx
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
mov    $0x400,%r12d
lea    (%rbx,%rbx,1),%r15d
mov    %ebx,%ebp
shl    $0x4,%ebp
jmp    11ee <llegeixx+0x7e>
nopl   (%rax)
mov    0x0(%r13),%edi
call   1080 <feof@plt>
test   %rax,%rax
jne    11a2 <llegeixx+0x32>
cmp    %r12d,%ebx
jne    1203 <llegeixx+0x93>
mov    (%r14),%rdi
mov    %ebp,%esi
call   1030 <xrealloc@plt>
mov    %rax,(%r14)
mov    %r15d,%r12d
mov    0x0(%r13),%edi
call   1060 <fgetc@plt>
movsbl %al,%edi
mov    0x2dca(%rip),%rcx
cmp    %edi,(%rcx)
je     11a2 <llegeixx+0x32>
cmp    $0xa,%al
je     11e0 <llegeixx+0x70>
cmp    $0x23,%al
jne    124d <llegeixx+0xdd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13),%edi
call   1060 <fgetc@plt>
cmp    $0xa,%al
jne    1230 <llegeixx+0xc0>
mov    0x0(%r13),%edi
call   1080 <feof@plt>
test   %rax,%rax
jne    1230 <llegeixx+0xc0>
jmp    11e0 <llegeixx+0x70>
mov    0x0(%r13),%esi
call   1090 <ungetc@plt>
mov    0x0(%r13),%edi
lea    0xd9f(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1290 <llegeixx+0x120>
movsd  (%rsp),%xmm0
mov    (%r14),%rax
movslq %ebx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%ebx
jmp    12c2 <llegeixx+0x152>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%edi
call   1060 <fgetc@plt>
cmp    $0xa,%al
jne    1290 <llegeixx+0x120>
mov    0x0(%r13),%edi
call   1080 <feof@plt>
test   %rax,%rax
jne    1290 <llegeixx+0x120>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
mov    %ebx,%edx
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
call   1080 <feof@plt>
test   %rax,%rax
je     11d2 <llegeixx+0x62>
jmp    11a2 <llegeixx+0x32>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@.str = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"Error at data entry %d. Ignoring a line\0A\00"
@.str.2 = [22 x i8] c"# %d dades llegides.\0A\00"
define i32 @llegeixx(double** %0) {
%2 = alloca double**
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store double** %0, double*** %2
store i32 1024, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = call double* @xmalloc(i32 %10)
%12 = load double**, double*** %2
store double* %11, double** %12
br label %13
13: ; preds = %97, %61, %44, %1
%14 = load i32, i32* @stdin
%15 = call i64 @feof(i32 %14)
%16 = icmp ne i64 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %98
18: ; preds = %13
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 2
store i32 %24, i32* %3
%25 = load double**, double*** %2
%26 = load double*, double** %25
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call double* @xrealloc(double* %26, i32 %30)
%32 = load double**, double*** %2
store double* %31, double** %32
br label %33
33: ; preds = %22, %18
%34 = load i32, i32* @stdin
%35 = call signext i8 @fgetc(i32 %34)
%36 = sext i8 %35 to i32
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %33
br label %98
41: ; preds = %33
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 10
br i1 %43, label %44, label %45
44: ; preds = %41
br label %13
45: ; preds = %41
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 35
br i1 %47, label %48, label %62
48: ; preds = %45
br label %49
49: ; preds = %60, %48
%50 = load i32, i32* @stdin
%51 = call signext i8 @fgetc(i32 %50)
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 10
br i1 %53, label %58, label %54
54: ; preds = %49
%55 = load i32, i32* @stdin
%56 = call i64 @feof(i32 %55)
%57 = icmp ne i64 %56, 0
br label %58
58: ; preds = %54, %49
%59 = phi i1 [ true, %49 ], [ %57, %54 ]
br i1 %59, label %60, label %61
60: ; preds = %58
br label %49
61: ; preds = %58
br label %13
62: ; preds = %45
%63 = load i32, i32* %6
%64 = load i32, i32* @stdin
%65 = call i32 @ungetc(i32 %63, i32 %64)
br label %66
66: ; preds = %62
br label %67
67: ; preds = %66
%68 = load i32, i32* @stdin
%69 = call i32 @fscanf(i32 %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %5)
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %80
71: ; preds = %67
%72 = load double, double* %5
%73 = load double**, double*** %2
%74 = load double*, double** %73
%75 = load i32, i32* %4
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
store double %72, double* %77
%78 = load i32, i32* %4
%79 = add nsw i32 %78, 1
store i32 %79, i32* %4
br label %97
80: ; preds = %67
br label %81
81: ; preds = %92, %80
%82 = load i32, i32* @stdin
%83 = call signext i8 @fgetc(i32 %82)
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %84, 10
br i1 %85, label %90, label %86
86: ; preds = %81
%87 = load i32, i32* @stdin
%88 = call i64 @feof(i32 %87)
%89 = icmp ne i64 %88, 0
br label %90
90: ; preds = %86, %81
%91 = phi i1 [ true, %81 ], [ %89, %86 ]
br i1 %91, label %92, label %93
92: ; preds = %90
br label %81
93: ; preds = %90
%94 = load i32, i32* @stderr
%95 = load i32, i32* %4
%96 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %93, %71
br label %13
98: ; preds = %40, %13
%99 = load i32, i32* @stderr
%100 = load i32, i32* %4
%101 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %100)
%102 = load i32, i32* %4
ret i32 %102
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@.str = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"Error at data entry %d. Ignoring a line\0A\00"
@.str.2 = [22 x i8] c"# %d dades llegides.\0A\00"
define i32 @llegeixx(double** nocapture %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = tail call double* @xmalloc(i32 8192)
store double* %4, double** %0
%5 = load i32, i32* @stdin
%6 = call i64 @feof(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %69
8: ; preds = %1, %64
%9 = phi i32 [ %20, %64 ], [ 1024, %1 ]
%10 = phi i32 [ %65, %64 ], [ 0, %1 ]
%11 = shl nsw i32 %10, 1
%12 = shl i32 %10, 4
br label %13
13: ; preds = %8, %27
%14 = phi i32 [ %9, %8 ], [ %20, %27 ]
%15 = icmp eq i32 %10, %14
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double*, double** %0
%18 = call double* @xrealloc(double* %17, i32 %12)
store double* %18, double** %0
br label %19
19: ; preds = %16, %13
%20 = phi i32 [ %11, %16 ], [ %14, %13 ]
%21 = load i32, i32* @stdin
%22 = call signext i8 @fgetc(i32 %21)
%23 = sext i8 %22 to i32
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %24, %23
br i1 %25, label %69, label %26
26: ; preds = %19
switch i8 %22, label %40 [
i8 10, label %27
i8 35, label %31
]
27: ; preds = %36, %26
%28 = load i32, i32* @stdin
%29 = call i64 @feof(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %13, label %69
31: ; preds = %26, %35
%32 = load i32, i32* @stdin
%33 = call signext i8 @fgetc(i32 %32)
%34 = icmp eq i8 %33, 10
br i1 %34, label %36, label %35
35: ; preds = %31, %36
br label %31
36: ; preds = %31
%37 = load i32, i32* @stdin
%38 = call i64 @feof(i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %27, label %35
40: ; preds = %26
%41 = load i32, i32* @stdin
%42 = call i32 @ungetc(i32 %23, i32 %41)
%43 = load i32, i32* @stdin
%44 = call i32 @fscanf(i32 %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %52
46: ; preds = %40
%47 = load double, double* %2
%48 = load double*, double** %0
%49 = sext i32 %10 to i64
%50 = getelementptr inbounds double, double* %48, i64 %49
store double %47, double* %50
%51 = add nsw i32 %10, 1
br label %64
52: ; preds = %40, %56
%53 = load i32, i32* @stdin
%54 = call signext i8 @fgetc(i32 %53)
%55 = icmp eq i8 %54, 10
br i1 %55, label %57, label %56
56: ; preds = %52, %57
br label %52
57: ; preds = %52
%58 = load i32, i32* @stdin
%59 = call i64 @feof(i32 %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %56
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %64
64: ; preds = %61, %46
%65 = phi i32 [ %51, %46 ], [ %10, %61 ]
%66 = load i32, i32* @stdin
%67 = call i64 @feof(i32 %66)
%68 = icmp eq i64 %67, 0
br i1 %68, label %8, label %69
69: ; preds = %64, %27, %19, %1
%70 = phi i32 [ 0, %1 ], [ %10, %19 ], [ %10, %27 ], [ %65, %64 ]
%71 = load i32, i32* @stderr
%72 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %70)
ret i32 %70
}