#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*/ ConvertFwriteDouble(int /*<<< orphan*/ *, double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  double val[8] = {0.1, 0.2, 0.5, -0.5, 0.6, 1.2, 1.8, -0.8};
  FILE *fp;
  fp = fopen("test.dat", "w");
  for (i = 0; i < 8; i++)
    ConvertFwriteDouble(fp, val[i]);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    0xece(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11b4 <main+0x74>
mov    -0x68(%rbp),%rdi
movslq -0x14(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
call   1060 <ConvertFwriteDouble@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x49>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf08(%rip),%rdi
lea    0xf0a(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
movsd  0xeb1(%rip),%xmm0
mov    %rax,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xea9(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xea1(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xe99(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xe91(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xe89(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xe81(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
movsd  0xe79(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <ConvertFwriteDouble@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.val = [8 x double] [double 1.000000e-01, double 2.000000e-01, double 5.000000e-01, double -5.000000e-01, double 6.000000e-01, double 1.200000e+00, double 1.800000e+00, double -8.000000e-01]
@.str = [9 x i8] c"test.dat\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8 x double]
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [8 x double]* %7 to i8*
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %8
store i32 0, i32* %6
br label %11
11: ; preds = %21, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32*, i32** %8
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [8 x double], [8 x double]* %7, i64 0, i64 %17
%19 = load double, double* %18
%20 = call i32 @ConvertFwriteDouble(i32* %15, double %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %11
24: ; preds = %11
%25 = load i32*, i32** %8
%26 = call i32 @fclose(i32* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.dat\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @ConvertFwriteDouble(i32* %3, double 1.000000e-01)
%5 = tail call i32 @ConvertFwriteDouble(i32* %3, double 2.000000e-01)
%6 = tail call i32 @ConvertFwriteDouble(i32* %3, double 5.000000e-01)
%7 = tail call i32 @ConvertFwriteDouble(i32* %3, double -5.000000e-01)
%8 = tail call i32 @ConvertFwriteDouble(i32* %3, double 6.000000e-01)
%9 = tail call i32 @ConvertFwriteDouble(i32* %3, double 1.200000e+00)
%10 = tail call i32 @ConvertFwriteDouble(i32* %3, double 1.800000e+00)
%11 = tail call i32 @ConvertFwriteDouble(i32* %3, double -8.000000e-01)
%12 = tail call i32 @fclose(i32* %3)
ret i32 0
}