#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
double *read_ascii_doubles(int /*<<< orphan*/ *, int *);
double *read_ascii_doubles_fn(const char *fname, int *no) {
  FILE *f = fopen(fname, "r");
  if (!f) {
    *no = 0;
    return NULL;
  }
  double *r = read_ascii_doubles(f, no);
  fclose(f);
  return r;
}


x86 assembly (clang, -O0):
<read_ascii_doubles_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1176 <read_ascii_doubles_fn+0x46>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1198 <read_ascii_doubles_fn+0x68>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <read_ascii_doubles@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ascii_doubles_fn>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xec2(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1166 <read_ascii_doubles_fn+0x36>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <read_ascii_doubles@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    116f <read_ascii_doubles_fn+0x3f>
movl   $0x0,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define double* @read_ascii_doubles_fn(i8* %0, i32* %1) {
%3 = alloca double*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca double*
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = load i32*, i32** %5
store i32 0, i32* %13
store double* null, double** %3
br label %21
14: ; preds = %2
%15 = load i32*, i32** %6
%16 = load i32*, i32** %5
%17 = call double* @read_ascii_doubles(i32* %15, i32* %16)
store double* %17, double** %7
%18 = load i32*, i32** %6
%19 = call i32 @fclose(i32* %18)
%20 = load double*, double** %7
store double* %20, double** %3
br label %21
21: ; preds = %14, %12
%22 = load double*, double** %3
ret double* %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define double* @read_ascii_doubles_fn(i8* nocapture %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 %6
5: ; preds = %2
store i32 0, i32* %1
br label %9
6: ; preds = %2
%7 = tail call double* @read_ascii_doubles(i32* %3, i32* %1)
%8 = tail call i32 @fclose(i32* %3)
br label %9
9: ; preds = %6, %5
%10 = phi double* [ %7, %6 ], [ null, %5 ]
ret double* %10
}