#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*/ ave2day(float);
int diffdays(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *, float *);
float getactime(int /*<<< orphan*/ *);
int newdate(int, int /*<<< orphan*/);
scalar_t__ score(float, int);
void cfanalyses(char *sumfile, int today, int qtd, int *view, int *learn,
                float *pct, float *addscore, int *ncardl) {
  int card, date, revd;
  int late;
  float ave;
  FILE *fp;
  int alla = 1;
  *view = 0;
  *learn = 0;
  *pct = 0.0;
  *addscore = 0.0;
  *ncardl = 0;
  if (!(fp = fopen(sumfile, "r")))
    return;
  ave = getactime(fp);
  while (3 == fscanf(fp, "%d %d %f\n", &card, &date, &ave)) {
    (*view)++;
    *addscore += ave;
    if (ave >= 3.90)
      (*learn)++;
    if (ave < 4.92)
      alla = 0;
    revd = newdate(date, ave2day(ave));
    late = 0;
    if (today - revd >= 0) {
      late = diffdays(today, revd);
      (*ncardl)++;
    }
    *pct += score(ave, late);
  }
  fclose(fp);
  *pct /= ((float)qtd);
  if (*pct > 4.92 && alla)
    *pct = 5.0;
  *pct *= 20.0;
  if (*view == 0)
    *addscore = 0.0;
  else
    *addscore /= ((float)*view);
  if (*addscore > 4.92 && alla)
    *addscore = 5.0;
  return;
}


x86 assembly (clang, -O0):
<cfanalyses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1204 <cfanalyses+0x84>
jmp    13f8 <cfanalyses+0x278>
mov    -0x48(%rbp),%rdi
call   10a0 <getactime@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xe01(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1050 <fscanf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jne    1310 <cfanalyses+0x190>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movss  -0x3c(%rbp),%xmm0
mov    0x10(%rbp),%rax
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xda6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     127f <cfanalyses+0xff>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd70(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a1 <cfanalyses+0x121>
movl   $0x0,-0x4c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x50(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1040 <ave2day@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%esi
call   1070 <newdate@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x34(%rbp),%eax
cmp    $0x0,%eax
jl     12ed <cfanalyses+0x16d>
mov    -0xc(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1080 <diffdays@plt>
mov    %eax,-0x38(%rbp)
mov    0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x38(%rbp),%edi
call   1060 <score@plt>
cvtsi2ss %rax,%xmm0
mov    -0x28(%rbp),%rax
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
jmp    1212 <cfanalyses+0x92>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
cvtsi2ssl -0x10(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcbe(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1366 <cfanalyses+0x1e6>
cmpl   $0x0,-0x4c(%rbp)
je     1366 <cfanalyses+0x1e6>
mov    -0x28(%rbp),%rax
movss  0xcb6(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    13a3 <cfanalyses+0x223>
mov    0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    13bb <cfanalyses+0x23b>
mov    -0x18(%rbp),%rax
cvtsi2ssl (%rax),%xmm1
mov    0x10(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
mov    0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc31(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13f3 <cfanalyses+0x273>
cmpl   $0x0,-0x4c(%rbp)
je     13f3 <cfanalyses+0x273>
mov    0x10(%rbp),%rax
movss  0xc29(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    13f8 <cfanalyses+0x278>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfanalyses>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %edx,%r15d
mov    %esi,%ebp
mov    0x68(%rsp),%rdx
mov    0x60(%rsp),%rax
mov    %rcx,0x18(%rsp)
movl   $0x0,(%rcx)
mov    %r8,0x20(%rsp)
movl   $0x0,(%r8)
movl   $0x0,(%r9)
movl   $0x0,(%rax)
movl   $0x0,(%rdx)
lea    0xe4b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     13b2 <cfanalyses+0x232>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <getactime@plt>
movss  %xmm0,0x8(%rsp)
lea    0xe27(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %r13,%rdi
call   1050 <fscanf@plt>
mov    $0x1,%r14b
cmp    $0x3,%eax
jne    1301 <cfanalyses+0x181>
mov    %r15d,0x10(%rsp)
mov    $0x1,%r14d
jmp    1275 <cfanalyses+0xf5>
nopw   0x0(%rax,%rax,1)
movss  0x8(%rsp),%xmm0
mov    %r15d,%edi
call   1060 <score@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  (%rbx),%xmm0
movss  %xmm0,(%rbx)
mov    %r13,%rdi
lea    0xdc6(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <fscanf@plt>
cmp    $0x3,%eax
jne    12f5 <cfanalyses+0x175>
mov    0x18(%rsp),%rax
addl   $0x1,(%rax)
movss  0x8(%rsp),%xmm0
mov    0x60(%rsp),%rax
movss  (%rax),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rax)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
ucomisd 0xd5d(%rip),%xmm1
jb     12ad <cfanalyses+0x12d>
mov    0x20(%rsp),%rax
addl   $0x1,(%rax)
xor    %r15d,%r15d
movsd  0xd50(%rip),%xmm2
ucomisd %xmm1,%xmm2
cmova  %r15d,%r14d
mov    0xc(%rsp),%r12d
call   1040 <ave2day@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1070 <newdate@plt>
cmp    %ebp,%eax
jg     1230 <cfanalyses+0xb0>
mov    %ebp,%edi
mov    %eax,%esi
call   1080 <diffdays@plt>
mov    %eax,%r15d
mov    0x68(%rsp),%rax
addl   $0x1,(%rax)
jmp    1230 <cfanalyses+0xb0>
test   %r14d,%r14d
setne  %r14b
mov    0x10(%rsp),%r15d
mov    %r13,%rdi
call   1030 <fclose@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %r15d,%xmm1
movss  (%rbx),%xmm0
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulss  0xce8(%rip),%xmm0
test   %r14b,%r14b
jne    133c <cfanalyses+0x1bc>
movaps %xmm0,%xmm2
ucomisd 0xcd0(%rip),%xmm1
jbe    134e <cfanalyses+0x1ce>
jmp    1351 <cfanalyses+0x1d1>
movss  0xcd0(%rip),%xmm2
ucomisd 0xcbc(%rip),%xmm1
ja     1351 <cfanalyses+0x1d1>
movaps %xmm0,%xmm2
movss  %xmm2,(%rbx)
mov    0x18(%rsp),%rax
mov    (%rax),%eax
test   %eax,%eax
je     1376 <cfanalyses+0x1f6>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mov    0x60(%rsp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
jmp    1379 <cfanalyses+0x1f9>
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
test   %r14b,%r14b
jne    1394 <cfanalyses+0x214>
movaps %xmm0,%xmm1
ucomisd 0xc78(%rip),%xmm2
jbe    13a6 <cfanalyses+0x226>
jmp    13a9 <cfanalyses+0x229>
movss  0xc7c(%rip),%xmm1
ucomisd 0xc64(%rip),%xmm2
ja     13a9 <cfanalyses+0x229>
movaps %xmm0,%xmm1
mov    0x60(%rsp),%rax
movss  %xmm1,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"%d %d %f\0A\00"
define void @cfanalyses(i8* %0, i32 %1, i32 %2, i32* %3, i32* %4, float* %5, float* %6, i32* %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca float*
%15 = alloca float*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca float
%22 = alloca i32*
%23 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store float* %5, float** %14
store float* %6, float** %15
store i32* %7, i32** %16
store i32 1, i32* %23
%24 = load i32*, i32** %12
store i32 0, i32* %24
%25 = load i32*, i32** %13
store i32 0, i32* %25
%26 = load float*, float** %14
store float 0.000000e+00, float* %26
%27 = load float*, float** %15
store float 0.000000e+00, float* %27
%28 = load i32*, i32** %16
store i32 0, i32* %28
%29 = load i8*, i8** %9
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %30, i32** %22
%31 = icmp ne i32* %30, null
br i1 %31, label %33, label %32
32: ; preds = %8
br label %130
33: ; preds = %8
%34 = load i32*, i32** %22
%35 = call float @getactime(i32* %34)
store float %35, float* %21
br label %36
36: ; preds = %76, %33
%37 = load i32*, i32** %22
%38 = call i32 @fscanf(i32* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %17, i32* %18, float* %21)
%39 = icmp eq i32 3, %38
br i1 %39, label %40, label %84
40: ; preds = %36
%41 = load i32*, i32** %12
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
%44 = load float, float* %21
%45 = load float*, float** %15
%46 = load float, float* %45
%47 = fadd float %46, %44
store float %47, float* %45
%48 = load float, float* %21
%49 = fpext float %48 to double
%50 = fcmp oge double %49, 3.900000e+00
br i1 %50, label %51, label %55
51: ; preds = %40
%52 = load i32*, i32** %13
%53 = load i32, i32* %52
%54 = add nsw i32 %53, 1
store i32 %54, i32* %52
br label %55
55: ; preds = %51, %40
%56 = load float, float* %21
%57 = fpext float %56 to double
%58 = fcmp olt double %57, 4.920000e+00
br i1 %58, label %59, label %60
59: ; preds = %55
store i32 0, i32* %23
br label %60
60: ; preds = %59, %55
%61 = load i32, i32* %18
%62 = load float, float* %21
%63 = call i32 @ave2day(float %62)
%64 = call i32 @newdate(i32 %61, i32 %63)
store i32 %64, i32* %19
store i32 0, i32* %20
%65 = load i32, i32* %10
%66 = load i32, i32* %19
%67 = sub nsw i32 %65, %66
%68 = icmp sge i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %60
%70 = load i32, i32* %10
%71 = load i32, i32* %19
%72 = call i32 @diffdays(i32 %70, i32 %71)
store i32 %72, i32* %20
%73 = load i32*, i32** %16
%74 = load i32, i32* %73
%75 = add nsw i32 %74, 1
store i32 %75, i32* %73
br label %76
76: ; preds = %69, %60
%77 = load float, float* %21
%78 = load i32, i32* %20
%79 = call i64 @score(float %77, i32 %78)
%80 = sitofp i64 %79 to float
%81 = load float*, float** %14
%82 = load float, float* %81
%83 = fadd float %82, %80
store float %83, float* %81
br label %36
84: ; preds = %36
%85 = load i32*, i32** %22
%86 = call i32 @fclose(i32* %85)
%87 = load i32, i32* %11
%88 = sitofp i32 %87 to float
%89 = load float*, float** %14
%90 = load float, float* %89
%91 = fdiv float %90, %88
store float %91, float* %89
%92 = load float*, float** %14
%93 = load float, float* %92
%94 = fpext float %93 to double
%95 = fcmp ogt double %94, 4.920000e+00
br i1 %95, label %96, label %101
96: ; preds = %84
%97 = load i32, i32* %23
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = load float*, float** %14
store float 5.000000e+00, float* %100
br label %101
101: ; preds = %99, %96, %84
%102 = load float*, float** %14
%103 = load float, float* %102
%104 = fpext float %103 to double
%105 = fmul double %104, 2.000000e+01
%106 = fptrunc double %105 to float
store float %106, float* %102
%107 = load i32*, i32** %12
%108 = load i32, i32* %107
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %101
%111 = load float*, float** %15
store float 0.000000e+00, float* %111
br label %119
112: ; preds = %101
%113 = load i32*, i32** %12
%114 = load i32, i32* %113
%115 = sitofp i32 %114 to float
%116 = load float*, float** %15
%117 = load float, float* %116
%118 = fdiv float %117, %115
store float %118, float* %116
br label %119
119: ; preds = %112, %110
%120 = load float*, float** %15
%121 = load float, float* %120
%122 = fpext float %121 to double
%123 = fcmp ogt double %122, 4.920000e+00
br i1 %123, label %124, label %129
124: ; preds = %119
%125 = load i32, i32* %23
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %129
127: ; preds = %124
%128 = load float*, float** %15
store float 5.000000e+00, float* %128
br label %129
129: ; preds = %127, %124, %119
br label %130
130: ; preds = %129, %32
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"%d %d %f\0A\00"
define void @cfanalyses(i8* nocapture %0, i32 %1, i32 %2, i32* nocapture %3, i32* nocapture %4, float* nocapture %5, float* nocapture %6, i32* nocapture %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = bitcast i32* %9 to i8*
%13 = bitcast i32* %10 to i8*
%14 = bitcast float* %11 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
store i32 0, i32* %7
%15 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %78, label %17
17: ; preds = %8
%18 = tail call float @getactime(i32* %15)
store float %18, float* %11
%19 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %10, float* %11)
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %55
21: ; preds = %17, %44
%22 = phi i32 [ %35, %44 ], [ 1, %17 ]
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load float, float* %11
%26 = load float, float* %6
%27 = fadd float %25, %26
store float %27, float* %6
%28 = fpext float %25 to double
%29 = fcmp ult double %28, 3.900000e+00
br i1 %29, label %33, label %30
30: ; preds = %21
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %33
33: ; preds = %30, %21
%34 = fcmp olt double %28, 4.920000e+00
%35 = select i1 %34, i32 0, i32 %22
%36 = load i32, i32* %10
%37 = call i32 @ave2day(float %25)
%38 = call i32 @newdate(i32 %36, i32 %37)
%39 = icmp sgt i32 %38, %1
br i1 %39, label %44, label %40
40: ; preds = %33
%41 = call i32 @diffdays(i32 %1, i32 %38)
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %44
44: ; preds = %40, %33
%45 = phi i32 [ %41, %40 ], [ 0, %33 ]
%46 = load float, float* %11
%47 = call i64 @score(float %46, i32 %45)
%48 = sitofp i64 %47 to float
%49 = load float, float* %5
%50 = fadd float %49, %48
store float %50, float* %5
%51 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %10, float* %11)
%52 = icmp eq i32 %51, 3
br i1 %52, label %21, label %53
53: ; preds = %44
%54 = icmp ne i32 %35, 0
br label %55
55: ; preds = %53, %17
%56 = phi i1 [ true, %17 ], [ %54, %53 ]
%57 = call i32 @fclose(i32* %15)
%58 = sitofp i32 %2 to float
%59 = load float, float* %5
%60 = fdiv float %59, %58
%61 = fpext float %60 to double
%62 = fcmp ogt double %61, 4.920000e+00
%63 = select i1 %62, i1 %56, i1 false
%64 = fmul float %60, 2.000000e+01
%65 = select i1 %63, float 1.000000e+02, float %64
store float %65, float* %5
%66 = load i32, i32* %3
%67 = icmp eq i32 %66, 0
br i1 %67, label %72, label %68
68: ; preds = %55
%69 = sitofp i32 %66 to float
%70 = load float, float* %6
%71 = fdiv float %70, %69
br label %72
72: ; preds = %55, %68
%73 = phi float [ %71, %68 ], [ 0.000000e+00, %55 ]
%74 = fpext float %73 to double
%75 = fcmp ogt double %74, 4.920000e+00
%76 = select i1 %75, i1 %56, i1 false
%77 = select i1 %76, float 5.000000e+00, float %73
store float %77, float* %6
br label %78
78: ; preds = %8, %72
ret void
}