#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, double, double);
double fittedSunsetTime(int, double, double);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double, double,
                           double, double);
int /*<<< orphan*/ printf(char *, char const *const);
double sunriseTime(int, double, double);
double sunsetTime(int, double, double);
int writeFittedSunriseSunsetTable(const char *const filename) {
  double latitude = 55.0;
  double longitude = 0.0;
  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 < 366; day++) {
    double fittedSunrise = fittedSunriseTime(day, latitude, longitude);
    double actualSunrise = sunriseTime(day, latitude, longitude);
    double fittedSunset = fittedSunsetTime(day, latitude, longitude);
    double actualSunset = sunsetTime(day, latitude, longitude);
    fprintf(fd,
            "%d"
            "\t%.8e\t%.8e"
            "\t%.8e\t%.8e"
            "\n",
            day, actualSunrise, fittedSunrise, actualSunset, fittedSunset);
  }
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<writeFittedSunriseSunsetTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11dc <writeFittedSunriseSunsetTable+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <writeFittedSunriseSunsetTable+0x121>
mov    -0x10(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x16e,-0x2c(%rbp)
jge    1291 <writeFittedSunriseSunsetTable+0x111>
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <fittedSunriseTime@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1060 <sunriseTime@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <fittedSunsetTime@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1090 <sunsetTime@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
lea    0xdc5(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f3 <writeFittedSunriseSunsetTable+0x73>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFittedSunriseSunsetTable>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbp
lea    0xe76(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1257 <writeFittedSunriseSunsetTable+0xd7>
mov    %rax,%rbx
lea    0xe81(%rip),%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
xor    %ebp,%ebp
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
mov    %ebp,%edi
movsd  0xe33(%rip),%xmm0
call   1040 <fittedSunriseTime@plt>
movsd  %xmm0,0x18(%rsp)
xorps  %xmm1,%xmm1
mov    %ebp,%edi
movsd  0xe1b(%rip),%xmm0
call   1060 <sunriseTime@plt>
movsd  %xmm0,0x10(%rsp)
xorps  %xmm1,%xmm1
mov    %ebp,%edi
movsd  0xe03(%rip),%xmm0
call   1050 <fittedSunsetTime@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
mov    %ebp,%edi
movsd  0xdeb(%rip),%xmm0
call   1090 <sunsetTime@plt>
movaps %xmm0,%xmm2
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
call   1080 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x16e,%ebp
jne    11c0 <writeFittedSunriseSunsetTable+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    126b <writeFittedSunriseSunsetTable+0xeb>
lea    0xdad(%rip),%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0x20,%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 = [24 x i8] c"%d\09%.8e\09%.8e\09%.8e\09%.8e\0A\00"
define i32 @writeFittedSunriseSunsetTable(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca double
%5 = alloca double
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i8* %0, i8** %3
store double 5.500000e+01, double* %4
store double 0.000000e+00, double* %5
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 1, i32* %2
br label %55
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 0, i32* %7
br label %22
22: ; preds = %49, %19
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 366
br i1 %24, label %25, label %52
25: ; preds = %22
%26 = load i32, i32* %7
%27 = load double, double* %4
%28 = load double, double* %5
%29 = call double @fittedSunriseTime(i32 %26, double %27, double %28)
store double %29, double* %8
%30 = load i32, i32* %7
%31 = load double, double* %4
%32 = load double, double* %5
%33 = call double @sunriseTime(i32 %30, double %31, double %32)
store double %33, double* %9
%34 = load i32, i32* %7
%35 = load double, double* %4
%36 = load double, double* %5
%37 = call double @fittedSunsetTime(i32 %34, double %35, double %36)
store double %37, double* %10
%38 = load i32, i32* %7
%39 = load double, double* %4
%40 = load double, double* %5
%41 = call double @sunsetTime(i32 %38, double %39, double %40)
store double %41, double* %11
%42 = load i32*, i32** %6
%43 = load i32, i32* %7
%44 = load double, double* %9
%45 = load double, double* %8
%46 = load double, double* %11
%47 = load double, double* %10
%48 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %43, double %44, double %45, double %46, double %47)
br label %49
49: ; preds = %25
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %22
52: ; preds = %22
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
store i32 0, i32* %2
br label %55
55: ; preds = %52, %16
%56 = load i32, i32* %2
ret i32 %56
}

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 = [24 x i8] c"%d\09%.8e\09%.8e\09%.8e\09%.8e\0A\00"
define i32 @writeFittedSunriseSunsetTable(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 %19
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 %19
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %17, %10 ]
%12 = tail call double @fittedSunriseTime(i32 %11, double 5.500000e+01, double 0.000000e+00)
%13 = tail call double @sunriseTime(i32 %11, double 5.500000e+01, double 0.000000e+00)
%14 = tail call double @fittedSunsetTime(i32 %11, double 5.500000e+01, double 0.000000e+00)
%15 = tail call double @sunsetTime(i32 %11, double 5.500000e+01, double 0.000000e+00)
%16 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %11, double %13, double %12, double %15, double %14)
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, 366
br i1 %18, label %8, label %10
19: ; preds = %8, %4
%20 = phi i32 [ 0, %8 ], [ 1, %4 ]
ret i32 %20
}