#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*/ CloseFile(int /*<<< orphan*/ **);
scalar_t__ GetALine(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *OpenFile(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
double kelvinToCelsius(double);
double kgToCM(double);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, double *);
void dailyWeather2Write(int nSites, char *siteNames[], char *siteDirs[],
                        int year) {
  char temp[4096], tempMo[5];
  double tmax, tmin, ppt;
  FILE *siteFiles[nSites];
  int i, j = 0, mo;
  for (i = 0; i < nSites; i++) {
    sprintf(temp, "%s//%s.%d", siteDirs[i], "weath", year);
    siteFiles[i] = OpenFile(temp, "w");
    fprintf(siteFiles[i], "# weather for site %s year = %d\n", siteNames[i],
            year);
    fprintf(siteFiles[i], "# DOY Tmax(C) Tmin(C) PPT(cm)\n");
  }
  for (mo = 1; mo < 13; mo++) {
    if (mo < 10)
      sprintf(tempMo, "0%d", mo);
    else
      sprintf(tempMo, "%d", mo);
    sprintf(temp, "temporary_dy//tmax//tmax_%d%s.txt", year, tempMo);
    FILE *tmaxFile = OpenFile(temp, "r");
    sprintf(temp, "temporary_dy//tmin//tmin_%d%s.txt", year, tempMo);
    FILE *tminFile = OpenFile(temp, "r");
    sprintf(temp, "temporary_dy//ppt//ppt_%d%s.txt", year, tempMo);
    FILE *pptFile = OpenFile(temp, "r");
    i = 0;
    while (GetALine(tmaxFile, temp)) {
      tmax = tmin = ppt = 0.0;
      sscanf(temp, ",val=%lf", &tmax);
      GetALine(tminFile, temp);
      sscanf(temp, ",val=%lf", &tmin);
      GetALine(pptFile, temp);
      sscanf(temp, ",val=%lf", &ppt);
      fprintf(siteFiles[i], "%d\t%5.2f\t%5.2f\t%5.2f\n", j + 1,
              kelvinToCelsius(tmax), kelvinToCelsius(tmin),
              kgToCM((ppt / 4.0)));
      i++;
      if (i >= nSites) {
        i = 0;
        j++;
      }
    }
    CloseFile(&tmaxFile);
    CloseFile(&tminFile);
    CloseFile(&pptFile);
  }
  for (i = 0; i < nSites; i++)
    CloseFile(&siteFiles[i]);
}


x86 assembly (clang, -O0):
<dailyWeather2Write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x1048(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1080(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x1050(%rbp)
movl   $0x0,-0x1058(%rbp)
movl   $0x0,-0x1054(%rbp)
mov    -0x1054(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a2 <dailyWeather2Write+0x122>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1054(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x1c(%rbp),%r8d
lea    0xdfb(%rip),%rsi
lea    0xdfe(%rip),%rcx
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,%rdx
mov    -0x1080(%rbp),%rax
movslq -0x1054(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x1054(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1054(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1080(%rbp),%rax
movslq -0x1054(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1054(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1054(%rbp)
jmp    11dd <dailyWeather2Write+0x5d>
movl   $0x1,-0x105c(%rbp)
cmpl   $0xd,-0x105c(%rbp)
jge    1575 <dailyWeather2Write+0x3f5>
cmpl   $0xa,-0x105c(%rbp)
jge    12e6 <dailyWeather2Write+0x166>
lea    -0x1025(%rbp),%rdi
mov    -0x105c(%rbp),%edx
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    1301 <dailyWeather2Write+0x181>
lea    -0x1025(%rbp),%rdi
mov    -0x105c(%rbp),%edx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x1025(%rbp),%rcx
lea    0xd45(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xd52(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x1068(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x1025(%rbp),%rcx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x1070(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    -0x1025(%rbp),%rcx
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x1078(%rbp)
movl   $0x0,-0x1054(%rbp)
mov    -0x1068(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1080 <GetALine@plt>
cmp    $0x0,%rax
je     153d <dailyWeather2Write+0x3bd>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1040(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1038(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1030(%rbp)
ff
lea    -0x1020(%rbp),%rdi
lea    0xcc2(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x1070(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1080 <GetALine@plt>
lea    -0x1020(%rbp),%rdi
lea    0xc95(%rip),%rsi
lea    -0x1038(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x1078(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1080 <GetALine@plt>
lea    -0x1020(%rbp),%rdi
lea    0xc68(%rip),%rsi
lea    -0x1040(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x1080(%rbp),%rax
movslq -0x1054(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10a0(%rbp)
mov    -0x1058(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1094(%rbp)
movsd  -0x1030(%rbp),%xmm0
ff
call   1050 <kelvinToCelsius@plt>
movsd  %xmm0,-0x1088(%rbp)
ff
movsd  -0x1038(%rbp),%xmm0
ff
call   1050 <kelvinToCelsius@plt>
movsd  %xmm0,-0x1090(%rbp)
ff
movsd  -0x1040(%rbp),%xmm0
ff
movsd  0xb36(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <kgToCM@plt>
mov    -0x10a0(%rbp),%rdi
mov    -0x1094(%rbp),%edx
movsd  -0x1090(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x1088(%rbp),%xmm0
ff
lea    0xbd3(%rip),%rsi
mov    $0x3,%al
call   1070 <fprintf@plt>
mov    -0x1054(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1054(%rbp)
mov    -0x1054(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1538 <dailyWeather2Write+0x3b8>
movl   $0x0,-0x1054(%rbp)
mov    -0x1058(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1058(%rbp)
jmp    13b6 <dailyWeather2Write+0x236>
lea    -0x1068(%rbp),%rdi
call   1030 <CloseFile@plt>
lea    -0x1070(%rbp),%rdi
call   1030 <CloseFile@plt>
lea    -0x1078(%rbp),%rdi
call   1030 <CloseFile@plt>
mov    -0x105c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105c(%rbp)
jmp    12ac <dailyWeather2Write+0x12c>
movl   $0x0,-0x1054(%rbp)
mov    -0x1054(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    15bc <dailyWeather2Write+0x43c>
mov    -0x1080(%rbp),%rdi
movslq -0x1054(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1030 <CloseFile@plt>
mov    -0x1054(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1054(%rbp)
jmp    157f <dailyWeather2Write+0x3ff>
mov    -0x1048(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dailyWeather2Write>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1078,%rsp
mov    %ecx,%r14d
mov    %rsi,-0x38(%rbp)
mov    %rsp,-0x88(%rbp)
mov    %edi,%ecx
mov    %rsp,%r13
lea    0xf(,%rcx,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %edi,-0x2c(%rbp)
test   %edi,%edi
mov    %rcx,-0x50(%rbp)
jle    125e <dailyWeather2Write+0xce>
mov    %rdx,%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,8),%rdx
lea    -0x10a0(%rbp),%r12
mov    %r12,%rdi
lea    0xe13(%rip),%rsi
lea    0xe16(%rip),%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r12,%rdi
lea    0xe08(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,0x0(%r13,%rbx,8)
mov    -0x38(%rbp),%rcx
mov    (%rcx,%rbx,8),%rdx
mov    %rax,%rdi
lea    0xdee(%rip),%rsi
mov    %r14d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13,%rbx,8),%rcx
mov    $0x1e,%esi
mov    $0x1,%edx
lea    0xdef(%rip),%rdi
call   10b0 <fwrite@plt>
mov    -0x50(%rbp),%rcx
add    $0x1,%rbx
cmp    %rbx,%rcx
jne    11e0 <dailyWeather2Write+0x50>
mov    %r14d,-0x44(%rbp)
mov    %r13,-0x58(%rbp)
mov    $0x1,%edx
lea    -0x10a0(%rbp),%rbx
xor    %r13d,%r13d
mov    -0x2c(%rbp),%r15d
jmp    12b0 <dailyWeather2Write+0x120>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%r12d
lea    -0x40(%rbp),%rdi
call   1030 <CloseFile@plt>
lea    -0x68(%rbp),%rdi
call   1030 <CloseFile@plt>
lea    -0x60(%rbp),%rdi
call   1030 <CloseFile@plt>
mov    -0x48(%rbp),%edx
add    $0x1,%edx
mov    %r12d,%r13d
cmp    $0xd,%edx
je     1486 <dailyWeather2Write+0x2f6>
cmp    $0xa,%edx
lea    0xd55(%rip),%rsi
lea    0xd99(%rip),%rax
cmovb  %rax,%rsi
lea    -0x95(%rbp),%r12
mov    %r12,%rdi
mov    %edx,-0x48(%rbp)
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd7b(%rip),%rsi
mov    -0x44(%rbp),%r14d
mov    %r14d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd82(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x40(%rbp)
mov    %rbx,%rdi
lea    0xd71(%rip),%rsi
mov    %r14d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd58(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x68(%rbp)
mov    %rbx,%rdi
lea    0xd69(%rip),%rsi
mov    %r14d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd2e(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
mov    %rbx,%rsi
call   1080 <GetALine@plt>
test   %rax,%rax
je     1280 <dailyWeather2Write+0xf0>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
mov    %rbx,%rdi
mov    %rbx,%r15
lea    0xd1f(%rip),%rbx
mov    %rbx,%rsi
lea    -0x80(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x68(%rbp),%rdi
mov    %r15,%rsi
call   1080 <GetALine@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
lea    -0x78(%rbp),%rdx
call   1090 <sscanf@plt>
mov    -0x60(%rbp),%rdi
mov    %r15,%rsi
call   1080 <GetALine@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r15,%rbx
lea    -0x70(%rbp),%rdx
call   1090 <sscanf@plt>
movslq %r14d,%r14
mov    -0x58(%rbp),%rax
mov    (%rax,%r14,8),%r15
lea    0x1(%r13),%r12d
movsd  -0x80(%rbp),%xmm0
call   1050 <kelvinToCelsius@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1050 <kelvinToCelsius@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
mulsd  0xbd9(%rip),%xmm0
call   1060 <kgToCM@plt>
movapd %xmm0,%xmm2
mov    %r15,%rdi
mov    -0x2c(%rbp),%r15d
lea    0xc8f(%rip),%rsi
mov    %r12d,%edx
movsd  -0x38(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm1
ff
mov    $0x3,%al
call   1070 <fprintf@plt>
add    $0x1,%r14d
cmp    %r15d,%r14d
mov    $0x0,%eax
cmovge %eax,%r14d
cmovl  %r13d,%r12d
mov    -0x40(%rbp),%rdi
mov    %rbx,%rsi
call   1080 <GetALine@plt>
mov    %r12d,%r13d
test   %rax,%rax
jne    1380 <dailyWeather2Write+0x1f0>
jmp    1283 <dailyWeather2Write+0xf3>
test   %r15d,%r15d
mov    -0x50(%rbp),%r14
mov    -0x58(%rbp),%rbx
jle    14b2 <dailyWeather2Write+0x322>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <CloseFile@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%r14
jne    14a0 <dailyWeather2Write+0x310>
mov    -0x88(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s//%s.%d\00"
@.str.1 = [6 x i8] c"weath\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [33 x i8] c"# weather for site %s year = %d\0A\00"
@.str.4 = [31 x i8] c"# DOY Tmax(C) Tmin(C) PPT(cm)\0A\00"
@.str.5 = [4 x i8] c"0%d\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [34 x i8] c"temporary_dy//tmax//tmax_%d%s.txt\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [34 x i8] c"temporary_dy//tmin//tmin_%d%s.txt\00"
@.str.10 = [32 x i8] c"temporary_dy//ppt//ppt_%d%s.txt\00"
@.str.11 = [9 x i8] c",val=%lf\00"
@.str.12 = [22 x i8] c"%d\09%5.2f\09%5.2f\09%5.2f\0A\00"
define void @dailyWeather2Write(i32 %0, i8** %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca [5 x i8]
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%22 = load i32, i32* %5
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %14
%25 = alloca i32*, i64 %23
store i64 %23, i64* %15
store i32 0, i32* %17
store i32 0, i32* %16
br label %26
26: ; preds = %60, %4
%27 = load i32, i32* %16
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %63
30: ; preds = %26
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%32 = load i8**, i8*** %7
%33 = load i32, i32* %16
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = load i32, i32* %8
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%40 = call i32* @OpenFile(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* %16
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32*, i32** %25, i64 %42
store i32* %40, i32** %43
%44 = load i32, i32* %16
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32*, i32** %25, i64 %45
%47 = load i32*, i32** %46
%48 = load i8**, i8*** %6
%49 = load i32, i32* %16
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = load i32, i32* %8
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %52, i32 %53)
%55 = load i32, i32* %16
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32*, i32** %25, i64 %56
%58 = load i32*, i32** %57
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %30
%61 = load i32, i32* %16
%62 = add nsw i32 %61, 1
store i32 %62, i32* %16
br label %26
63: ; preds = %26
store i32 1, i32* %18
br label %64
64: ; preds = %142, %63
%65 = load i32, i32* %18
%66 = icmp slt i32 %65, 13
br i1 %66, label %67, label %145
67: ; preds = %64
%68 = load i32, i32* %18
%69 = icmp slt i32 %68, 10
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%72 = load i32, i32* %18
%73 = call i32 (i8*, i8*, ...) @sprintf(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %72)
br label %78
74: ; preds = %67
%75 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%76 = load i32, i32* %18
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %74, %70
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%80 = load i32, i32* %8
%81 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%82 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %80, i8* %81)
%83 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%84 = call i32* @OpenFile(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %84, i32** %19
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%86 = load i32, i32* %8
%87 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%88 = call i32 (i8*, i8*, ...) @sprintf(i8* %85, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %86, i8* %87)
%89 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%90 = call i32* @OpenFile(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %90, i32** %20
%91 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%92 = load i32, i32* %8
%93 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %91, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %92, i8* %93)
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%96 = call i32* @OpenFile(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %96, i32** %21
store i32 0, i32* %16
br label %97
97: ; preds = %137, %78
%98 = load i32*, i32** %19
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%100 = call i64 @GetALine(i32* %98, i8* %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %138
102: ; preds = %97
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %11
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%104 = call i32 @sscanf(i8* %103, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %11)
%105 = load i32*, i32** %20
%106 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%107 = call i64 @GetALine(i32* %105, i8* %106)
%108 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%109 = call i32 @sscanf(i8* %108, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %12)
%110 = load i32*, i32** %21
%111 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%112 = call i64 @GetALine(i32* %110, i8* %111)
%113 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%114 = call i32 @sscanf(i8* %113, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %13)
%115 = load i32, i32* %16
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32*, i32** %25, i64 %116
%118 = load i32*, i32** %117
%119 = load i32, i32* %17
%120 = add nsw i32 %119, 1
%121 = load double, double* %11
%122 = call double @kelvinToCelsius(double %121)
%123 = load double, double* %12
%124 = call double @kelvinToCelsius(double %123)
%125 = load double, double* %13
%126 = fdiv double %125, 4.000000e+00
%127 = call double @kgToCM(double %126)
%128 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %120, double %122, double %124, double %127)
%129 = load i32, i32* %16
%130 = add nsw i32 %129, 1
store i32 %130, i32* %16
%131 = load i32, i32* %16
%132 = load i32, i32* %5
%133 = icmp sge i32 %131, %132
br i1 %133, label %134, label %137
134: ; preds = %102
store i32 0, i32* %16
%135 = load i32, i32* %17
%136 = add nsw i32 %135, 1
store i32 %136, i32* %17
br label %137
137: ; preds = %134, %102
br label %97
138: ; preds = %97
%139 = call i32 @CloseFile(i32** %19)
%140 = call i32 @CloseFile(i32** %20)
%141 = call i32 @CloseFile(i32** %21)
br label %142
142: ; preds = %138
%143 = load i32, i32* %18
%144 = add nsw i32 %143, 1
store i32 %144, i32* %18
br label %64
145: ; preds = %64
store i32 0, i32* %16
br label %146
146: ; preds = %155, %145
%147 = load i32, i32* %16
%148 = load i32, i32* %5
%149 = icmp slt i32 %147, %148
br i1 %149, label %150, label %158
150: ; preds = %146
%151 = load i32, i32* %16
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i32*, i32** %25, i64 %152
%154 = call i32 @CloseFile(i32** %153)
br label %155
155: ; preds = %150
%156 = load i32, i32* %16
%157 = add nsw i32 %156, 1
store i32 %157, i32* %16
br label %146
158: ; preds = %146
%159 = load i8*, i8** %14
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s//%s.%d\00"
@.str.1 = [6 x i8] c"weath\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [33 x i8] c"# weather for site %s year = %d\0A\00"
@.str.4 = [31 x i8] c"# DOY Tmax(C) Tmin(C) PPT(cm)\0A\00"
@.str.5 = [4 x i8] c"0%d\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [34 x i8] c"temporary_dy//tmax//tmax_%d%s.txt\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [34 x i8] c"temporary_dy//tmin//tmin_%d%s.txt\00"
@.str.10 = [32 x i8] c"temporary_dy//ppt//ppt_%d%s.txt\00"
@.str.11 = [9 x i8] c",val=%lf\00"
@.str.12 = [22 x i8] c"%d\09%5.2f\09%5.2f\09%5.2f\0A\00"
define void @dailyWeather2Write(i32 %0, i8** nocapture %1, i8** nocapture %2, i32 %3) {
%5 = alloca [4096 x i8]
%6 = alloca [5 x i8]
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%15 = bitcast double* %7 to i8*
%16 = bitcast double* %8 to i8*
%17 = bitcast double* %9 to i8*
%18 = zext i32 %0 to i64
%19 = tail call i8* @llvm.stacksave()
%20 = alloca i32*, i64 %18
%21 = icmp sgt i32 %0, 0
br i1 %21, label %26, label %22
22: ; preds = %26, %4
%23 = bitcast i32** %10 to i8*
%24 = bitcast i32** %11 to i8*
%25 = bitcast i32** %12 to i8*
br label %41
26: ; preds = %4, %26
%27 = phi i64 [ %38, %26 ], [ 0, %4 ]
%28 = getelementptr inbounds i8*, i8** %2, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%31 = call i32* @OpenFile(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds i32*, i32** %20, i64 %27
store i32* %31, i32** %32
%33 = getelementptr inbounds i8*, i8** %1, i64 %27
%34 = load i8*, i8** %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %34, i32 %3)
%36 = load i32*, i32** %32
%37 = call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64 30, i64 1, i32* %36)
%38 = add nuw nsw i64 %27, 1
%39 = icmp eq i64 %38, %18
br i1 %39, label %22, label %26
40: ; preds = %85
br i1 %21, label %92, label %98
41: ; preds = %22, %85
%42 = phi i32 [ 1, %22 ], [ %90, %85 ]
%43 = phi i32 [ 0, %22 ], [ %86, %85 ]
%44 = icmp ult i32 %42, 10
%45 = select i1 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0)
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) %45, i32 %42)
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %3, i8* %14)
%48 = call i32* @OpenFile(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %48, i32** %10
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %3, i8* %14)
%50 = call i32* @OpenFile(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %50, i32** %11
%51 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %3, i8* %14)
%52 = call i32* @OpenFile(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %52, i32** %12
%53 = load i32*, i32** %10
%54 = call i64 @GetALine(i32* %53, i8* %13)
%55 = icmp eq i64 %54, 0
br i1 %55, label %85, label %56
56: ; preds = %41, %56
%57 = phi i32 [ %81, %56 ], [ %43, %41 ]
%58 = phi i32 [ %80, %56 ], [ 0, %41 ]
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %7
%59 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %7)
%60 = load i32*, i32** %11
%61 = call i64 @GetALine(i32* %60, i8* %13)
%62 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %8)
%63 = load i32*, i32** %12
%64 = call i64 @GetALine(i32* %63, i8* %13)
%65 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), double* %9)
%66 = sext i32 %58 to i64
%67 = getelementptr inbounds i32*, i32** %20, i64 %66
%68 = load i32*, i32** %67
%69 = add nsw i32 %57, 1
%70 = load double, double* %7
%71 = call double @kelvinToCelsius(double %70)
%72 = load double, double* %8
%73 = call double @kelvinToCelsius(double %72)
%74 = load double, double* %9
%75 = fmul double %74, 2.500000e-01
%76 = call double @kgToCM(double %75)
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %69, double %71, double %73, double %76)
%78 = add nsw i32 %58, 1
%79 = icmp slt i32 %78, %0
%80 = select i1 %79, i32 %78, i32 0
%81 = select i1 %79, i32 %57, i32 %69
%82 = load i32*, i32** %10
%83 = call i64 @GetALine(i32* %82, i8* %13)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %56
85: ; preds = %56, %41
%86 = phi i32 [ %43, %41 ], [ %81, %56 ]
%87 = call i32 @CloseFile(i32** %10)
%88 = call i32 @CloseFile(i32** %11)
%89 = call i32 @CloseFile(i32** %12)
%90 = add nuw nsw i32 %42, 1
%91 = icmp eq i32 %90, 13
br i1 %91, label %40, label %41
92: ; preds = %40, %92
%93 = phi i64 [ %96, %92 ], [ 0, %40 ]
%94 = getelementptr inbounds i32*, i32** %20, i64 %93
%95 = call i32 @CloseFile(i32** %94)
%96 = add nuw nsw i64 %93, 1
%97 = icmp eq i64 %96, %18
br i1 %97, label %98, label %92
98: ; preds = %92, %40
ret void
}