#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*/ free(char *);
char *get_line(int /*<<< orphan*/ *);
scalar_t__ space(int);
int sscanf(char *, char *, double *, double *);
scalar_t__ xrealloc(double *, int);
double *read_concentrations(FILE *fp) {
  char *line;
  double *startc;
  int i = 0, n = 2;
  startc = (double *)space((2 * n + 1) * sizeof(double));
  while ((line = get_line(fp)) != NULL) {
    int c;
    if (i + 4 >= 2 * n) {
      n *= 2;
      startc = (double *)xrealloc(startc, (2 * n + 1) * sizeof(double));
    }
    c = sscanf(line, "%lf %lf", &startc[i], &startc[i + 1]);
    free(line);
    if (c < 2)
      break;
    i += 2;
  }
  startc[i] = startc[i + 1] = 0;
  return startc;
}


x86 assembly (clang, -O0):
<read_concentrations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <space@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_line@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1231 <read_concentrations+0xe1>
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    -0x20(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jl     11d6 <read_concentrations+0x86>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1060 <xrealloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
lea    0xdfd(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x2,-0x24(%rbp)
jge    1223 <read_concentrations+0xd3>
jmp    1231 <read_concentrations+0xe1>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1184 <read_concentrations+0x34>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_concentrations>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
mov    $0x28,%edi
call   1040 <space@plt>
mov    %rax,%r12
mov    $0x2,%r13d
mov    $0x8,%r15d
xor    %eax,%eax
jmp    11b2 <read_concentrations+0x62>
nopl   0x0(%rax)
lea    (%r12,%r15,1),%rcx
lea    (%r12,%r15,1),%rdx
add    $0xfffffffffffffff8,%rdx
mov    %rbx,%rdi
lea    0xe6a(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0x2(%r14),%rax
add    $0x10,%r15
cmp    $0x1,%ebp
jle    11ee <read_concentrations+0x9e>
mov    %rax,%r14
mov    (%rsp),%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     11ee <read_concentrations+0x9e>
mov    %rax,%rbx
lea    0x0(%r13,%r13,1),%ebp
lea    0x4(%r14),%eax
cmp    %ebp,%eax
jl     1180 <read_concentrations+0x30>
shl    $0x5,%r13d
or     $0x8,%r13d
mov    %r12,%rdi
mov    %r13d,%esi
call   1060 <xrealloc@plt>
mov    %rax,%r12
mov    %ebp,%r13d
jmp    1180 <read_concentrations+0x30>
and    $0xfffffffe,%r14d
xorps  %xmm0,%xmm0
movups %xmm0,(%r12,%r14,8)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%lf %lf\00"
define double* @read_concentrations(i32* %0) {
%2 = tail call i64 @space(i32 40)
%3 = inttoptr i64 %2 to double*
br label %4
4: ; preds = %20, %1
%5 = phi i64 [ %29, %20 ], [ 0, %1 ]
%6 = phi i32 [ %21, %20 ], [ 2, %1 ]
%7 = phi double* [ %22, %20 ], [ %3, %1 ]
%8 = tail call i8* @get_line(i32* %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %30, label %10
10: ; preds = %4
%11 = shl nsw i32 %6, 1
%12 = trunc i64 %5 to i32
%13 = add i32 %12, 4
%14 = icmp slt i32 %13, %11
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = shl i32 %6, 5
%17 = or i32 %16, 8
%18 = tail call i64 @xrealloc(double* %7, i32 %17)
%19 = inttoptr i64 %18 to double*
br label %20
20: ; preds = %15, %10
%21 = phi i32 [ %11, %15 ], [ %6, %10 ]
%22 = phi double* [ %19, %15 ], [ %7, %10 ]
%23 = getelementptr inbounds double, double* %22, i64 %5
%24 = or i64 %5, 1
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = tail call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %23, double* %25)
%27 = tail call i32 @free(i8* %8)
%28 = icmp slt i32 %26, 2
%29 = add nuw i64 %5, 2
br i1 %28, label %30, label %4
30: ; preds = %20, %4
%31 = phi double* [ %22, %20 ], [ %7, %4 ]
%32 = and i64 %5, 4294967294
%33 = or i64 %32, 1
%34 = getelementptr inbounds double, double* %31, i64 %33
store double 0.000000e+00, double* %34
%35 = and i64 %5, 4294967294
%36 = getelementptr inbounds double, double* %31, i64 %35
store double 0.000000e+00, double* %36
ret double* %31
}