#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 */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *, double *);
int /*<<< orphan*/ printf(char *, char const *);
void dread_ascfile_c_(const char *ascfile, double *t0, double *dt, int *n,
                      double *data) {
  FILE *fd;
  double junk, junk1;
  int i;
  if ((fd = fopen(ascfile, "r")) == NULL) {
    printf(" file %s cannot be opened\n", ascfile);
    exit(1);
  }
  i = 0;
  while (fscanf(fd, "%lf  %lf\n", &junk, data + i) != EOF) {
    if (i == 0)
      junk1 = junk;
    if (i == 1)
      *dt = junk - junk1;
    i++;
  }
  *t0 = junk1;
  *n = i;
  if (fclose(fd) != 0) {
    printf(" file %s cannot be closed\n", ascfile);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<dread_ascfile_c_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11a4 <dread_ascfile_c_+0x54>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rcx
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
lea    0xe58(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1050 <fscanf@plt>
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%rax
je     121c <dread_ascfile_c_+0xcc>
cmpl   $0x0,-0x44(%rbp)
jne    11f2 <dread_ascfile_c_+0xa2>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x1,-0x44(%rbp)
jne    120e <dread_ascfile_c_+0xbe>
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ab <dread_ascfile_c_+0x5b>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     125f <dread_ascfile_c_+0x10f>
mov    -0x8(%rbp),%rsi
lea    0xdd7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dread_ascfile_c_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%r14
lea    0xe8c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1296 <dread_ascfile_c_+0x146>
mov    %rax,%r13
mov    %rbp,0x18(%rsp)
mov    %r15,0x20(%rsp)
lea    0xe87(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
mov    %rbx,%rcx
call   1050 <fscanf@plt>
mov    0x2e3d(%rip),%r15
cmp    (%r15),%rax
jne    11b8 <dread_ascfile_c_+0x68>
xor    %r12d,%r12d
jmp    1269 <dread_ascfile_c_+0x119>
mov    %r12,%rbp
movsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x8(%rbx),%rcx
lea    0xe4c(%rip),%rsi
mov    %rsp,%rdx
mov    %r13,%rdi
call   1050 <fscanf@plt>
mov    $0x1,%r12d
cmp    (%r15),%rax
je     1263 <dread_ascfile_c_+0x113>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x0(%rbp)
lea    0x10(%rbx),%rcx
lea    0xe1b(%rip),%rsi
mov    %rsp,%rdx
mov    %r13,%rdi
call   1050 <fscanf@plt>
mov    $0x2,%r12d
cmp    (%r15),%rax
je     1263 <dread_ascfile_c_+0x113>
mov    %r14,0x10(%rsp)
add    $0x18,%rbx
mov    $0x2,%r12d
lea    0xdef(%rip),%rbp
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fscanf@plt>
add    $0x1,%r12d
add    $0x8,%rbx
cmp    (%r15),%rax
jne    1240 <dread_ascfile_c_+0xf0>
mov    0x10(%rsp),%r14
movsd  0x8(%rsp),%xmm0
mov    0x18(%rsp),%rax
movsd  %xmm0,(%rax)
mov    0x20(%rsp),%rax
mov    %r12d,(%rax)
mov    %r13,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
jne    129f <dread_ascfile_c_+0x14f>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd65(%rip),%rdi
jmp    12a6 <dread_ascfile_c_+0x156>
lea    0xd81(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c" file %s cannot be opened\0A\00"
@.str.2 = [10 x i8] c"%lf %lf\0A\00"
@EOF = global i64 0
@.str.3 = [27 x i8] c" file %s cannot be closed\0A\00"
define void @dread_ascfile_c_(i8* %0, double* %1, double* %2, i32* %3, double* %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca double*
%11 = alloca i32*
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store i8* %0, i8** %6
store double* %1, double** %7
store double* %2, double** %8
store i32* %3, i32** %9
store double* %4, double** %10
%15 = load i8*, i8** %6
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %11
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %5
store i32 0, i32* %14
br label %23
23: ; preds = %45, %22
%24 = load i32*, i32** %11
%25 = load double*, double** %10
%26 = load i32, i32* %14
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %12, double* %28)
%30 = load i64, i64* @EOF
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %48
32: ; preds = %23
%33 = load i32, i32* %14
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load double, double* %12
store double %36, double* %13
br label %37
37: ; preds = %35, %32
%38 = load i32, i32* %14
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load double, double* %12
%42 = load double, double* %13
%43 = fsub double %41, %42
%44 = load double*, double** %8
store double %43, double* %44
br label %45
45: ; preds = %40, %37
%46 = load i32, i32* %14
%47 = add nsw i32 %46, 1
store i32 %47, i32* %14
br label %23
48: ; preds = %23
%49 = load double, double* %13
%50 = load double*, double** %7
store double %49, double* %50
%51 = load i32, i32* %14
%52 = load i32*, i32** %9
store i32 %51, i32* %52
%53 = load i32*, i32** %11
%54 = call i64 @fclose(i32* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %48
%57 = load i8*, i8** %6
%58 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %57)
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %48
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c" file %s cannot be opened\0A\00"
@.str.2 = [10 x i8] c"%lf %lf\0A\00"
@EOF = global i64 0
@.str.3 = [27 x i8] c" file %s cannot be closed\0A\00"
define void @dread_ascfile_c_(i8* %0, double* nocapture writeonly %1, double* nocapture writeonly %2, i32* nocapture writeonly %3, double* %4) {
%6 = alloca double
%7 = bitcast double* %6 to i8*
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %27, label %10
10: ; preds = %5
%11 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %6, double* %4)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %39, label %14
14: ; preds = %10
%15 = load double, double* %6
%16 = getelementptr inbounds double, double* %4, i64 1
%17 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %6, double* %16)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %39, label %20
20: ; preds = %14
%21 = load double, double* %6
%22 = fsub double %21, %15
store double %22, double* %2
%23 = getelementptr inbounds double, double* %4, i64 2
%24 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %6, double* %23)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %39, label %30
27: ; preds = %5
%28 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %20, %30
%31 = phi i64 [ %32, %30 ], [ 2, %20 ]
%32 = add nuw i64 %31, 1
%33 = getelementptr inbounds double, double* %4, i64 %32
%34 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %6, double* %33)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %30
37: ; preds = %30
%38 = trunc i64 %32 to i32
br label %39
39: ; preds = %14, %20, %37, %10
%40 = phi double [ undef, %10 ], [ %15, %37 ], [ %15, %20 ], [ %15, %14 ]
%41 = phi i32 [ 0, %10 ], [ %38, %37 ], [ 2, %20 ], [ 1, %14 ]
store double %40, double* %1
store i32 %41, i32* %3
%42 = call i64 @fclose(i32* %8)
%43 = icmp eq i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %39
ret void
}