#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 tabDD[20000], tabDI[20000], Inc;
  char *F_named, *F_namei;
  int fp, fpi;
  F_named = "ldexp_inp.ref";
  F_namei = "ildexp_inp.ref";
  nbVal = 20000;
  Inc = exp(1) / 10;
  for (i = 0; i < (nbVal); i++) {
    tabDD[i] = (Inc * i) + Inc;
    tabDI[i] = nbVal - i;
  }
  fp = open(F_named, O_RDWR | O_CREAT | O_TRUNC, 0777);
  fpi = open(F_namei, O_RDWR | O_CREAT | O_TRUNC, 0777);
  if (!fp || !fpi) {
    printf("error opening file");
    close(fp);
    close(fpi);
    return -1;
  } else {
    for (i = 0; i < nbVal; i++) {
      write(fp, &tabDD[i], sizeof(double));
      write(fpi, &tabDI[i], sizeof(int));
    }
    close(fp);
    close(fpi);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Data_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e230,%rsp
lea    0xe9f(%rip),%rax
mov    %rax,-0x4e220(%rbp)
lea    0xe90(%rip),%rax
mov    %rax,-0x4e228(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    $0x1,%edi
call   1060 <exp@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x4e218(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <create_Data_file+0xae>
movsd  -0x4e218(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  -0x4e218(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x4e210(%rbp,%rax,8)
fb ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <create_Data_file+0x53>
mov    -0x4e220(%rbp),%rdi
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
mov    0x2de3(%rip),%rax
or     (%rax),%esi
mov    0x2dd2(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x4e22c(%rbp)
mov    -0x4e228(%rbp),%rdi
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
mov    0x2db1(%rip),%rax
or     (%rax),%esi
mov    0x2da0(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x4e230(%rbp)
cmpl   $0x0,-0x4e22c(%rbp)
je     127c <create_Data_file+0x12c>
cmpl   $0x0,-0x4e230(%rbp)
jne    12aa <create_Data_file+0x15a>
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4e22c(%rbp),%edi
call   1050 <close@plt>
mov    -0x4e230(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    132c <create_Data_file+0x1dc>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    130f <create_Data_file+0x1bf>
mov    -0x4e22c(%rbp),%edi
movslq -0x8(%rbp),%rax
lea    -0x27110(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    -0x4e230(%rbp),%edi
movslq -0x8(%rbp),%rax
lea    -0x4e210(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12b1 <create_Data_file+0x161>
mov    -0x4e22c(%rbp),%edi
call   1050 <close@plt>
mov    -0x4e230(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4e230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_Data_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4e208,%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 0xe73(%rip),%xmm1
mov    $0x2,%eax
movdqa 0xe75(%rip),%xmm8
movdqa 0xe7d(%rip),%xmm3
movdqa 0xe85(%rip),%xmm4
movdqa 0xe8d(%rip),%xmm5
movdqa %xmm1,%xmm6
nopw   0x0(%rax,%rax,1)
movdqa %xmm1,%xmm7
paddd  %xmm8,%xmm7
cvtdq2pd %xmm1,%xmm2
cvtdq2pd %xmm7,%xmm7
mulpd  %xmm0,%xmm2
addpd  %xmm0,%xmm2
mulpd  %xmm0,%xmm7
addpd  %xmm0,%xmm7
movapd %xmm2,0x270f0(%rsp,%rax,8)
movapd %xmm7,0x27100(%rsp,%rax,8)
movdqa %xmm3,%xmm2
psubd  %xmm6,%xmm2
movdqa %xmm4,%xmm7
psubd  %xmm6,%xmm7
cvtdq2pd %xmm2,%xmm2
cvtdq2pd %xmm7,%xmm7
movaps %xmm2,-0x10(%rsp,%rax,8)
movaps %xmm7,(%rsp,%rax,8)
paddd  %xmm5,%xmm1
paddd  %xmm5,%xmm6
add    $0x4,%rax
cmp    $0x4e22,%rax
jne    11c0 <create_Data_file+0x70>
mov    0x2da9(%rip),%r14
mov    0x2dc2(%rip),%rbp
mov    0x0(%rbp),%esi
or     (%r14),%esi
mov    0x2dad(%rip),%rbx
or     (%rbx),%esi
lea    0xe05(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%r15d
mov    0x0(%rbp),%esi
or     (%r14),%esi
or     (%rbx),%esi
lea    0xde8(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%ebp
test   %r15d,%r15d
je     12c7 <create_Data_file+0x177>
test   %ebp,%ebp
je     12c7 <create_Data_file+0x177>
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rsp,%rbx,1),%rsi
add    $0x27100,%rsi
mov    %r15d,%edi
mov    $0x8,%edx
call   1030 <write@plt>
lea    (%rsp,%rbx,1),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1290 <create_Data_file+0x140>
jmp    12d9 <create_Data_file+0x189>
lea    0xd91(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r15d,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x4e208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"ldexp_inp.ref\00"
@.str.1 = [15 x i8] c"ildexp_inp.ref\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [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 [20000 x double]
%6 = alloca double
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i32 20000, i32* %3
%11 = call i32 @exp(i32 1)
%12 = sdiv i32 %11, 10
%13 = sitofp i32 %12 to double
store double %13, double* %6
store i32 0, i32* %2
br label %14
14: ; preds = %34, %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load double, double* %6
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = load double, double* %6
%23 = call double @llvm.fmuladd.f64(double %19, double %21, double %22)
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %25
store double %23, double* %26
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = sub nsw i32 %27, %28
%30 = sitofp i32 %29 to double
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20000 x double], [20000 x double]* %5, i64 0, i64 %32
store double %30, double* %33
br label %34
34: ; preds = %18
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %14
37: ; preds = %14
%38 = load i8*, i8** %7
%39 = load i32, i32* @O_RDWR
%40 = load i32, i32* @O_CREAT
%41 = or i32 %39, %40
%42 = load i32, i32* @O_TRUNC
%43 = or i32 %41, %42
%44 = call i32 @open(i8* %38, i32 %43, i32 511)
store i32 %44, i32* %9
%45 = load i8*, i8** %8
%46 = load i32, i32* @O_RDWR
%47 = load i32, i32* @O_CREAT
%48 = or i32 %46, %47
%49 = load i32, i32* @O_TRUNC
%50 = or i32 %48, %49
%51 = call i32 @open(i8* %45, i32 %50, i32 511)
store i32 %51, i32* %10
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %37
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %63, label %57
57: ; preds = %54, %37
%58 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32, i32* %9
%60 = call i32 @close(i32 %59)
%61 = load i32, i32* %10
%62 = call i32 @close(i32 %61)
store i32 -1, i32* %1
br label %87
63: ; preds = %54
store i32 0, i32* %2
br label %64
64: ; preds = %79, %63
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %82
68: ; preds = %64
%69 = load i32, i32* %9
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %71
%73 = call i32 @write(i32 %69, double* %72, i32 8)
%74 = load i32, i32* %10
%75 = load i32, i32* %2
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [20000 x double], [20000 x double]* %5, i64 0, i64 %76
%78 = call i32 @write(i32 %74, double* %77, i32 4)
br label %79
79: ; preds = %68
%80 = load i32, i32* %2
%81 = add nsw i32 %80, 1
store i32 %81, i32* %2
br label %64
82: ; preds = %64
%83 = load i32, i32* %9
%84 = call i32 @close(i32 %83)
%85 = load i32, i32* %10
%86 = call i32 @close(i32 %85)
store i32 0, i32* %1
br label %87
87: ; preds = %82, %57
%88 = load i32, i32* %1
ret i32 %88
}

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