#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 */

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int exp(int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, double *, int);
int create_Data_file(void) {
  int i, nbVal;
  double tabD[20000], Inc;
  char *F_name;
  int fp;
  F_name = "log_inp.ref";
  nbVal = 20000;
  Inc = exp(1) / 10;
  for (i = 0; i < nbVal; i++)
    tabD[i] = (Inc * i) + Inc;
  fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
  if (!fp) {
    printf("error opening file");
    close(fp);
    return -1;
  } else {
    for (i = 0; i < nbVal; i++) {
      write(fp, &tabD[i], sizeof(double));
    }
    close(fp);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Data_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27130,%rsp
lea    0xe9e(%rip),%rax
mov    %rax,-0x27120(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    $0x1,%edi
call   1060 <exp@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x27118(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d9 <create_Data_file+0x89>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  -0x27118(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <create_Data_file+0x45>
mov    -0x27120(%rbp),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    0x2e08(%rip),%rax
or     (%rax),%esi
mov    0x2df7(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    123b <create_Data_file+0xeb>
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1290 <create_Data_file+0x140>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127e <create_Data_file+0x12e>
mov    -0x27124(%rbp),%edi
movslq -0x8(%rbp),%rax
lea    -0x27110(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1242 <create_Data_file+0xf2>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_Data_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x27100,%rsp
mov    $0x1,%edi
call   1060 <exp@plt>
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
unpcklpd %xmm0,%xmm0
movdqa 0xe75(%rip),%xmm1
mov    $0x6,%eax
movdqa 0xe78(%rip),%xmm2
movdqa 0xe80(%rip),%xmm3
movdqa 0xe88(%rip),%xmm4
movdqa 0xe90(%rip),%xmm5
movdqa %xmm1,%xmm6
cvtdq2pd %xmm1,%xmm7
paddd  %xmm2,%xmm6
cvtdq2pd %xmm6,%xmm6
mulpd  %xmm0,%xmm7
addpd  %xmm0,%xmm7
mulpd  %xmm0,%xmm6
addpd  %xmm0,%xmm6
movapd %xmm7,-0x30(%rsp,%rax,8)
movapd %xmm6,-0x20(%rsp,%rax,8)
movdqa %xmm1,%xmm6
paddd  %xmm3,%xmm6
movdqa %xmm1,%xmm7
cvtdq2pd %xmm6,%xmm6
paddd  %xmm4,%xmm7
cvtdq2pd %xmm7,%xmm7
mulpd  %xmm0,%xmm6
addpd  %xmm0,%xmm6
mulpd  %xmm0,%xmm7
addpd  %xmm0,%xmm7
movapd %xmm6,-0x10(%rsp,%rax,8)
movapd %xmm7,(%rsp,%rax,8)
paddd  %xmm5,%xmm1
add    $0x8,%rax
cmp    $0x4e26,%rax
jne    11b0 <create_Data_file+0x60>
mov    0x2db2(%rip),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2db8(%rip),%rax
or     (%rax),%esi
lea    0xe0f(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
test   %eax,%eax
je     127f <create_Data_file+0x12f>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1260 <create_Data_file+0x110>
jmp    1293 <create_Data_file+0x143>
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
xor    %ebp,%ebp
mov    %ebp,%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x27100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"log_inp.ref\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [19 x i8] c"error opening file\00"
define i32 @create_Data_file() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20000 x double]
%5 = alloca double
%6 = alloca i8*
%7 = alloca i32
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 20000, i32* %3
%8 = call i32 @exp(i32 1)
%9 = sdiv i32 %8, 10
%10 = sitofp i32 %9 to double
store double %10, double* %5
store i32 0, i32* %2
br label %11
11: ; preds = %24, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load double, double* %5
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to double
%19 = load double, double* %5
%20 = call double @llvm.fmuladd.f64(double %16, double %18, double %19)
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %22
store double %20, double* %23
br label %24
24: ; preds = %15
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %11
27: ; preds = %11
%28 = load i8*, i8** %6
%29 = load i32, i32* @O_RDWR
%30 = load i32, i32* @O_CREAT
%31 = or i32 %29, %30
%32 = load i32, i32* @O_TRUNC
%33 = or i32 %31, %32
%34 = call i32 @open(i8* %28, i32 %33, i32 511)
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %27
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* %7
%40 = call i32 @close(i32 %39)
store i32 -1, i32* %1
br label %58
41: ; preds = %27
store i32 0, i32* %2
br label %42
42: ; preds = %52, %41
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %42
%47 = load i32, i32* %7
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %49
%51 = call i32 @write(i32 %47, double* %50, i32 8)
br label %52
52: ; preds = %46
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %42
55: ; preds = %42
%56 = load i32, i32* %7
%57 = call i32 @close(i32 %56)
store i32 0, i32* %1
br label %58
58: ; preds = %55, %37
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str = [12 x i8] c"log_inp.ref\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [19 x i8] c"error opening file\00"
define i32 @create_Data_file() {
%1 = alloca [20000 x double]
%2 = bitcast [20000 x double]* %1 to i8*
%3 = tail call i32 @exp(i32 1)
%4 = sdiv i32 %3, 10
%5 = sitofp i32 %4 to double
%6 = insertelement <2 x double> poison, double %5, i64 0
%7 = shufflevector <2 x double> %6, <2 x double> poison, <2 x i32> zeroinitializer
%8 = insertelement <2 x double> poison, double %5, i64 0
%9 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> zeroinitializer
br label %10
10: ; preds = %10, %0
%11 = phi i64 [ 0, %0 ], [ %33, %10 ]
%12 = phi <2 x i32> [ <i32 0, i32 1>, %0 ], [ %34, %10 ]
%13 = add <2 x i32> %12, <i32 2, i32 2>
%14 = sitofp <2 x i32> %12 to <2 x double>
%15 = sitofp <2 x i32> %13 to <2 x double>
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %7, <2 x double> %14, <2 x double> %7)
%17 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %9, <2 x double> %15, <2 x double> %9)
%18 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %11
%19 = bitcast double* %18 to <2 x double>*
store <2 x double> %16, <2 x double>* %19
%20 = getelementptr inbounds double, double* %18, i64 2
%21 = bitcast double* %20 to <2 x double>*
store <2 x double> %17, <2 x double>* %21
%22 = or i64 %11, 4
%23 = add <2 x i32> %12, <i32 4, i32 4>
%24 = add <2 x i32> %12, <i32 6, i32 6>
%25 = sitofp <2 x i32> %23 to <2 x double>
%26 = sitofp <2 x i32> %24 to <2 x double>
%27 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %7, <2 x double> %25, <2 x double> %7)
%28 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %9, <2 x double> %26, <2 x double> %9)
%29 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %22
%30 = bitcast double* %29 to <2 x double>*
store <2 x double> %27, <2 x double>* %30
%31 = getelementptr inbounds double, double* %29, i64 2
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> %28, <2 x double>* %32
%33 = add nuw nsw i64 %11, 8
%34 = add <2 x i32> %12, <i32 8, i32 8>
%35 = icmp eq i64 %33, 20000
br i1 %35, label %36, label %10
36: ; preds = %10
%37 = load i32, i32* @O_RDWR
%38 = load i32, i32* @O_CREAT
%39 = or i32 %38, %37
%40 = load i32, i32* @O_TRUNC
%41 = or i32 %39, %40
%42 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %41, i32 511)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %36
%45 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %52
46: ; preds = %36, %46
%47 = phi i64 [ %50, %46 ], [ 0, %36 ]
%48 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %47
%49 = call i32 @write(i32 %42, double* %48, i32 8)
%50 = add nuw nsw i64 %47, 1
%51 = icmp eq i64 %50, 20000
br i1 %51, label %52, label %46
52: ; preds = %46, %44
%53 = phi i32 [ 0, %44 ], [ %42, %46 ]
%54 = phi i32 [ -1, %44 ], [ 0, %46 ]
%55 = tail call i32 @close(i32 %53)
ret i32 %54
}