#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 fscanf(int /*<<< orphan*/ *, char *, float *);
float *xrealloc(float *, int);
float *read_ascii_floats(FILE *f, int *no) {
  int r, n = 0, nt = 0;
  float *t = NULL;
  while (1) {
    if (n >= nt) {
      nt = 2 * (nt + 1);
      t = xrealloc(t, nt * sizeof *t);
    }
    r = fscanf(f, "%f", t + n);
    if (r != 1)
      break;
    n += 1;
  }
  *no = n;
  return t;
}


x86 assembly (clang, -O0):
<read_ascii_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1175 <read_ascii_floats+0x55>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1030 <xrealloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe71(%rip),%rsi
call   1040 <fscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     11a6 <read_ascii_floats+0x86>
jmp    11b4 <read_ascii_floats+0x94>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <read_ascii_floats+0x26>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ascii_floats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %rdi,%r12
xor    %ebx,%ebx
lea    0xec5(%rip),%r15
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    116c <read_ascii_floats+0x4c>
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rbx,%r13,1),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
add    $0x1,%rbp
add    $0x4,%rbx
cmp    $0x1,%eax
jne    1194 <read_ascii_floats+0x74>
movslq %r14d,%rax
cmp    %rax,%rbp
jl     1150 <read_ascii_floats+0x30>
mov    %r14d,%eax
add    %eax,%eax
add    %r14d,%r14d
add    $0x2,%r14d
lea    0x8(,%rax,4),%esi
mov    %r13,%rdi
call   1030 <xrealloc@plt>
mov    %rax,%r13
jmp    1150 <read_ascii_floats+0x30>
add    $0xffffffff,%ebp
mov    (%rsp),%rax
mov    %ebp,(%rax)
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
define float* @read_ascii_floats(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %7
store float* null, float** %8
br label %9
9: ; preds = %2, %33
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32, i32* %7
%15 = add nsw i32 %14, 1
%16 = mul nsw i32 2, %15
store i32 %16, i32* %7
%17 = load float*, float** %8
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call float* @xrealloc(float* %17, i32 %21)
store float* %22, float** %8
br label %23
23: ; preds = %13, %9
%24 = load i32*, i32** %3
%25 = load float*, float** %8
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
%29 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %23
br label %36
33: ; preds = %23
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %9
36: ; preds = %32
%37 = load i32, i32* %6
%38 = load i32*, i32** %4
store i32 %37, i32* %38
%39 = load float*, float** %8
ret float* %39
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define float* @read_ascii_floats(i32* nocapture %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %14, %2
%4 = phi i64 [ %20, %14 ], [ 0, %2 ]
%5 = phi i32 [ %15, %14 ], [ 0, %2 ]
%6 = phi float* [ %16, %14 ], [ null, %2 ]
%7 = sext i32 %5 to i64
%8 = icmp slt i64 %4, %7
br i1 %8, label %14, label %9
9: ; preds = %3
%10 = shl i32 %5, 1
%11 = add i32 %10, 2
%12 = shl i32 %11, 2
%13 = tail call float* @xrealloc(float* %6, i32 %12)
br label %14
14: ; preds = %9, %3
%15 = phi i32 [ %11, %9 ], [ %5, %3 ]
%16 = phi float* [ %13, %9 ], [ %6, %3 ]
%17 = getelementptr inbounds float, float* %16, i64 %4
%18 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %17)
%19 = icmp eq i32 %18, 1
%20 = add nuw i64 %4, 1
br i1 %19, label %3, label %21
21: ; preds = %14
%22 = trunc i64 %4 to i32
store i32 %22, i32* %1
ret float* %16
}