#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, ...);
void writeGridData(double X0, double XL, double Y0, double YL, double dx,
                   double dy, int nX, int nY, char *filename_GridData) {
  FILE *outputFile;
  outputFile = fopen(filename_GridData, "w");
  fprintf(outputFile,
          "# X - Y domain: Xstart Xend Ystart Yend : \ndomain %f %f %f %f\n",
          X0, XL, Y0, YL);
  fprintf(outputFile, "# step size dx, dy: \nstepsize %f %f\n", dx, dy);
  fprintf(outputFile,
          "# number of grid points in X and Y dimensions: \npoints %d %d\n", nX,
          nY);
  fclose(outputFile);
}


x86 assembly (clang, -O0):
<writeGridData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %edi,-0x34(%rbp)
mov    %esi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
cvttsd2si -0x8(%rbp),%edx
cvttsd2si -0x10(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe6f(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    -0x48(%rbp),%rdi
cvttsd2si -0x28(%rbp),%edx
cvttsd2si -0x30(%rbp),%ecx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeGridData>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
movsd  %xmm5,0x28(%rsp)
movsd  %xmm4,0x20(%rsp)
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
lea    0xe99(%rip),%rsi
mov    %rdx,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
cvttsd2si (%rsp),%edx
cvttsd2si 0x8(%rsp),%ecx
lea    0xe7e(%rip),%rsi
mov    %rax,%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    $0x2,%al
call   1040 <fprintf@plt>
cvttsd2si 0x20(%rsp),%edx
cvttsd2si 0x28(%rsp),%ecx
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [63 x i8] c"# X - Y domain: Xstart Xend Ystart Yend : \0Adomain %f %f %f %f\0A\00"
@.str.2 = [37 x i8] c"# step size dx, dy: \0Astepsize %f %f\0A\00"
@.str.3 = [62 x i8] c"# number of grid points in X and Y dimensions: \0Apoints %d %d\0A\00"
define void @writeGridData(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32 %7, i8* %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32*
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i8* %8, i8** %18
%20 = load i8*, i8** %18
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %19
%22 = load i32*, i32** %19
%23 = load double, double* %10
%24 = fptosi double %23 to i32
%25 = load double, double* %11
%26 = fptosi double %25 to i32
%27 = load double, double* %12
%28 = load double, double* %13
%29 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %26, double %27, double %28)
%30 = load i32*, i32** %19
%31 = load double, double* %14
%32 = fptosi double %31 to i32
%33 = load double, double* %15
%34 = fptosi double %33 to i32
%35 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %34)
%36 = load i32*, i32** %19
%37 = load i32, i32* %16
%38 = load i32, i32* %17
%39 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38)
%40 = load i32*, i32** %19
%41 = call i32 @fclose(i32* %40)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [63 x i8] c"# X - Y domain: Xstart Xend Ystart Yend : \0Adomain %f %f %f %f\0A\00"
@.str.2 = [37 x i8] c"# step size dx, dy: \0Astepsize %f %f\0A\00"
@.str.3 = [62 x i8] c"# number of grid points in X and Y dimensions: \0Apoints %d %d\0A\00"
define void @writeGridData(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32 %7, i8* nocapture %8) {
%10 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = fptosi double %0 to i32
%12 = fptosi double %1 to i32
%13 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, double %2, double %3)
%14 = fptosi double %4 to i32
%15 = fptosi double %5 to i32
%16 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15)
%17 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 %7)
%18 = tail call i32 @fclose(i32* %10)
ret void
}