#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 */
char *char_alloc(int);
char **char_calloc2(int, int);
int /*<<< orphan*/ check_scan(int, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
float *float_calloc(int);
int /*<<< orphan*/ *openfile_rt(char *, int *);
int sscanf(char *, char *, char *, char *, float *, float *);
int read_stats(char *file, char ***stats, char ***nets, float **stlats,
               float **stlons) {
  FILE *fp;
  int ns, jstat, nstat;
  char *line;
  line = char_alloc(64);
  fp = openfile_rt(file, &nstat);
  *stats = char_calloc2(nstat, 5);
  *nets = char_calloc2(nstat, 3);
  *stlats = float_calloc(nstat);
  *stlons = float_calloc(nstat);
  for (jstat = 0; jstat < nstat; jstat++) {
    fgets(line, 64, fp);
    ns = sscanf(line, "%s%s%f%f", (*stats)[jstat], (*nets)[jstat],
                &(*stlats)[jstat], &(*stlons)[jstat]);
    check_scan(4, ns, file, fp);
  }
  fclose(fp);
  return (nstat);
}


x86 assembly (clang, -O0):
<read_stats>:
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    $0x40,%edi
call   1050 <char_alloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   1070 <openfile_rt@plt>
mov    %rax,-0x30(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x5,%esi
call   1030 <char_calloc2@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x3c(%rbp),%edi
mov    $0x3,%esi
call   1030 <char_calloc2@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x3c(%rbp),%edi
call   1090 <float_calloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x3c(%rbp),%edi
call   1090 <float_calloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12aa <read_stats+0x12a>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x40,%esi
call   1060 <fgets@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r8
mov    -0x28(%rbp),%rax
mov    (%rax),%r9
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r9
lea    0xd81(%rip),%rsi
call   1080 <sscanf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x4,%edi
call   10a0 <check_scan@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1214 <read_stats+0x94>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_stats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x40,%edi
call   1050 <char_alloc@plt>
mov    %rax,%rbp
lea    0x4(%rsp),%rsi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   1070 <openfile_rt@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
mov    $0x5,%esi
call   1030 <char_calloc2@plt>
mov    %r15,0x18(%rsp)
mov    %rax,(%r15)
mov    0x4(%rsp),%edi
mov    $0x3,%esi
call   1030 <char_calloc2@plt>
mov    %r13,0x20(%rsp)
mov    %rax,0x0(%r13)
mov    0x4(%rsp),%edi
call   1090 <float_calloc@plt>
mov    %r12,%rbx
mov    %rax,(%r12)
mov    0x4(%rsp),%edi
call   1090 <float_calloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
cmpl   $0x0,0x4(%rsp)
jle    128a <read_stats+0x10a>
mov    %rcx,%r13
xor    %r15d,%r15d
xor    %r12d,%r12d
nop
mov    %rbp,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    0x18(%rsp),%rax
mov    (%rax),%rax
mov    (%rax,%r15,2),%rdx
mov    0x20(%rsp),%rax
mov    (%rax),%rax
mov    (%rax,%r15,2),%rcx
mov    (%rbx),%r8
add    %r15,%r8
mov    0x0(%r13),%r9
add    %r15,%r9
mov    %rbp,%rdi
lea    0xda1(%rip),%rsi
call   1080 <sscanf@plt>
mov    $0x4,%edi
mov    %eax,%esi
mov    0x10(%rsp),%rdx
mov    %r14,%rcx
call   10a0 <check_scan@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%r12
jl     1220 <read_stats+0xa0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s%s%f%f\00"
define i32 @read_stats(i8* %0, i8*** %1, i8*** %2, float** %3, float** %4) {
%6 = alloca i8*
%7 = alloca i8***
%8 = alloca i8***
%9 = alloca float**
%10 = alloca float**
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store i8* %0, i8** %6
store i8*** %1, i8**** %7
store i8*** %2, i8**** %8
store float** %3, float*** %9
store float** %4, float*** %10
%16 = call i8* @char_alloc(i32 64)
store i8* %16, i8** %15
%17 = load i8*, i8** %6
%18 = call i32* @openfile_rt(i8* %17, i32* %14)
store i32* %18, i32** %11
%19 = load i32, i32* %14
%20 = call i8** @char_calloc2(i32 %19, i32 5)
%21 = load i8***, i8**** %7
store i8** %20, i8*** %21
%22 = load i32, i32* %14
%23 = call i8** @char_calloc2(i32 %22, i32 3)
%24 = load i8***, i8**** %8
store i8** %23, i8*** %24
%25 = load i32, i32* %14
%26 = call float* @float_calloc(i32 %25)
%27 = load float**, float*** %9
store float* %26, float** %27
%28 = load i32, i32* %14
%29 = call float* @float_calloc(i32 %28)
%30 = load float**, float*** %10
store float* %29, float** %30
store i32 0, i32* %13
br label %31
31: ; preds = %67, %5
%32 = load i32, i32* %13
%33 = load i32, i32* %14
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %70
35: ; preds = %31
%36 = load i8*, i8** %15
%37 = load i32*, i32** %11
%38 = call i32 @fgets(i8* %36, i32 64, i32* %37)
%39 = load i8*, i8** %15
%40 = load i8***, i8**** %7
%41 = load i8**, i8*** %40
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = load i8***, i8**** %8
%47 = load i8**, i8*** %46
%48 = load i32, i32* %13
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = load float**, float*** %9
%53 = load float*, float** %52
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
%57 = load float**, float*** %10
%58 = load float*, float** %57
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds float, float* %58, i64 %60
%62 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %45, i8* %51, float* %56, float* %61)
store i32 %62, i32* %12
%63 = load i32, i32* %12
%64 = load i8*, i8** %6
%65 = load i32*, i32** %11
%66 = call i32 @check_scan(i32 4, i32 %63, i8* %64, i32* %65)
br label %67
67: ; preds = %35
%68 = load i32, i32* %13
%69 = add nsw i32 %68, 1
store i32 %69, i32* %13
br label %31
70: ; preds = %31
%71 = load i32*, i32** %11
%72 = call i32 @fclose(i32* %71)
%73 = load i32, i32* %14
ret i32 %73
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s%s%f%f\00"
define i32 @read_stats(i8* %0, i8*** nocapture %1, i8*** nocapture %2, float** nocapture %3, float** nocapture %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = tail call i8* @char_alloc(i32 64)
%9 = call i32* @openfile_rt(i8* %0, i32* %6)
%10 = load i32, i32* %6
%11 = call i8** @char_calloc2(i32 %10, i32 5)
store i8** %11, i8*** %1
%12 = load i32, i32* %6
%13 = call i8** @char_calloc2(i32 %12, i32 3)
store i8** %13, i8*** %2
%14 = load i32, i32* %6
%15 = call float* @float_calloc(i32 %14)
store float* %15, float** %3
%16 = load i32, i32* %6
%17 = call float* @float_calloc(i32 %16)
store float* %17, float** %4
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %5, %20
%21 = phi i64 [ %35, %20 ], [ 0, %5 ]
%22 = call i32 @fgets(i8* %8, i32 64, i32* %9)
%23 = load i8**, i8*** %1
%24 = getelementptr inbounds i8*, i8** %23, i64 %21
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %2
%27 = getelementptr inbounds i8*, i8** %26, i64 %21
%28 = load i8*, i8** %27
%29 = load float*, float** %3
%30 = getelementptr inbounds float, float* %29, i64 %21
%31 = load float*, float** %4
%32 = getelementptr inbounds float, float* %31, i64 %21
%33 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %28, float* %30, float* %32)
%34 = call i32 @check_scan(i32 4, i32 %33, i8* %0, i32* %9)
%35 = add nuw nsw i64 %21, 1
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %20, label %39
39: ; preds = %20, %5
%40 = call i32 @fclose(i32* %9)
%41 = load i32, i32* %6
ret i32 %41
}