#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 /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
main(int argc, char *argv[]) {
  int i, j, k, m, n, numsteps, numdata, numcells, numtoread, skip;
  int flag, datatype;
  float Max, tmp;
  FILE *filelist, *inputfile, *outputfile, *workfile, *outputnr;
  int year, nmth, startyear, endyear, yrday;
  if (argc != 7) {
    printf("Wrong command line arguments: enter <infile> <outfile> <startyear> "
           "<endyear> <numcells > .\n");
    exit(0);
  }
  inputfile = fopen(argv[1], "r");
  outputfile = fopen(argv[2], "w");
  outputnr = fopen(argv[6], "w");
  sscanf(argv[3], "%d", &startyear);
  sscanf(argv[4], "%d", &endyear);
  sscanf(argv[5], "%d", &numcells);
  if (startyear > endyear) {
    printf("Startyear and endyear improperly  defined.\n");
    exit(0);
  }
  n = 0;
  m = 0;
  Max = 0;
  for (year = startyear; year <= endyear; year++) {
    for (nmth = 1; nmth <= 12; nmth++) {
      n++;
      for (i = 0; i < numcells; i++) {
        fscanf(inputfile, "%f", &tmp);
        if (Max < tmp)
          Max = tmp;
      }
    }
    fprintf(outputfile, " %5.4f ", Max);
    fprintf(outputfile, "\n");
    Max = 0;
    m++;
  }
  printf("Done.\nNumber of daily timesteps processed = %d.\n", n);
  fprintf(outputnr, "%d.", m);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x7,-0x8(%rbp)
je     1198 <main+0x38>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe71(%rip),%rsi
lea    -0x7c(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe59(%rip),%rsi
lea    -0x80(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe41(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x7c(%rbp),%eax
cmp    -0x80(%rbp),%eax
jle    1249 <main+0xe9>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x80(%rbp),%eax
jg     1341 <main+0x1e1>
movl   $0x1,-0x78(%rbp)
cmpl   $0xc,-0x78(%rbp)
jg     12f5 <main+0x195>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12e2 <main+0x182>
mov    -0x58(%rbp),%rdi
lea    0xde6(%rip),%rsi
lea    -0x48(%rbp),%rdx
call   1040 <fscanf@plt>
movss  -0x44(%rbp),%xmm1
movss  -0x48(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12cf <main+0x16f>
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
jmp    12d4 <main+0x174>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1292 <main+0x132>
jmp    12e7 <main+0x187>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1278 <main+0x118>
mov    -0x60(%rbp),%rdi
movss  -0x44(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd89(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x60(%rbp),%rdi
lea    0xd3f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1265 <main+0x105>
mov    -0x24(%rbp),%esi
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x7,%edi
jne    133a <main+0x1ba>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xe4a(%rip),%r14
mov    %r14,%rsi
call   1090 <fopen@plt>
mov    %rax,0x28(%rsp)
mov    0x30(%rbp),%rdi
mov    %r14,%rsi
call   1090 <fopen@plt>
mov    %rax,0x20(%rsp)
mov    0x18(%rbp),%rdi
lea    0xe23(%rip),%r14
lea    0x18(%rsp),%rdx
mov    %r14,%rsi
call   1080 <sscanf@plt>
mov    0x20(%rbp),%rdi
lea    0x4(%rsp),%rdx
mov    %r14,%rsi
call   1080 <sscanf@plt>
mov    0x28(%rbp),%rdi
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   1080 <sscanf@plt>
mov    0x18(%rsp),%eax
cmp    0x4(%rsp),%eax
jg     1343 <main+0x1c3>
xor    %r14d,%r14d
mov    $0xc,%r15d
lea    0xdd9(%rip),%r13
lea    0x1c(%rsp),%rbp
xor    %r12d,%r12d
jmp    128b <main+0x10b>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%r12d
add    $0xc,%r12d
cvtss2sd %xmm0,%xmm0
mov    0x28(%rsp),%r14
mov    %r14,%rdi
lea    0xdae(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
mov    0x10(%rsp),%r14d
add    $0x1,%r14d
mov    0x30(%rsp),%rcx
lea    0x1(%rcx),%eax
add    $0xc,%r15d
cmp    0x4(%rsp),%ecx
jge    1302 <main+0x182>
mov    %rax,0x30(%rsp)
mov    %r14d,0x10(%rsp)
xorps  %xmm0,%xmm0
mov    0x8(%rsp),%eax
mov    %r12d,0xc(%rsp)
mov    %r12d,%r14d
jmp    12b5 <main+0x135>
cs nopw 0x0(%rax,%rax,1)
cmp    %r15d,%r14d
je     1240 <main+0xc0>
add    $0x1,%r14d
test   %eax,%eax
jle    12b0 <main+0x130>
xor    %r12d,%r12d
movaps %xmm0,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm1,0x14(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <fscanf@plt>
movss  0x1c(%rsp),%xmm0
maxss  0x14(%rsp),%xmm0
add    $0x1,%r12d
mov    0x8(%rsp),%eax
movaps %xmm0,%xmm1
cmp    %eax,%r12d
jl     12d0 <main+0x150>
jmp    12b0 <main+0x130>
lea    0xd09(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd29(%rip),%rsi
mov    0x20(%rsp),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd31(%rip),%rdi
jmp    134a <main+0x1ca>
lea    0xcfd(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [92 x i8] c"Wrong command line arguments: enter <infile> <outfile> <startyear> <endyear> <numcells > .\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [44 x i8] c"Startyear and endyear improperly defined.\0A\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [8 x i8] c" %5.4f \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [49 x i8] c"Done.\0ANumber of daily timesteps processed = %d.\0A\00"
@.str.9 = [4 x i8] c"%d.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca float
%19 = alloca float
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 7
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %2
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %21
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %43, i32** %22
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 6
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %47, i32** %24
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i32 @sscanf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %27)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
%55 = call i32 @sscanf(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %28)
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 5
%58 = load i8*, i8** %57
%59 = call i32 @sscanf(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %13)
%60 = load i32, i32* %27
%61 = load i32, i32* %28
%62 = icmp sgt i32 %60, %61
br i1 %62, label %63, label %66
63: ; preds = %35
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %35
store i32 0, i32* %10
store i32 0, i32* %9
store float 0.000000e+00, float* %18
%67 = load i32, i32* %27
store i32 %67, i32* %25
br label %68
68: ; preds = %108, %66
%69 = load i32, i32* %25
%70 = load i32, i32* %28
%71 = icmp sle i32 %69, %70
br i1 %71, label %72, label %111
72: ; preds = %68
store i32 1, i32* %26
br label %73
73: ; preds = %96, %72
%74 = load i32, i32* %26
%75 = icmp sle i32 %74, 12
br i1 %75, label %76, label %99
76: ; preds = %73
%77 = load i32, i32* %10
%78 = add nsw i32 %77, 1
store i32 %78, i32* %10
store i32 0, i32* %6
br label %79
79: ; preds = %92, %76
%80 = load i32, i32* %6
%81 = load i32, i32* %13
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %95
83: ; preds = %79
%84 = load i32*, i32** %21
%85 = call i32 @fscanf(i32* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %19)
%86 = load float, float* %18
%87 = load float, float* %19
%88 = fcmp olt float %86, %87
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = load float, float* %19
store float %90, float* %18
br label %91
91: ; preds = %89, %83
br label %92
92: ; preds = %91
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 1
store i32 %94, i32* %6
br label %79
95: ; preds = %79
br label %96
96: ; preds = %95
%97 = load i32, i32* %26
%98 = add nsw i32 %97, 1
store i32 %98, i32* %26
br label %73
99: ; preds = %73
%100 = load i32*, i32** %22
%101 = load float, float* %18
%102 = fpext float %101 to double
%103 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %102)
%104 = load i32*, i32** %22
%105 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store float 0.000000e+00, float* %18
%106 = load i32, i32* %9
%107 = add nsw i32 %106, 1
store i32 %107, i32* %9
br label %108
108: ; preds = %99
%109 = load i32, i32* %25
%110 = add nsw i32 %109, 1
store i32 %110, i32* %25
br label %68
111: ; preds = %68
%112 = load i32, i32* %10
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %112)
%114 = load i32*, i32** %24
%115 = load i32, i32* %9
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [8 x i8] c" %5.4f \00"
@.str.8 = [49 x i8] c"Done.\0ANumber of daily timesteps processed = %d.\0A\00"
@.str.9 = [4 x i8] c"%d.\00"
@str = [43 x i8] c"Startyear and endyear improperly defined.\00"
@str.10 = [91 x i8] c"Wrong command line arguments: enter <infile> <outfile> <startyear> <endyear> <numcells > .\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 7
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.10, i64 0, i64 0))
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds i8*, i8** %1, i64 6
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%28 = getelementptr inbounds i8*, i8** %1, i64 4
%29 = load i8*, i8** %28
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%31 = getelementptr inbounds i8*, i8** %1, i64 5
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %15
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %15, %66
%41 = phi i32 [ %75, %66 ], [ 12, %15 ]
%42 = phi i32 [ %72, %66 ], [ %34, %15 ]
%43 = phi i32 [ %71, %66 ], [ 0, %15 ]
%44 = phi i32 [ %67, %66 ], [ 0, %15 ]
%45 = load i32, i32* %3
br label %46
46: ; preds = %40, %62
%47 = phi i32 [ %45, %40 ], [ %63, %62 ]
%48 = phi i32 [ %44, %40 ], [ %50, %62 ]
%49 = phi float [ 0.000000e+00, %40 ], [ %64, %62 ]
%50 = add i32 %48, 1
%51 = icmp sgt i32 %47, 0
br i1 %51, label %52, label %62
52: ; preds = %46, %52
%53 = phi i32 [ %59, %52 ], [ 0, %46 ]
%54 = phi float [ %58, %52 ], [ %49, %46 ]
%55 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%56 = load float, float* %4
%57 = fcmp olt float %54, %56
%58 = select i1 %57, float %56, float %54
%59 = add nuw nsw i32 %53, 1
%60 = load i32, i32* %3
%61 = icmp slt i32 %59, %60
br i1 %61, label %52, label %62
62: ; preds = %52, %46
%63 = phi i32 [ %47, %46 ], [ %60, %52 ]
%64 = phi float [ %49, %46 ], [ %58, %52 ]
%65 = icmp eq i32 %50, %41
br i1 %65, label %66, label %46
66: ; preds = %62
%67 = add i32 %44, 12
%68 = fpext float %64 to double
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %68)
%70 = call i32 @fputc(i32 10, i32* %21)
%71 = add nuw nsw i32 %43, 1
%72 = add nsw i32 %42, 1
%73 = load i32, i32* %6
%74 = icmp slt i32 %42, %73
%75 = add i32 %41, 12
br i1 %74, label %40, label %76
76: ; preds = %66
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %67)
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %71)
ret i32 0
}