#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*/ fscanf(int /*<<< orphan*/ *, char *, float *);
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[10957][6], float lat, float lon,
                  int Nparam) {
  FILE *fp;
  int i, param;
  char LATLON[50];
  char file[400];
  strcpy(file, indir);
  sprintf(LATLON, "data_%.4f_%.4f", 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 < 10957; i++)
    for (param = 0; param < Nparam; param++)
      fscanf(fp, "%f", &AFR[i][param]);
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_metdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x200(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
lea    0xe3b(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x200(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x200(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1050 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1228 <read_metdata+0xa8>
lea    -0x200(%rbp),%rsi
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2acd,-0x2c(%rbp)
jge    129a <read_metdata+0x11a>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1287 <read_metdata+0x107>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x2c(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdb7(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1243 <read_metdata+0xc3>
jmp    128c <read_metdata+0x10c>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    122f <read_metdata+0xaf>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_metdata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
mov    %edx,%ebx
movss  %xmm1,(%rsp)
movss  %xmm0,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xe48(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
movss  0x8(%rsp),%xmm0
movss  (%rsp),%xmm1
call   1090 <sprintf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xe2d(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
lea    0xe22(%rip),%rsi
mov    %rbp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     1274 <read_metdata+0xf4>
mov    %rax,%rbp
mov    %ebx,%eax
mov    %rax,(%rsp)
xor    %r14d,%r14d
lea    0xe1a(%rip),%r12
mov    %ebx,0xc(%rsp)
jmp    1235 <read_metdata+0xb5>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0x18,%r15
cmp    $0x2acd,%r14
mov    0xc(%rsp),%ebx
je     125a <read_metdata+0xda>
test   %ebx,%ebx
jle    1220 <read_metdata+0xa0>
mov    (%rsp),%r13
mov    %r15,%rbx
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1240 <read_metdata+0xc0>
jmp    1220 <read_metdata+0xa0>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd9a(%rip),%rdi
lea    0x50(%rsp),%rsi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"data_%.4f_%.4f\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"
@.str.4 = [3 x i8] c"%f\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]
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
%16 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%20 = load float, float* %8
%21 = load float, float* %9
%22 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), float %20, float %21)
%23 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %29, i32** %11
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %35
31: ; preds = %5
%32 = getelementptr inbounds [400 x i8], [400 x i8]* %15, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %5
store i32 0, i32* %12
br label %36
36: ; preds = %58, %35
%37 = load i32, i32* %12
%38 = icmp slt i32 %37, 10957
br i1 %38, label %39, label %61
39: ; preds = %36
store i32 0, i32* %13
br label %40
40: ; preds = %54, %39
%41 = load i32, i32* %13
%42 = load i32, i32* %10
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %57
44: ; preds = %40
%45 = load i32*, i32** %11
%46 = load [6 x float]*, [6 x float]** %7
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [6 x float], [6 x float]* %46, i64 %48
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [6 x float], [6 x float]* %49, i64 0, i64 %51
%53 = call i32 @fscanf(i32* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %52)
br label %54
54: ; preds = %44
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %40
57: ; preds = %40
br label %58
58: ; preds = %57
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 1
store i32 %60, i32* %12
br label %36
61: ; preds = %36
%62 = load i32*, i32** %11
%63 = call i32 @fclose(i32* %62)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"data_%.4f_%.4f\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"
@.str.4 = [3 x i8] c"%f\00"
define void @read_metdata(i8* %0, [6 x float]* %1, float %2, float %3, i32 %4) {
%6 = alloca [50 x i8]
%7 = alloca [400 x i8]
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* %0)
%11 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), float %2, float %3)
%12 = call i32 @strcat(i8* %9, i8* %8)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%14 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %5
%17 = icmp sgt i32 %4, 0
%18 = zext i32 %4 to i64
br label %22
19: ; preds = %5
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %16, %30
%23 = phi i64 [ 0, %16 ], [ %31, %30 ]
br i1 %17, label %24, label %30
24: ; preds = %22, %24
%25 = phi i64 [ %28, %24 ], [ 0, %22 ]
%26 = getelementptr inbounds [6 x float], [6 x float]* %1, i64 %23, i64 %25
%27 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %26)
%28 = add nuw nsw i64 %25, 1
%29 = icmp eq i64 %28, %18
br i1 %29, label %30, label %24
30: ; preds = %24, %22
%31 = add nuw nsw i64 %23, 1
%32 = icmp eq i64 %31, 10957
br i1 %32, label %33, label %22
33: ; preds = %30
%34 = call i32 @fclose(i32* %14)
ret void
}