#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 */
char *Csv_readDoubles(char *, unsigned int const, unsigned int, int, double *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ halt(char *, unsigned int);
double *malloc(int);
double *readPrices(unsigned nObservations) {
  double *pricesLogStdP = malloc(sizeof(double) * nObservations);
  if (!pricesLogStdP)
    halt("unable to allocate prices: %u\n", nObservations);
  const unsigned expectHeader = 1;
  char *pricesHeader = Csv_readDoubles("SALE-AMOUNT-log.csv", expectHeader,
                                       nObservations, 1, pricesLogStdP);
  free(pricesHeader);
  return pricesLogStdP;
}


x86 assembly (clang, -O0):
<readPrices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <readPrices+0x37>
mov    -0x4(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1060 <halt@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%r8
lea    0xe93(%rip),%rdi
mov    $0x1,%ecx
mov    %ecx,%esi
call   1040 <Csv_readDoubles@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPrices>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116b <readPrices+0x2b>
lea    0xe9d(%rip),%rdi
mov    %r14d,%esi
call   1060 <halt@plt>
lea    0xead(%rip),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    %rbx,%r8
call   1040 <Csv_readDoubles@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"unable to allocate prices: %u\0A\00"
@.str.1 = [20 x i8] c"SALE-AMOUNT-log.csv\00"
define double* @readPrices(i32 %0) {
%2 = alloca i32
%3 = alloca double*
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call double* @malloc(i32 %9)
store double* %10, double** %3
%11 = load double*, double** %3
%12 = icmp ne double* %11, null
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i32, i32* %2
%15 = call i32 @halt(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %1
store i32 1, i32* %4
%17 = load i32, i32* %2
%18 = load double*, double** %3
%19 = call i8* @Csv_readDoubles(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %17, i32 1, double* %18)
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = call i32 @free(i8* %20)
%22 = load double*, double** %3
ret double* %22
}

LLVM IR (-O2):
@.str = [31 x i8] c"unable to allocate prices: %u\0A\00"
@.str.1 = [20 x i8] c"SALE-AMOUNT-log.csv\00"
define double* @readPrices(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call double* @malloc(i32 %2)
%4 = icmp eq double* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @halt(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %7
7: ; preds = %5, %1
%8 = tail call i8* @Csv_readDoubles(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %0, i32 1, double* %3)
%9 = tail call i32 @free(i8* %8)
ret double* %3
}