#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*/ **);
int /*<<< orphan*/ *OpenFile(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ monthlyClimate(double, double, int, int, char *, char *,
                                  double *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void writeMonthlyClimate(double latitude, double longitude, int yearLow,
                         int yearHigh, char *site, char *directory) {
  double monthlyValues[36];
  monthlyClimate(latitude, longitude, yearLow, yearHigh, site, directory,
                 monthlyValues);
  char outFileName[4096];
  sprintf(outFileName, "%s//mc.csv", directory);
  FILE *outFile = OpenFile(outFileName, "w");
  fprintf(outFile, "Month,Cloud_Cover,Rel_Humidity,Surface_Wind\n");
  int i;
  for (i = 0; i < 12; i++)
    fprintf(outFile, "%d,%5.1f,%5.1f,%5.1f\n", (i + 1), monthlyValues[i],
            monthlyValues[i + 12], monthlyValues[i + 24]);
  CloseFile(&outFile);
}


x86 assembly (clang, -O0):
<writeMonthlyClimate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1160,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x150(%rbp),%r8
call   1050 <monthlyClimate@plt>
lea    -0x1150(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe57(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x1150(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x1158(%rbp)
mov    -0x1158(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x115c(%rbp)
cmpl   $0xc,-0x115c(%rbp)
jge    125e <writeMonthlyClimate+0x10e>
mov    -0x1158(%rbp),%rdi
mov    -0x115c(%rbp),%edx
add    $0x1,%edx
movslq -0x115c(%rbp),%rax
movsd  -0x150(%rbp,%rax,8),%xmm0
ff ff
mov    -0x115c(%rbp),%eax
add    $0xc,%eax
cltq
movsd  -0x150(%rbp,%rax,8),%xmm1
ff ff
mov    -0x115c(%rbp),%eax
add    $0x18,%eax
cltq
movsd  -0x150(%rbp,%rax,8),%xmm2
ff ff
lea    0xdf7(%rip),%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    -0x115c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x115c(%rbp)
jmp    11e7 <writeMonthlyClimate+0x97>
lea    -0x1158(%rbp),%rdi
call   1030 <CloseFile@plt>
add    $0x1160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeMonthlyClimate>:
push   %r14
push   %rbx
sub    $0x1138,%rsp
mov    %rcx,%rbx
lea    0x10(%rsp),%r8
call   1050 <monthlyClimate@plt>
lea    0xe82(%rip),%rsi
lea    0x130(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
lea    0xe73(%rip),%rsi
mov    %r14,%rdi
call   1040 <OpenFile@plt>
mov    %rax,0x8(%rsp)
lea    0xe61(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    0x8(%rsp),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0xd0(%rsp),%xmm2
lea    0xe5b(%rip),%rbx
mov    %rbx,%rsi
mov    $0x1,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
movsd  0xd8(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x2,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x20(%rsp),%xmm0
movsd  0x80(%rsp),%xmm1
movsd  0xe0(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x3,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x28(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
movsd  0xe8(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x30(%rsp),%xmm0
movsd  0x90(%rsp),%xmm1
movsd  0xf0(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x5,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x38(%rsp),%xmm0
movsd  0x98(%rsp),%xmm1
movsd  0xf8(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x6,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x40(%rsp),%xmm0
movsd  0xa0(%rsp),%xmm1
movsd  0x100(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x7,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x48(%rsp),%xmm0
movsd  0xa8(%rsp),%xmm1
movsd  0x108(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x50(%rsp),%xmm0
movsd  0xb0(%rsp),%xmm1
movsd  0x110(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0x9,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x58(%rsp),%xmm0
movsd  0xb8(%rsp),%xmm1
movsd  0x118(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x60(%rsp),%xmm0
movsd  0xc0(%rsp),%xmm1
movsd  0x120(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0xb,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    0x8(%rsp),%rdi
movsd  0x68(%rsp),%xmm0
movsd  0xc8(%rsp),%xmm1
movsd  0x128(%rsp),%xmm2
mov    %rbx,%rsi
mov    $0xc,%edx
mov    $0x3,%al
call   1060 <fprintf@plt>
lea    0x8(%rsp),%rdi
call   1030 <CloseFile@plt>
add    $0x1138,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s//mc.csv\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [45 x i8] c"Month,Cloud_Cover,Rel_Humidity,Surface_Wind\0A\00"
@.str.3 = [22 x i8] c"%d,%5.1f,%5.1f,%5.1f\0A\00"
define void @writeMonthlyClimate(double %0, double %1, i32 %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [36 x double]
%14 = alloca [4096 x i8]
%15 = alloca i32*
%16 = alloca i32
store double %0, double* %7
store double %1, double* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%17 = load double, double* %7
%18 = load double, double* %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i8*, i8** %11
%22 = load i8*, i8** %12
%23 = getelementptr inbounds [36 x double], [36 x double]* %13, i64 0, i64 0
%24 = call i32 @monthlyClimate(double %17, double %18, i32 %19, i32 %20, i8* %21, i8* %22, double* %23)
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%26 = load i8*, i8** %12
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%29 = call i32* @OpenFile(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %15
%30 = load i32*, i32** %15
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %16
br label %32
32: ; preds = %54, %6
%33 = load i32, i32* %16
%34 = icmp slt i32 %33, 12
br i1 %34, label %35, label %57
35: ; preds = %32
%36 = load i32*, i32** %15
%37 = load i32, i32* %16
%38 = add nsw i32 %37, 1
%39 = load i32, i32* %16
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [36 x double], [36 x double]* %13, i64 0, i64 %40
%42 = load double, double* %41
%43 = load i32, i32* %16
%44 = add nsw i32 %43, 12
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [36 x double], [36 x double]* %13, i64 0, i64 %45
%47 = load double, double* %46
%48 = load i32, i32* %16
%49 = add nsw i32 %48, 24
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [36 x double], [36 x double]* %13, i64 0, i64 %50
%52 = load double, double* %51
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %38, double %42, double %47, double %52)
br label %54
54: ; preds = %35
%55 = load i32, i32* %16
%56 = add nsw i32 %55, 1
store i32 %56, i32* %16
br label %32
57: ; preds = %32
%58 = call i32 @CloseFile(i32** %15)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s//mc.csv\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [45 x i8] c"Month,Cloud_Cover,Rel_Humidity,Surface_Wind\0A\00"
@.str.3 = [22 x i8] c"%d,%5.1f,%5.1f,%5.1f\0A\00"
define void @writeMonthlyClimate(double %0, double %1, i32 %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca [36 x double]
%8 = alloca [4096 x i8]
%9 = alloca i32*
%10 = bitcast [36 x double]* %7 to i8*
%11 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 0
%12 = call i32 @monthlyClimate(double %0, double %1, i32 %2, i32 %3, i8* %4, i8* %5, double* %11)
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%14 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5)
%15 = bitcast i32** %9 to i8*
%16 = call i32* @OpenFile(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %9
%17 = call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i64 44, i64 1, i32* %16)
%18 = load i32*, i32** %9
%19 = load double, double* %11
%20 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 12
%21 = load double, double* %20
%22 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 24
%23 = load double, double* %22
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 1, double %19, double %21, double %23)
%25 = load i32*, i32** %9
%26 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 13
%29 = load double, double* %28
%30 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 25
%31 = load double, double* %30
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 2, double %27, double %29, double %31)
%33 = load i32*, i32** %9
%34 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 2
%35 = load double, double* %34
%36 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 14
%37 = load double, double* %36
%38 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 26
%39 = load double, double* %38
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 3, double %35, double %37, double %39)
%41 = load i32*, i32** %9
%42 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 3
%43 = load double, double* %42
%44 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 15
%45 = load double, double* %44
%46 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 27
%47 = load double, double* %46
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 4, double %43, double %45, double %47)
%49 = load i32*, i32** %9
%50 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 4
%51 = load double, double* %50
%52 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 16
%53 = load double, double* %52
%54 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 28
%55 = load double, double* %54
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 5, double %51, double %53, double %55)
%57 = load i32*, i32** %9
%58 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 5
%59 = load double, double* %58
%60 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 17
%61 = load double, double* %60
%62 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 29
%63 = load double, double* %62
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 6, double %59, double %61, double %63)
%65 = load i32*, i32** %9
%66 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 6
%67 = load double, double* %66
%68 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 18
%69 = load double, double* %68
%70 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 30
%71 = load double, double* %70
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 7, double %67, double %69, double %71)
%73 = load i32*, i32** %9
%74 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 7
%75 = load double, double* %74
%76 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 19
%77 = load double, double* %76
%78 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 31
%79 = load double, double* %78
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 8, double %75, double %77, double %79)
%81 = load i32*, i32** %9
%82 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 8
%83 = load double, double* %82
%84 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 20
%85 = load double, double* %84
%86 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 32
%87 = load double, double* %86
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 9, double %83, double %85, double %87)
%89 = load i32*, i32** %9
%90 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 9
%91 = load double, double* %90
%92 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 21
%93 = load double, double* %92
%94 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 33
%95 = load double, double* %94
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 10, double %91, double %93, double %95)
%97 = load i32*, i32** %9
%98 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 10
%99 = load double, double* %98
%100 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 22
%101 = load double, double* %100
%102 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 34
%103 = load double, double* %102
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 11, double %99, double %101, double %103)
%105 = load i32*, i32** %9
%106 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 11
%107 = load double, double* %106
%108 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 23
%109 = load double, double* %108
%110 = getelementptr inbounds [36 x double], [36 x double]* %7, i64 0, i64 35
%111 = load double, double* %110
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 12, double %107, double %109, double %111)
%113 = call i32 @CloseFile(i32** %9)
ret void
}