#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);
double 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 = "frexp_inp.ref";
  nbVal = 20000;
  Inc = exp(1);
  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>
movsd  %xmm0,-0x27118(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <create_Data_file+0x7d>
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    1189 <create_Data_file+0x39>
mov    -0x27120(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
mov    0x2e14(%rip),%rax
or     (%rax),%esi
mov    0x2e03(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    122f <create_Data_file+0xdf>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1284 <create_Data_file+0x134>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1272 <create_Data_file+0x122>
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    1236 <create_Data_file+0xe6>
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>
unpcklpd %xmm0,%xmm0
movdqa 0xe8f(%rip),%xmm1
mov    $0x6,%eax
movdqa 0xe92(%rip),%xmm2
movdqa 0xe9a(%rip),%xmm3
movdqa 0xea2(%rip),%xmm4
movdqa 0xeaa(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
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    11a0 <create_Data_file+0x50>
mov    0x2dc2(%rip),%rax
mov    0x2ddb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dc8(%rip),%rax
or     (%rax),%esi
lea    0xe1f(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
test   %eax,%eax
je     126f <create_Data_file+0x11f>
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    1250 <create_Data_file+0x100>
jmp    1283 <create_Data_file+0x133>
lea    0xde8(%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 = [14 x i8] c"frexp_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 ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 20000, i32* %3
%8 = call double @exp(i32 1)
store double %8, double* %5
store i32 0, i32* %2
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load double, double* %5
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = load double, double* %5
%18 = call double @llvm.fmuladd.f64(double %14, double %16, double %17)
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %20
store double %18, double* %21
br label %22
22: ; preds = %13
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %9
25: ; preds = %9
%26 = load i8*, i8** %6
%27 = load i32, i32* @O_RDWR
%28 = load i32, i32* @O_CREAT
%29 = or i32 %27, %28
%30 = load i32, i32* @O_TRUNC
%31 = or i32 %29, %30
%32 = call i32 @open(i8* %26, i32 %31, i32 511)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %25
%36 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %7
%38 = call i32 @close(i32 %37)
store i32 -1, i32* %1
br label %56
39: ; preds = %25
store i32 0, i32* %2
br label %40
40: ; preds = %50, %39
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = load i32, i32* %7
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %47
%49 = call i32 @write(i32 %45, double* %48, i32 8)
br label %50
50: ; preds = %44
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %40
53: ; preds = %40
%54 = load i32, i32* %7
%55 = call i32 @close(i32 %54)
store i32 0, i32* %1
br label %56
56: ; preds = %53, %35
%57 = load i32, i32* %1
ret i32 %57
}

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