#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 */
size_t EOF;
scalar_t__ floor(double);
int /*<<< orphan*/ free(char *);
size_t getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, int *, double *, double *, double *);
scalar_t__ strncmp(char *, char *, int);
int read_event(FILE *stream, double dpt, int *ntot, int *ptCount,
               double ptArray[10000][25], double phiArray[10000][25],
               double rapArray[10000][25], int chArray[10000][25]) {
  char *buffer = NULL;
  size_t linecap = 0;
  size_t linelen;
  int charge;
  double pt, phi, rap;
  int nparts = 0;
  int ipt, pcount;
  double ptmin = 0.0;
  while ((linelen = getline(&buffer, &linecap, stream)) != EOF) {
    if (strncmp(buffer, "#", 1) == 0) {
      *ntot = nparts;
      free(buffer);
      return 0;
    }
    sscanf(buffer, "%d %lf %lf %lf", &charge, &pt, &phi, &rap);
    nparts++;
    ipt = (int)floor((pt - ptmin) / dpt);
    if (ipt < 25) {
      ptCount[ipt]++;
      pcount = ptCount[ipt];
      ptArray[pcount][ipt] = pt;
      phiArray[pcount][ipt] = phi;
      rapArray[pcount][ipt] = rap;
      chArray[pcount][ipt] = charge;
    }
  }
  *ntot = nparts;
  free(buffer);
  if (linelen == EOF)
    return EOF;
}


x86 assembly (clang, -O0):
<read_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x7c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x10(%rbp),%rdx
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <getline@plt>
mov    %rax,-0x58(%rbp)
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%rax
je     12f9 <read_event+0x1a9>
mov    -0x48(%rbp),%rdi
lea    0xe32(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1200 <read_event+0xb0>
mov    -0x7c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    132c <read_event+0x1dc>
mov    -0x48(%rbp),%rdi
lea    0xdf7(%rip),%rsi
lea    -0x5c(%rbp),%rdx
lea    -0x68(%rbp),%rcx
lea    -0x70(%rbp),%r8
lea    -0x78(%rbp),%r9
call   1050 <sscanf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x90(%rbp),%xmm0
ff
divsd  -0x18(%rbp),%xmm0
call   1070 <floor@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x19,-0x80(%rbp)
jge    12f4 <read_event+0x1a4>
mov    -0x28(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x84(%rbp)
movsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x84(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x80(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x70(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x84(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x80(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x78(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x84(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x80(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x5c(%rbp),%edx
mov    0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
movslq -0x80(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    119e <read_event+0x4e>
mov    -0x7c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rax
mov    0x2cd2(%rip),%rcx
cmp    (%rcx),%rax
jne    132c <read_event+0x1dc>
mov    0x2cc2(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_event>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x38(%rsp)
mov    %r8,0x30(%rsp)
mov    %rcx,0x28(%rsp)
mov    %rdx,%rbx
mov    %rsi,0x10(%rsp)
movsd  %xmm0,0x40(%rsp)
mov    %rdi,%rbp
movq   $0x0,(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    %rbp,%rdx
call   1060 <getline@plt>
mov    0x2e42(%rip),%r15
xor    %r12d,%r12d
cmp    (%r15),%rax
jne    11c7 <read_event+0x77>
mov    0x10(%rsp),%rax
mov    %r12d,(%rax)
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    (%r15),%eax
jmp    12d1 <read_event+0x181>
xor    %r12d,%r12d
mov    %rsp,%r14
lea    0x20(%rsp),%r13
jmp    11f7 <read_event+0xa7>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <getline@plt>
add    $0x1,%r12d
cmp    (%r15),%rax
je     11ae <read_event+0x5e>
mov    (%rsp),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12be <read_event+0x16e>
mov    (%rsp),%rdi
lea    0xde2(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x50(%rsp),%r8
lea    0x48(%rsp),%r9
call   1050 <sscanf@plt>
movsd  0x18(%rsp),%xmm0
divsd  0x40(%rsp),%xmm0
call   1070 <floor@plt>
cmp    $0x18,%eax
jg     11e0 <read_event+0x90>
shl    $0x20,%rax
mov    %rax,%rcx
sar    $0x1e,%rcx
movslq (%rbx,%rcx,1),%rdx
add    $0x1,%rdx
mov    %edx,(%rbx,%rcx,1)
movsd  0x18(%rsp),%xmm0
imul   $0xc8,%rdx,%rsi
mov    0x28(%rsp),%rdi
add    %rsi,%rdi
sar    $0x1d,%rax
movsd  %xmm0,(%rax,%rdi,1)
movsd  0x50(%rsp),%xmm0
mov    0x30(%rsp),%rdi
add    %rsi,%rdi
movsd  %xmm0,(%rax,%rdi,1)
movsd  0x48(%rsp),%xmm0
add    0x38(%rsp),%rsi
movsd  %xmm0,(%rax,%rsi,1)
mov    0xc(%rsp),%eax
imul   $0x64,%rdx,%rdx
add    0x90(%rsp),%rdx
mov    %eax,(%rcx,%rdx,1)
jmp    11e0 <read_event+0x90>
mov    0x10(%rsp),%rax
mov    %r12d,(%rax)
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
@.str = [2 x i8] c"#\00"
@.str.1 = [15 x i8] c"%d %lf %lf %lf\00"
define i32 @read_event(i32* %0, double %1, i32* %2, i32* %3, [25 x double]* %4, [25 x double]* %5, [25 x double]* %6, [25 x i32]* %7) {
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca [25 x double]*
%15 = alloca [25 x double]*
%16 = alloca [25 x double]*
%17 = alloca [25 x i32]*
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i64
%21 = alloca i32
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca double
store i32* %0, i32** %10
store double %1, double* %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store [25 x double]* %4, [25 x double]** %14
store [25 x double]* %5, [25 x double]** %15
store [25 x double]* %6, [25 x double]** %16
store [25 x i32]* %7, [25 x i32]** %17
store i8* null, i8** %18
store i64 0, i64* %19
store i32 0, i32* %25
store double 0.000000e+00, double* %28
br label %29
29: ; preds = %101, %8
%30 = load i32*, i32** %10
%31 = call i64 @getline(i8** %18, i64* %19, i32* %30)
store i64 %31, i64* %20
%32 = load i64, i64* @EOF
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %102
34: ; preds = %29
%35 = load i8*, i8** %18
%36 = call i64 @strncmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32, i32* %25
%40 = load i32*, i32** %12
store i32 %39, i32* %40
%41 = load i8*, i8** %18
%42 = call i32 @free(i8* %41)
store i32 0, i32* %9
br label %113
43: ; preds = %34
%44 = load i8*, i8** %18
%45 = call i32 @sscanf(i8* %44, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %21, double* %22, double* %23, double* %24)
%46 = load i32, i32* %25
%47 = add nsw i32 %46, 1
store i32 %47, i32* %25
%48 = load double, double* %22
%49 = load double, double* %28
%50 = fsub double %48, %49
%51 = load double, double* %11
%52 = fdiv double %50, %51
%53 = call i64 @floor(double %52)
%54 = trunc i64 %53 to i32
store i32 %54, i32* %26
%55 = load i32, i32* %26
%56 = icmp slt i32 %55, 25
br i1 %56, label %57, label %101
57: ; preds = %43
%58 = load i32*, i32** %13
%59 = load i32, i32* %26
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 1
store i32 %63, i32* %61
%64 = load i32*, i32** %13
%65 = load i32, i32* %26
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
store i32 %68, i32* %27
%69 = load double, double* %22
%70 = load [25 x double]*, [25 x double]** %14
%71 = load i32, i32* %27
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [25 x double], [25 x double]* %70, i64 %72
%74 = load i32, i32* %26
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [25 x double], [25 x double]* %73, i64 0, i64 %75
store double %69, double* %76
%77 = load double, double* %23
%78 = load [25 x double]*, [25 x double]** %15
%79 = load i32, i32* %27
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [25 x double], [25 x double]* %78, i64 %80
%82 = load i32, i32* %26
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [25 x double], [25 x double]* %81, i64 0, i64 %83
store double %77, double* %84
%85 = load double, double* %24
%86 = load [25 x double]*, [25 x double]** %16
%87 = load i32, i32* %27
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [25 x double], [25 x double]* %86, i64 %88
%90 = load i32, i32* %26
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [25 x double], [25 x double]* %89, i64 0, i64 %91
store double %85, double* %92
%93 = load i32, i32* %21
%94 = load [25 x i32]*, [25 x i32]** %17
%95 = load i32, i32* %27
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [25 x i32], [25 x i32]* %94, i64 %96
%98 = load i32, i32* %26
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [25 x i32], [25 x i32]* %97, i64 0, i64 %99
store i32 %93, i32* %100
br label %101
101: ; preds = %57, %43
br label %29
102: ; preds = %29
%103 = load i32, i32* %25
%104 = load i32*, i32** %12
store i32 %103, i32* %104
%105 = load i8*, i8** %18
%106 = call i32 @free(i8* %105)
%107 = load i64, i64* %20
%108 = load i64, i64* @EOF
%109 = icmp eq i64 %107, %108
br i1 %109, label %110, label %113
110: ; preds = %102
%111 = load i64, i64* @EOF
%112 = trunc i64 %111 to i32
store i32 %112, i32* %9
br label %113
113: ; preds = %38, %110, %102
%114 = load i32, i32* %9
ret i32 %114
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [2 x i8] c"#\00"
@.str.1 = [15 x i8] c"%d %lf %lf %lf\00"
define i32 @read_event(i32* %0, double %1, i32* nocapture writeonly %2, i32* nocapture %3, [25 x double]* nocapture writeonly %4, [25 x double]* nocapture writeonly %5, [25 x double]* nocapture writeonly %6, [25 x i32]* nocapture writeonly %7) {
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = bitcast i8** %9 to i8*
store i8* null, i8** %9
%16 = bitcast i64* %10 to i8*
store i64 0, i64* %10
%17 = bitcast i32* %11 to i8*
%18 = bitcast double* %12 to i8*
%19 = bitcast double* %13 to i8*
%20 = bitcast double* %14 to i8*
%21 = call i64 @getline(i8** %9, i64* %10, i32* %0)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %60, label %24
24: ; preds = %8, %56
%25 = phi i32 [ %35, %56 ], [ 0, %8 ]
%26 = load i8*, i8** %9
%27 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
store i32 %25, i32* %2
%30 = load i8*, i8** %9
%31 = call i32 @free(i8* %30)
br label %69
32: ; preds = %24
%33 = load i8*, i8** %9
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %11, double* %12, double* %13, double* %14)
%35 = add nuw nsw i32 %25, 1
%36 = load double, double* %12
%37 = fdiv double %36, %1
%38 = call i64 @floor(double %37)
%39 = trunc i64 %38 to i32
%40 = icmp slt i32 %39, 25
br i1 %40, label %41, label %56
41: ; preds = %32
%42 = shl i64 %38, 32
%43 = ashr exact i64 %42, 32
%44 = getelementptr inbounds i32, i32* %3, i64 %43
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
%47 = load double, double* %12
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [25 x double], [25 x double]* %4, i64 %48, i64 %43
store double %47, double* %49
%50 = load double, double* %13
%51 = getelementptr inbounds [25 x double], [25 x double]* %5, i64 %48, i64 %43
store double %50, double* %51
%52 = load double, double* %14
%53 = getelementptr inbounds [25 x double], [25 x double]* %6, i64 %48, i64 %43
store double %52, double* %53
%54 = load i32, i32* %11
%55 = getelementptr inbounds [25 x i32], [25 x i32]* %7, i64 %48, i64 %43
store i32 %54, i32* %55
br label %56
56: ; preds = %41, %32
%57 = call i64 @getline(i8** %9, i64* %10, i32* %0)
%58 = load i64, i64* @EOF
%59 = icmp eq i64 %57, %58
br i1 %59, label %60, label %24
60: ; preds = %56, %8
%61 = phi i32 [ 0, %8 ], [ %35, %56 ]
%62 = phi i64 [ %21, %8 ], [ %57, %56 ]
store i32 %61, i32* %2
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
%65 = load i64, i64* @EOF
%66 = icmp eq i64 %62, %65
%67 = trunc i64 %65 to i32
%68 = select i1 %66, i32 %67, i32 undef
br label %69
69: ; preds = %60, %29
%70 = phi i32 [ 0, %29 ], [ %68, %60 ]
ret i32 %70
}