#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*/ LC_ALL;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *,
                          int *);
int /*<<< orphan*/ is_valid_date(int, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "RUS");
  int i, sum, day, month, year, temperature;
  FILE *file_pointer;
  char *file_name = "temperature";
  do {
    printf("\nВведите дату день/месяц/год (слэш - разделитель): ");
    scanf("%d/%d/%d", &day, &month, &year);
  } while (!is_valid_date(day, month, year));
  do {
    printf("\nВведите температуру (в диапазоне [-100; 80]): ");
    scanf("%d", &temperature);
  } while (temperature < -100 || temperature > 80);
  printf("\nСохранение данных...");
  file_pointer = fopen(file_name, "a");
  if (file_pointer == NULL) {
    perror("Невозможно открыть файл для записи");
    return -1;
  }
  fprintf(file_pointer, "%d %d %d %d\n", day, month, year, temperature);
  fclose(file_pointer);
  printf("\nЗагрузка данных...");
  file_pointer = fopen(file_name, "r");
  if (file_pointer == NULL) {
    perror("Невозможно открыть файл для чтения");
    return -1;
  }
  for (i = 0, sum = 0; !feof(file_pointer); i++) {
    fscanf(file_pointer, "%d %d %d %d", &day, &month, &year, &temperature);
    sum += temperature;
  }
  fclose(file_pointer);
  printf("\nСреднее значение температуры: %lf", (double)sum / i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1090 <setlocale@plt>
lea    0xe39(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <is_valid_date@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11cf <main+0x2f>
jmp    121a <main+0x7a>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf74(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    $0x1,%al
cmpl   $0xffffff9c,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
jl     1253 <main+0xb3>
cmpl   $0x50,-0x1c(%rbp)
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    121a <main+0x7a>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12a3 <main+0x103>
lea    0xe55(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    139e <main+0x1fe>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe6c(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    130f <main+0x16f>
lea    0xe5b(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    139e <main+0x1fe>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    133b <main+0x19b>
jmp    1372 <main+0x1d2>
mov    -0x28(%rbp),%rdi
lea    0xe54(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
lea    -0x1c(%rbp),%r9
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    131d <main+0x17d>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe16(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1090 <setlocale@plt>
lea    0xe46(%rip),%r14
lea    0xe99(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
lea    0x4(%rsp),%rbp
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1060 <is_valid_date@plt>
test   %eax,%eax
je     11e0 <main+0x40>
lea    0xe5a(%rip),%r14
lea    0xf83(%rip),%rbp
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    (%rsp),%eax
add    $0xffffffaf,%eax
cmp    $0xffffff4b,%eax
jb     1230 <main+0x90>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd9b(%rip),%rdi
lea    0xe75(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1378 <main+0x1d8>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r8d
mov    (%rsp),%r9d
lea    0xe8f(%rip),%rsi
mov    %rax,%rdi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd46(%rip),%rdi
lea    0xe92(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1381 <main+0x1e1>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
test   %eax,%eax
jne    1341 <main+0x1a1>
xor    %r14d,%r14d
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%rbp
xor    %r15d,%r15d
nopl   (%rax)
mov    %rbx,%rdi
lea    0xe90(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1050 <fscanf@plt>
add    (%rsp),%r14d
add    $0x1,%r15d
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1300 <main+0x160>
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe4c(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd68(%rip),%rdi
jmp    1388 <main+0x1e8>
lea    0xdd1(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%eax
jmp    1369 <main+0x1c9>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [12 x i8] c"temperature\00"
@.str.2 = [90 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D0\B4\D0\B0\D1\82\D1\83 \D0\B4\D0\B5\D0\BD\D1\8C/\D0\BC\D0\B5\D1\81\D1\8F\D1\86/\D0\B3\D0\BE\D0\B4 (\D1\81\D0\BB\D1\8D\D1\88 - \D1\80\D0\B0\D0\B7\D0\B4\D0\B5\D0\BB\D0\B8\D1\82\D0\B5\D0\BB\D1\8C): \00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
@.str.4 = [76 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\82\D0\B5\D0\BC\D0\BF\D0\B5\D1\80\D0\B0\D1\82\D1\83\D1\80\D1\83 (\D0\B2 \D0\B4\D0\B8\D0\B0\D0\BF\D0\B0\D0\B7\D0\BE\D0\BD\D0\B5 [-100; 80]): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [38 x i8] c"\0A\D0\A1\D0\BE\D1\85\D1\80\D0\B0\D0\BD\D0\B5\D0\BD\D0\B8\D0\B5 \D0\B4\D0\B0\D0\BD\D0\BD\D1\8B\D1\85...\00"
@.str.7 = [2 x i8] c"a\00"
@.str.8 = [65 x i8] c"\D0\9D\D0\B5\D0\B2\D0\BE\D0\B7\D0\BC\D0\BE\D0\B6\D0\BD\D0\BE \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D1\8C \D1\84\D0\B0\D0\B9\D0\BB \D0\B4\D0\BB\D1\8F \D0\B7\D0\B0\D0\BF\D0\B8\D1\81\D0\B8\00"
@.str.9 = [13 x i8] c"%d %d %d %d\0A\00"
@.str.10 = [34 x i8] c"\0A\D0\97\D0\B0\D0\B3\D1\80\D1\83\D0\B7\D0\BA\D0\B0 \D0\B4\D0\B0\D0\BD\D0\BD\D1\8B\D1\85...\00"
@.str.11 = [2 x i8] c"r\00"
@.str.12 = [65 x i8] c"\D0\9D\D0\B5\D0\B2\D0\BE\D0\B7\D0\BC\D0\BE\D0\B6\D0\BD\D0\BE \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D1\8C \D1\84\D0\B0\D0\B9\D0\BB \D0\B4\D0\BB\D1\8F \D1\87\D1\82\D0\B5\D0\BD\D0\B8\D1\8F\00"
@.str.13 = [12 x i8] c"%d %d %d %d\00"
@.str.14 = [61 x i8] c"\0A\D0\A1\D1\80\D0\B5\D0\B4\D0\BD\D0\B5\D0\B5 \D0\B7\D0\BD\D0\B0\D1\87\D0\B5\D0\BD\D0\B8\D0\B5 \D1\82\D0\B5\D0\BC\D0\BF\D0\B5\D1\80\D0\B0\D1\82\D1\83\D1\80\D1\8B: %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
store i32 0, i32* %1
%10 = load i32, i32* @LC_ALL
%11 = call i32 @setlocale(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %12
12: ; preds = %15, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
br label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @is_valid_date(i32 %16, i32 %17, i32 %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %12, label %22
22: ; preds = %15
br label %23
23: ; preds = %32, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
br label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, -100
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 80
br label %32
32: ; preds = %29, %26
%33 = phi i1 [ true, %26 ], [ %31, %29 ]
br i1 %33, label %23, label %34
34: ; preds = %32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%36 = load i8*, i8** %9
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %37, i32** %8
%38 = load i32*, i32** %8
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 @perror(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %1
br label %82
42: ; preds = %34
%43 = load i32*, i32** %8
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %44, i32 %45, i32 %46, i32 %47)
%49 = load i32*, i32** %8
%50 = call i32 @fclose(i32* %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
%52 = load i8*, i8** %9
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %53, i32** %8
%54 = load i32*, i32** %8
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %58
56: ; preds = %42
%57 = call i32 @perror(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %1
br label %82
58: ; preds = %42
store i32 0, i32* %2
store i32 0, i32* %3
br label %59
59: ; preds = %70, %58
%60 = load i32*, i32** %8
%61 = call i32 @feof(i32* %60)
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
br i1 %63, label %64, label %73
64: ; preds = %59
%65 = load i32*, i32** %8
%66 = call i32 @fscanf(i32* %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7)
%67 = load i32, i32* %7
%68 = load i32, i32* %3
%69 = add nsw i32 %68, %67
store i32 %69, i32* %3
br label %70
70: ; preds = %64
%71 = load i32, i32* %2
%72 = add nsw i32 %71, 1
store i32 %72, i32* %2
br label %59
73: ; preds = %59
%74 = load i32*, i32** %8
%75 = call i32 @fclose(i32* %74)
%76 = load i32, i32* %3
%77 = sitofp i32 %76 to double
%78 = load i32, i32* %2
%79 = sitofp i32 %78 to double
%80 = fdiv double %77, %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0), double %80)
store i32 0, i32* %1
br label %82
82: ; preds = %73, %56, %40
%83 = load i32, i32* %1
ret i32 %83
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [12 x i8] c"temperature\00"
@.str.2 = [90 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D0\B4\D0\B0\D1\82\D1\83 \D0\B4\D0\B5\D0\BD\D1\8C/\D0\BC\D0\B5\D1\81\D1\8F\D1\86/\D0\B3\D0\BE\D0\B4 (\D1\81\D0\BB\D1\8D\D1\88 - \D1\80\D0\B0\D0\B7\D0\B4\D0\B5\D0\BB\D0\B8\D1\82\D0\B5\D0\BB\D1\8C): \00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
@.str.4 = [76 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\82\D0\B5\D0\BC\D0\BF\D0\B5\D1\80\D0\B0\D1\82\D1\83\D1\80\D1\83 (\D0\B2 \D0\B4\D0\B8\D0\B0\D0\BF\D0\B0\D0\B7\D0\BE\D0\BD\D0\B5 [-100; 80]): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [38 x i8] c"\0A\D0\A1\D0\BE\D1\85\D1\80\D0\B0\D0\BD\D0\B5\D0\BD\D0\B8\D0\B5 \D0\B4\D0\B0\D0\BD\D0\BD\D1\8B\D1\85...\00"
@.str.7 = [2 x i8] c"a\00"
@.str.8 = [65 x i8] c"\D0\9D\D0\B5\D0\B2\D0\BE\D0\B7\D0\BC\D0\BE\D0\B6\D0\BD\D0\BE \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D1\8C \D1\84\D0\B0\D0\B9\D0\BB \D0\B4\D0\BB\D1\8F \D0\B7\D0\B0\D0\BF\D0\B8\D1\81\D0\B8\00"
@.str.9 = [13 x i8] c"%d %d %d %d\0A\00"
@.str.10 = [34 x i8] c"\0A\D0\97\D0\B0\D0\B3\D1\80\D1\83\D0\B7\D0\BA\D0\B0 \D0\B4\D0\B0\D0\BD\D0\BD\D1\8B\D1\85...\00"
@.str.11 = [2 x i8] c"r\00"
@.str.12 = [65 x i8] c"\D0\9D\D0\B5\D0\B2\D0\BE\D0\B7\D0\BC\D0\BE\D0\B6\D0\BD\D0\BE \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D1\8C \D1\84\D0\B0\D0\B9\D0\BB \D0\B4\D0\BB\D1\8F \D1\87\D1\82\D0\B5\D0\BD\D0\B8\D1\8F\00"
@.str.13 = [12 x i8] c"%d %d %d %d\00"
@.str.14 = [61 x i8] c"\0A\D0\A1\D1\80\D0\B5\D0\B4\D0\BD\D0\B5\D0\B5 \D0\B7\D0\BD\D0\B0\D1\87\D0\B5\D0\BD\D0\B8\D0\B5 \D1\82\D0\B5\D0\BC\D0\BF\D0\B5\D1\80\D0\B0\D1\82\D1\83\D1\80\D1\8B: %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @LC_ALL
%6 = tail call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
br label %11
11: ; preds = %11, %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @is_valid_date(i32 %14, i32 %15, i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %11, label %19
19: ; preds = %11, %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%22 = load i32, i32* %4
%23 = add i32 %22, -81
%24 = icmp ult i32 %23, -181
br i1 %24, label %19, label %25
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.8, i64 0, i64 0))
br label %64
31: ; preds = %25
%32 = load i32, i32* %1
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %32, i32 %33, i32 %34, i32 %35)
%37 = call i32 @fclose(i32* %27)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %31
%42 = call i32 @feof(i32* %39)
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %58
44: ; preds = %31
%45 = call i32 @perror(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %64
46: ; preds = %41, %46
%47 = phi i32 [ %51, %46 ], [ 0, %41 ]
%48 = phi i32 [ %52, %46 ], [ 0, %41 ]
%49 = call i32 @fscanf(i32* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%50 = load i32, i32* %4
%51 = add nsw i32 %50, %47
%52 = add nuw nsw i32 %48, 1
%53 = call i32 @feof(i32* %39)
%54 = icmp eq i32 %53, 0
br i1 %54, label %46, label %55
55: ; preds = %46
%56 = sitofp i32 %51 to double
%57 = sitofp i32 %52 to double
br label %58
58: ; preds = %55, %41
%59 = phi double [ 0.000000e+00, %41 ], [ %57, %55 ]
%60 = phi double [ 0.000000e+00, %41 ], [ %56, %55 ]
%61 = call i32 @fclose(i32* %39)
%62 = fdiv double %60, %59
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0), double %62)
br label %64
64: ; preds = %58, %44, %29
%65 = phi i32 [ -1, %29 ], [ -1, %44 ], [ 0, %58 ]
ret i32 %65
}