#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 */
double atof(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int fsize(char const *);
void *malloc(int);
int /*<<< orphan*/ stderr;
char *strtok(char *, char *);
double *getDepths(const char *fname, int len) {
  FILE *fp = NULL;
  if ((fp = fopen(fname, "r")) == NULL) {
    fprintf(stderr, "Problem opening file: %s\n", fname);
    exit(0);
  }
  char *buf = malloc(sizeof(char) * fsize(fname));
  double *ret = malloc(len * sizeof(double));
  if (fsize(fname) != fread(buf, sizeof(char), fsize(fname), fp)) {
    fprintf(stderr, "Problem reading file=%s\n", fname);
    exit(0);
  }
  int posi = 0;
  ret[posi++] = atof(strtok(buf, "\n\t "));
  char *tok;
  while ((tok = strtok(NULL, "\n\t ")))
    ret[posi++] = atof(tok);
  return ret;
}


x86 assembly (clang, -O0):
<getDepths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d5 <getDepths+0x55>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe39(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1070 <fsize@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <fsize@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <fsize@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
je     1260 <getDepths+0xe0>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdc8(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,%rdi
call   1040 <atof@plt>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd94(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     12d9 <getDepths+0x159>
mov    -0x38(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1296 <getDepths+0x116>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDepths>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125c <getDepths+0xdc>
mov    %rax,%r15
mov    %rbx,%rdi
call   1070 <fsize@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
shl    $0x3,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <fsize@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <fsize@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    %eax,%ebp
jne    126e <getDepths+0xee>
lea    0xe3e(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <strtok@plt>
mov    %rax,%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14)
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
test   %rax,%rax
je     1250 <getDepths+0xd0>
mov    %r14,%rbp
add    $0x8,%rbp
lea    0xe09(%rip),%rbx
nopl   0x0(%rax)
mov    %rax,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x0(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
add    $0x8,%rbp
test   %rax,%rax
jne    1230 <getDepths+0xb0>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0xd96(%rip),%rsi
jmp    127e <getDepths+0xfe>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Problem opening file: %s\0A\00"
@.str.2 = [25 x i8] c"Problem reading file=%s\0A\00"
@.str.3 = [4 x i8] c"\0A\09 \00"
define double* @getDepths(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32* null, i32** %5
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = load i8*, i8** %3
%20 = call i32 @fsize(i8* %19)
%21 = sext i32 %20 to i64
%22 = mul i64 1, %21
%23 = trunc i64 %22 to i32
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %6
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 8
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc(i32 %28)
%30 = bitcast i8* %29 to double*
store double* %30, double** %7
%31 = load i8*, i8** %3
%32 = call i32 @fsize(i8* %31)
%33 = load i8*, i8** %6
%34 = load i8*, i8** %3
%35 = call i32 @fsize(i8* %34)
%36 = load i32*, i32** %5
%37 = call i32 @fread(i8* %33, i32 1, i32 %35, i32* %36)
%38 = icmp ne i32 %32, %37
br i1 %38, label %39, label %44
39: ; preds = %18
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %3
%42 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %18
store i32 0, i32* %8
%45 = load i8*, i8** %6
%46 = call i8* @strtok(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%47 = call double @atof(i8* %46)
%48 = load double*, double** %7
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds double, double* %48, i64 %51
store double %47, double* %52
br label %53
53: ; preds = %56, %44
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %54, i8** %9
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %64
56: ; preds = %53
%57 = load i8*, i8** %9
%58 = call double @atof(i8* %57)
%59 = load double*, double** %7
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds double, double* %59, i64 %62
store double %58, double* %63
br label %53
64: ; preds = %53
%65 = load double*, double** %7
ret double* %65
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Problem opening file: %s\0A\00"
@.str.2 = [25 x i8] c"Problem reading file=%s\0A\00"
@.str.3 = [4 x i8] c"\0A\09 \00"
define noalias double* @getDepths(i8* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = tail call i32 @fsize(i8* %0)
%11 = tail call i8* @malloc(i32 %10)
%12 = shl i32 %1, 3
%13 = tail call i8* @malloc(i32 %12)
%14 = bitcast i8* %13 to double*
%15 = tail call i32 @fsize(i8* %0)
%16 = tail call i32 @fsize(i8* %0)
%17 = tail call i32 @fread(i8* %11, i32 1, i32 %16, i32* %3)
%18 = icmp eq i32 %15, %17
br i1 %18, label %23, label %19
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %9
%24 = tail call i8* @strtok(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call double @atof(i8* %24)
store double %25, double* %14
%26 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %36, label %28
28: ; preds = %23, %28
%29 = phi i64 [ %32, %28 ], [ 1, %23 ]
%30 = phi i8* [ %34, %28 ], [ %26, %23 ]
%31 = tail call double @atof(i8* %30)
%32 = add nuw i64 %29, 1
%33 = getelementptr inbounds double, double* %14, i64 %29
store double %31, double* %33
%34 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %28
36: ; preds = %28, %23
ret double* %14
}