#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopfile(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, float *, float *, float *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
void read_bbpfile(char *file, float *per, float *sa1, float *sa2, int np) {
  FILE *fpr;
  int i, nr;
  char str[1024];
  fpr = fopfile(file, "r");
  fgets(str, 1024, fpr);
  while (strncmp(str, "#", 1) == 0)
    fgets(str, 1024, fpr);
  for (i = 0; i < np; i++) {
    nr = sscanf(str, "%f %f %f", &per[i], &sa1[i], &sa2[i]);
    if (nr < 3) {
      fprintf(stderr, "Error in file= %s\n", file);
      fprintf(stderr, "found %d columns, expecting at least 3, exiting...\n",
              nr);
      exit(-1);
    }
    if (i < np - 1)
      fgets(str, 1024, fpr);
  }
  fclose(fpr);
}


x86 assembly (clang, -O0):
<read_bbpfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopfile@plt>
mov    %rax,-0x30(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
lea    -0x440(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11f4 <read_bbpfile+0x84>
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
jmp    11b8 <read_bbpfile+0x48>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12cc <read_bbpfile+0x15c>
lea    -0x440(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
mov    -0x20(%rbp),%r8
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r8
lea    0xdc2(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    1293 <read_bbpfile+0x123>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%edx
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x34(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12b9 <read_bbpfile+0x149>
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
jmp    12be <read_bbpfile+0x14e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11fb <read_bbpfile+0x8b>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_bbpfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
lea    0xe6a(%rip),%rsi
mov    %rdi,0x8(%rsp)
call   1090 <fopfile@plt>
mov    %rax,%r13
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
lea    0xe43(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1205 <read_bbpfile+0x95>
lea    0x20(%rsp),%rbp
lea    0xe25(%rip),%r14
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e0 <read_bbpfile+0x70>
mov    %r13,(%rsp)
mov    0x10(%rsp),%rax
test   %eax,%eax
jle    1280 <read_bbpfile+0x110>
lea    -0x1(%rax),%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,%r14d
xor    %r13d,%r13d
jmp    1245 <read_bbpfile+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13
add    $0x4,%r15
add    $0x4,%r12
add    $0x4,%rbx
cmp    %r13,%r14
je     1280 <read_bbpfile+0x110>
lea    0x20(%rsp),%rdi
lea    0xdb3(%rip),%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jle    129b <read_bbpfile+0x12b>
cmp    0x18(%rsp),%r13
jae    1230 <read_bbpfile+0xc0>
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
mov    (%rsp),%rdx
call   1050 <fgets@plt>
jmp    1230 <read_bbpfile+0xc0>
mov    (%rsp),%rdi
call   1040 <fclose@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    0x2d3c(%rip),%rbx
mov    (%rbx),%edi
lea    0xd60(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd5e(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [9 x i8] c"%f %f %f\00"
@stderr = global i32 0
@.str.3 = [19 x i8] c"Error in file= %s\0A\00"
@.str.4 = [52 x i8] c"found %d columns, expecting at least 3, exiting...\0A\00"
define void @read_bbpfile(i8* %0, float* %1, float* %2, float* %3, i32 %4) {
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = tail call i32* @fopfile(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @fgets(i8* %7, i32 1024, i32* %8)
%10 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %18, %5
%13 = icmp sgt i32 %4, 0
br i1 %13, label %14, label %42
14: ; preds = %12
%15 = add nsw i32 %4, -1
%16 = zext i32 %15 to i64
%17 = zext i32 %4 to i64
br label %22
18: ; preds = %5, %18
%19 = call i32 @fgets(i8* %7, i32 1024, i32* %8)
%20 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %18, label %12
22: ; preds = %14, %39
%23 = phi i64 [ 0, %14 ], [ %40, %39 ]
%24 = getelementptr inbounds float, float* %1, i64 %23
%25 = getelementptr inbounds float, float* %2, i64 %23
%26 = getelementptr inbounds float, float* %3, i64 %23
%27 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %24, float* %25, float* %26)
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %35
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %22
%36 = icmp ult i64 %23, %16
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = call i32 @fgets(i8* %7, i32 1024, i32* %8)
br label %39
39: ; preds = %35, %37
%40 = add nuw nsw i64 %23, 1
%41 = icmp eq i64 %40, %17
br i1 %41, label %42, label %22
42: ; preds = %39, %12
%43 = call i32 @fclose(i32* %8)
ret void
}