#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*/ fclose(int /*<<< orphan*/ *);
double fittedSunriseTime(int, int, int /*<<< orphan*/);
double fittedSunsetTime(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double, double,
                           double, double, double, double, double, double);
int /*<<< orphan*/ printf(char *, char const *const);
double sunriseTime(int, int, int /*<<< orphan*/);
double sunsetTime(int, int, int /*<<< orphan*/);
int writeSunriseSunsetTable(const char *const filename) {
  FILE *fd = fopen(filename, "wt");
  if (!fd) {
    printf("Unable to open %s for writing.\n", filename);
    return 1;
  }
  printf("Writing table to %s...\n", filename);
  for (int day = 0; day < 36525; day++) {
    double sunriseTimes[] = {sunriseTime(day, 55, 0),
                             fittedSunriseTime(day, 55, 0),
                             sunriseTime(day, 60, 0), sunriseTime(day, 50, 0)};
    double sunsetTimes[] = {sunsetTime(day, 55, 0),
                            fittedSunsetTime(day, 55, 0),
                            sunsetTime(day, 60, 0), sunsetTime(day, 50, 0)};
    fprintf(fd,
            "%d"
            "\t%.8e\t%.8e"
            "\t%.8e\t%.8e"
            "\t%.8e\t%.8e"
            "\t%.8e\t%.8e"
            "\n",
            day, sunriseTimes[0], sunsetTimes[0], sunriseTimes[1],
            sunsetTimes[1], sunriseTimes[2], sunsetTimes[2], sunriseTimes[3],
            sunsetTimes[3]);
  }
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<writeSunriseSunsetTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c7 <writeSunriseSunsetTable+0x47>
mov    -0x10(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e4 <writeSunriseSunsetTable+0x164>
mov    -0x10(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8ead,-0x1c(%rbp)
jge    12d4 <writeSunriseSunsetTable+0x154>
mov    -0x1c(%rbp),%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1040 <fittedSunriseTime@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x3c,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x32,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1050 <fittedSunsetTime@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x3c,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x32,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
movsd  -0x40(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm5
movsd  -0x28(%rbp),%xmm6
movsd  -0x48(%rbp),%xmm7
lea    0xd7a(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11de <writeSunriseSunsetTable+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeSunriseSunsetTable>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbp
lea    0xe6e(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12af <writeSunriseSunsetTable+0x12f>
mov    %rax,%rbx
lea    0xe79(%rip),%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
xor    %ebp,%ebp
lea    0xe80(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,0x38(%rsp)
mov    %ebp,%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1040 <fittedSunriseTime@plt>
movsd  %xmm0,0x30(%rsp)
mov    %ebp,%edi
mov    $0x3c,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,0x28(%rsp)
mov    %ebp,%edi
mov    $0x32,%esi
xor    %edx,%edx
call   1060 <sunriseTime@plt>
movsd  %xmm0,0x20(%rsp)
mov    %ebp,%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
mov    $0x37,%esi
xor    %edx,%edx
call   1050 <fittedSunsetTime@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    $0x3c,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    $0x32,%esi
xor    %edx,%edx
call   1090 <sunsetTime@plt>
movaps %xmm0,%xmm7
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
movsd  0x38(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
movsd  0x8(%rsp),%xmm5
movsd  0x20(%rsp),%xmm6
call   1080 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x8ead,%ebp
jne    11c0 <writeSunriseSunsetTable+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12c3 <writeSunriseSunsetTable+0x143>
lea    0xd4d(%rip),%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [32 x i8] c"Unable to open %s for writing.\0A\00"
@.str.2 = [24 x i8] c"Writing table to %s...\0A\00"
@.str.3 = [44 x i8] c"%d\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\0A\00"
define i32 @writeSunriseSunsetTable(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [4 x double]
%7 = alloca [4 x double]
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp ne i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 1, i32* %2
br label %71
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %16)
store i32 0, i32* %5
br label %18
18: ; preds = %65, %15
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 36525
br i1 %20, label %21, label %68
21: ; preds = %18
%22 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call double @sunriseTime(i32 %23, i32 55, i32 0)
store double %24, double* %22
%25 = getelementptr inbounds double, double* %22, i64 1
%26 = load i32, i32* %5
%27 = call double @fittedSunriseTime(i32 %26, i32 55, i32 0)
store double %27, double* %25
%28 = getelementptr inbounds double, double* %25, i64 1
%29 = load i32, i32* %5
%30 = call double @sunriseTime(i32 %29, i32 60, i32 0)
store double %30, double* %28
%31 = getelementptr inbounds double, double* %28, i64 1
%32 = load i32, i32* %5
%33 = call double @sunriseTime(i32 %32, i32 50, i32 0)
store double %33, double* %31
%34 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%35 = load i32, i32* %5
%36 = call double @sunsetTime(i32 %35, i32 55, i32 0)
store double %36, double* %34
%37 = getelementptr inbounds double, double* %34, i64 1
%38 = load i32, i32* %5
%39 = call double @fittedSunsetTime(i32 %38, i32 55, i32 0)
store double %39, double* %37
%40 = getelementptr inbounds double, double* %37, i64 1
%41 = load i32, i32* %5
%42 = call double @sunsetTime(i32 %41, i32 60, i32 0)
store double %42, double* %40
%43 = getelementptr inbounds double, double* %40, i64 1
%44 = load i32, i32* %5
%45 = call double @sunsetTime(i32 %44, i32 50, i32 0)
store double %45, double* %43
%46 = load i32*, i32** %4
%47 = load i32, i32* %5
%48 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%49 = load double, double* %48
%50 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%51 = load double, double* %50
%52 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
%53 = load double, double* %52
%54 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 1
%55 = load double, double* %54
%56 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
%57 = load double, double* %56
%58 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 2
%59 = load double, double* %58
%60 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
%61 = load double, double* %60
%62 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 3
%63 = load double, double* %62
%64 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %47, double %49, double %51, double %53, double %55, double %57, double %59, double %61, double %63)
br label %65
65: ; preds = %21
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %18
68: ; preds = %18
%69 = load i32*, i32** %4
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %2
br label %71
71: ; preds = %68, %12
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [32 x i8] c"Unable to open %s for writing.\0A\00"
@.str.2 = [24 x i8] c"Writing table to %s...\0A\00"
@.str.3 = [44 x i8] c"%d\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\09%.8e\0A\00"
define i32 @writeSunriseSunsetTable(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %23
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %10
8: ; preds = %10
%9 = tail call i32 @fclose(i32* %2)
br label %23
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %21, %10 ]
%12 = tail call double @sunriseTime(i32 %11, i32 55, i32 0)
%13 = tail call double @fittedSunriseTime(i32 %11, i32 55, i32 0)
%14 = tail call double @sunriseTime(i32 %11, i32 60, i32 0)
%15 = tail call double @sunriseTime(i32 %11, i32 50, i32 0)
%16 = tail call double @sunsetTime(i32 %11, i32 55, i32 0)
%17 = tail call double @fittedSunsetTime(i32 %11, i32 55, i32 0)
%18 = tail call double @sunsetTime(i32 %11, i32 60, i32 0)
%19 = tail call double @sunsetTime(i32 %11, i32 50, i32 0)
%20 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %11, double %12, double %16, double %13, double %17, double %14, double %18, double %15, double %19)
%21 = add nuw nsw i32 %11, 1
%22 = icmp eq i32 %21, 36525
br i1 %22, label %8, label %10
23: ; preds = %8, %4
%24 = phi i32 [ 0, %8 ], [ 1, %4 ]
ret i32 %24
}