#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, float, float);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void read_metdata(char indir[400], float AFR[17897][6], float lat, float lon,
                  int Nparam) {
  FILE *fp;
  int i, param;
  char LATLON[50];
  char file[400];
  char fmtstr[15];
  short int tmpval[6];
  sprintf(fmtstr, "data_%%.%if_%%.%if", 4, 4);
  strcpy(file, indir);
  sprintf(LATLON, fmtstr, lat, lon);
  strcat(file, LATLON);
  printf("%s\n", file);
  if ((fp = fopen(file, "r")) == NULL) {
    printf("Cannot open file %s \n", file);
    exit(0);
  }
  for (i = 0; i < 17897; i++) {
    fread(tmpval, 6, sizeof(short int), fp);
    for (param = 0; param < Nparam; param++)
      AFR[i][param] = tmpval[param];
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_metdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x20f(%rbp),%rdi
lea    0xe56(%rip),%rsi
movss  0xe4a(%rip),%xmm1
movaps %xmm1,%xmm0
call   1090 <sprintf@plt>
lea    -0x200(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
lea    -0x20f(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1090 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x200(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1060 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1246 <read_metdata+0xc6>
lea    -0x200(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x45e9,-0x2c(%rbp)
jge    12d0 <read_metdata+0x150>
lea    -0x21c(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x6,%esi
mov    $0x2,%edx
call   1040 <fread@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12bd <read_metdata+0x13d>
movslq -0x30(%rbp),%rax
movswl -0x21c(%rbp,%rax,2),%eax
ff
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    127b <read_metdata+0xfb>
jmp    12c2 <read_metdata+0x142>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124d <read_metdata+0xcd>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_metdata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %edx,%ebp
movss  %xmm1,0x20(%rsp)
movss  %xmm0,0x18(%rsp)
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe58(%rip),%rsi
lea    0x41(%rsp),%r12
movss  0xe47(%rip),%xmm0
mov    %r12,%rdi
movaps %xmm0,%xmm1
call   1090 <sprintf@plt>
lea    0x90(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0x50(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
movss  0x18(%rsp),%xmm0
movss  0x20(%rsp),%xmm1
call   1090 <sprintf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
lea    0xe12(%rip),%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
lea    0xe07(%rip),%rsi
mov    %r13,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     13d6 <read_metdata+0x256>
mov    %rax,%r15
mov    %ebp,%ebx
mov    %ebx,%eax
and    $0xfffffff8,%eax
mov    %rax,0x20(%rsp)
add    $0xfffffffffffffff8,%rax
mov    %rax,0x18(%rsp)
mov    %rax,%rcx
shr    $0x3,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x38(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x30(%rsp)
mov    %r14,%r13
add    $0x30,%r14
xor    %r12d,%r12d
mov    %r13,0x28(%rsp)
jmp    1289 <read_metdata+0x109>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
add    $0x18,%r14
add    $0x18,%r13
cmp    $0x45e9,%r12
je     13bc <read_metdata+0x23c>
lea    0xc(%rsp),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
test   %ebp,%ebp
jle    1270 <read_metdata+0xf0>
cmp    $0x8,%ebp
jae    12b0 <read_metdata+0x130>
xor    %eax,%eax
jmp    1390 <read_metdata+0x210>
cmpq   $0x0,0x18(%rsp)
je     13b1 <read_metdata+0x231>
mov    0x30(%rsp),%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   0xc(%rsp,%rax,2),%xmm0
punpcklwd %xmm0,%xmm0
movq   0x14(%rsp,%rax,2),%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x10,%xmm0
cvtdq2ps %xmm0,%xmm0
psrad  $0x10,%xmm1
cvtdq2ps %xmm1,%xmm1
movups %xmm0,-0x30(%r14,%rax,4)
movups %xmm1,-0x20(%r14,%rax,4)
movq   0x1c(%rsp,%rax,2),%xmm0
punpcklwd %xmm0,%xmm0
movq   0x24(%rsp,%rax,2),%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x10,%xmm0
cvtdq2ps %xmm0,%xmm0
psrad  $0x10,%xmm1
cvtdq2ps %xmm1,%xmm1
movups %xmm0,-0x10(%r14,%rax,4)
movups %xmm1,(%r14,%rax,4)
add    $0x10,%rax
add    $0xfffffffffffffffe,%rcx
jne    12d0 <read_metdata+0x150>
testb  $0x1,0x38(%rsp)
je     137a <read_metdata+0x1fa>
movq   0xc(%rsp,%rax,2),%xmm0
punpcklwd %xmm0,%xmm0
movq   0x14(%rsp,%rax,2),%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x10,%xmm0
cvtdq2ps %xmm0,%xmm0
psrad  $0x10,%xmm1
cvtdq2ps %xmm1,%xmm1
lea    (%r12,%r12,2),%rcx
mov    0x28(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
movups %xmm0,(%rcx,%rax,4)
movups %xmm1,0x10(%rcx,%rax,4)
mov    0x20(%rsp),%rcx
mov    %rcx,%rax
cmp    %rbx,%rcx
je     1270 <read_metdata+0xf0>
nopl   0x0(%rax,%rax,1)
movswl 0xc(%rsp,%rax,2),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
movss  %xmm0,0x0(%r13,%rax,4)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1390 <read_metdata+0x210>
jmp    1270 <read_metdata+0xf0>
xor    %eax,%eax
testb  $0x1,0x38(%rsp)
jne    1340 <read_metdata+0x1c0>
jmp    137a <read_metdata+0x1fa>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc40(%rip),%rdi
lea    0x90(%rsp),%rsi
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"data_%%.%if_%%.%if\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Cannot open file %s \0A\00"
define void @read_metdata(i8* %0, [6 x float]* %1, float %2, float %3, i32 %4) {
%6 = alloca i8*
%7 = alloca [6 x float]*
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [50 x i8]
%15 = alloca [400 x i8]
%16 = alloca [15 x i8]
%17 = alloca [6 x i16]
store i8* %0, i8** %6
store [6 x float]* %1, [6 x float]** %7
store float %2, float* %8
store float %3, float* %9
store i32 %4, i32* %10
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %16, i64 0, i64 0
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float 4.000000e+00, float 4.000000e+00)
%20 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%21 = load i8*, i8** %6
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%24 = getelementptr inbounds [15 x i8], [15 x i8]* %16, i64 0, i64 0
%25 = load float, float* %8
%26 = load float, float* %9
%27 = call i32 @sprintf(i8* %23, i8* %24, float %25, float %26)
%28 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %11
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %5
%37 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %5
store i32 0, i32* %12
br label %41
41: ; preds = %69, %40
%42 = load i32, i32* %12
%43 = icmp slt i32 %42, 17897
br i1 %43, label %44, label %72
44: ; preds = %41
%45 = getelementptr inbounds [6 x i16], [6 x i16]* %17, i64 0, i64 0
%46 = load i32*, i32** %11
%47 = call i32 @fread(i16* %45, i32 6, i32 2, i32* %46)
store i32 0, i32* %13
br label %48
48: ; preds = %65, %44
%49 = load i32, i32* %13
%50 = load i32, i32* %10
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %68
52: ; preds = %48
%53 = load i32, i32* %13
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [6 x i16], [6 x i16]* %17, i64 0, i64 %54
%56 = load i16, i16* %55
%57 = sitofp i16 %56 to float
%58 = load [6 x float]*, [6 x float]** %7
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [6 x float], [6 x float]* %58, i64 %60
%62 = load i32, i32* %13
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [6 x float], [6 x float]* %61, i64 0, i64 %63
store float %57, float* %64
br label %65
65: ; preds = %52
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 1
store i32 %67, i32* %13
br label %48
68: ; preds = %48
br label %69
69: ; preds = %68
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %41
72: ; preds = %41
%73 = load i32*, i32** %11
%74 = call i32 @fclose(i32* %73)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"data_%%.%if_%%.%if\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Cannot open file %s \0A\00"
define void @read_metdata(i8* %0, [6 x float]* nocapture writeonly %1, float %2, float %3, i32 %4) {
%6 = alloca [50 x i8]
%7 = alloca [400 x i8]
%8 = alloca [15 x i8]
%9 = alloca [6 x i16]
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%13 = bitcast [6 x i16]* %9 to i8*
%14 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float 4.000000e+00, float 4.000000e+00)
%15 = call i32 @strcpy(i8* %11, i8* %0)
%16 = call i32 @sprintf(i8* %10, i8* %12, float %2, float %3)
%17 = call i32 @strcat(i8* %11, i8* %10)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%19 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %36, label %21
21: ; preds = %5
%22 = getelementptr inbounds [6 x i16], [6 x i16]* %9, i64 0, i64 0
%23 = icmp sgt i32 %4, 0
%24 = zext i32 %4 to i64
%25 = and i64 %24, 4294967288
%26 = add nsw i64 %25, -8
%27 = lshr exact i64 %26, 3
%28 = add nuw nsw i64 %27, 1
%29 = icmp ult i32 %4, 8
%30 = and i64 %24, 4294967288
%31 = and i64 %28, 1
%32 = icmp eq i64 %26, 0
%33 = and i64 %28, 4611686018427387902
%34 = icmp eq i64 %31, 0
%35 = icmp eq i64 %30, %24
br label %39
36: ; preds = %5
%37 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%38 = call i32 @exit(i32 0)
unreachable
39: ; preds = %21, %101
%40 = phi i64 [ 0, %21 ], [ %102, %101 ]
%41 = call i32 @fread(i16* %22, i32 6, i32 2, i32* %19)
br i1 %23, label %42, label %101
42: ; preds = %39
br i1 %29, label %91, label %43
43: ; preds = %42
br i1 %32, label %75, label %44
44: ; preds = %43, %44
%45 = phi i64 [ %72, %44 ], [ 0, %43 ]
%46 = phi i64 [ %73, %44 ], [ 0, %43 ]
%47 = getelementptr inbounds [6 x i16], [6 x i16]* %9, i64 0, i64 %45
%48 = bitcast i16* %47 to <4 x i16>*
%49 = load <4 x i16>, <4 x i16>* %48
%50 = getelementptr inbounds i16, i16* %47, i64 4
%51 = bitcast i16* %50 to <4 x i16>*
%52 = load <4 x i16>, <4 x i16>* %51
%53 = sitofp <4 x i16> %49 to <4 x float>
%54 = sitofp <4 x i16> %52 to <4 x float>
%55 = getelementptr inbounds [6 x float], [6 x float]* %1, i64 %40, i64 %45
%56 = bitcast float* %55 to <4 x float>*
store <4 x float> %53, <4 x float>* %56
%57 = getelementptr inbounds float, float* %55, i64 4
%58 = bitcast float* %57 to <4 x float>*
store <4 x float> %54, <4 x float>* %58
%59 = or i64 %45, 8
%60 = getelementptr inbounds [6 x i16], [6 x i16]* %9, i64 0, i64 %59
%61 = bitcast i16* %60 to <4 x i16>*
%62 = load <4 x i16>, <4 x i16>* %61
%63 = getelementptr inbounds i16, i16* %60, i64 4
%64 = bitcast i16* %63 to <4 x i16>*
%65 = load <4 x i16>, <4 x i16>* %64
%66 = sitofp <4 x i16> %62 to <4 x float>
%67 = sitofp <4 x i16> %65 to <4 x float>
%68 = getelementptr inbounds [6 x float], [6 x float]* %1, i64 %40, i64 %59
%69 = bitcast float* %68 to <4 x float>*
store <4 x float> %66, <4 x float>* %69
%70 = getelementptr inbounds float, float* %68, i64 4
%71 = bitcast float* %70 to <4 x float>*
store <4 x float> %67, <4 x float>* %71
%72 = add nuw i64 %45, 16
%73 = add i64 %46, 2
%74 = icmp eq i64 %73, %33
br i1 %74, label %75, label %44
75: ; preds = %44, %43
%76 = phi i64 [ 0, %43 ], [ %72, %44 ]
br i1 %34, label %90, label %77
77: ; preds = %75
%78 = getelementptr inbounds [6 x i16], [6 x i16]* %9, i64 0, i64 %76
%79 = bitcast i16* %78 to <4 x i16>*
%80 = load <4 x i16>, <4 x i16>* %79
%81 = getelementptr inbounds i16, i16* %78, i64 4
%82 = bitcast i16* %81 to <4 x i16>*
%83 = load <4 x i16>, <4 x i16>* %82
%84 = sitofp <4 x i16> %80 to <4 x float>
%85 = sitofp <4 x i16> %83 to <4 x float>
%86 = getelementptr inbounds [6 x float], [6 x float]* %1, i64 %40, i64 %76
%87 = bitcast float* %86 to <4 x float>*
store <4 x float> %84, <4 x float>* %87
%88 = getelementptr inbounds float, float* %86, i64 4
%89 = bitcast float* %88 to <4 x float>*
store <4 x float> %85, <4 x float>* %89
br label %90
90: ; preds = %75, %77
br i1 %35, label %101, label %91
91: ; preds = %42, %90
%92 = phi i64 [ 0, %42 ], [ %30, %90 ]
br label %93
93: ; preds = %91, %93
%94 = phi i64 [ %99, %93 ], [ %92, %91 ]
%95 = getelementptr inbounds [6 x i16], [6 x i16]* %9, i64 0, i64 %94
%96 = load i16, i16* %95
%97 = sitofp i16 %96 to float
%98 = getelementptr inbounds [6 x float], [6 x float]* %1, i64 %40, i64 %94
store float %97, float* %98
%99 = add nuw nsw i64 %94, 1
%100 = icmp eq i64 %99, %24
br i1 %100, label %101, label %93
101: ; preds = %93, %90, %39
%102 = add nuw nsw i64 %40, 1
%103 = icmp eq i64 %102, 17897
br i1 %103, label %104, label %39
104: ; preds = %101
%105 = call i32 @fclose(i32* %19)
ret void
}