#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 /*<<< orphan*/ fwrite(double *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main() {
  double a[10];
  int i;
  FILE *ofile = fopen("data.float64", "wb");
  for (i = 0; i < 10; i++) {
    a[i] = i;
  }
  fwrite(a, sizeof(double), 10, ofile);
  fclose(ofile);
  fprintf(stderr, "create_float64: done\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jge    1194 <main+0x54>
cvtsi2sdl -0x64(%rbp),%xmm0
movslq -0x64(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    116d <main+0x2d>
lea    -0x60(%rbp),%rdi
mov    -0x70(%rbp),%rcx
mov    $0x8,%esi
mov    $0xa,%edx
call   1060 <fwrite@plt>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xf04(%rip),%rdi
lea    0xf0a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
movhps 0xe9b(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0xa,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"data.float64\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"create_float64: done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x double]
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
store i32 0, i32* %3
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to double
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 %13
store double %11, double* %14
br label %15
15: ; preds = %9
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32 @fwrite(double* %19, i32 8, i32 10, i32* %20)
%22 = load i32*, i32** %4
%23 = call i32 @fclose(i32* %22)
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [13 x i8] c"data.float64\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"create_float64: done\0A\00"
define i32 @main() {
%1 = alloca [10 x double]
%2 = bitcast [10 x double]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
%5 = bitcast [10 x double]* %1 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 2
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 4
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 4.000000e+00, double 5.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 6
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 6.000000e+00, double 7.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 8
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 8.000000e+00, double 9.000000e+00>, <2 x double>* %13
%14 = call i32 @fwrite(double* %4, i32 8, i32 10, i32* %3)
%15 = tail call i32 @fclose(i32* %3)
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}