#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);
double log(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], tabD1[20000], Inc;
  char *F_name, *F_name1;
  int fp, fp1;
  F_name = "fmod_inp.ref";
  F_name1 = "1fmod_inp.ref";
  nbVal = 20000;
  Inc = exp(1) / 10;
  for (i = 0; i < nbVal; i++) {
    tabD[i] = log((Inc * i) + Inc);
    tabD1[i] = log(nbVal - (Inc * i) + Inc);
  }
  fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
  fp1 = open(F_name1, O_RDWR | O_CREAT | O_TRUNC, 0777);
  if (!fp || !fp1) {
    printf("error opening file");
    close(fp);
    close(fp1);
    return -1;
  } else {
    for (i = 0; i < nbVal; i++) {
      write(fp, &tabD[i], sizeof(double));
      write(fp1, &tabD1[i], sizeof(double));
    }
    close(fp);
    close(fp1);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Data_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e230,%rsp
lea    0xe8f(%rip),%rax
mov    %rax,-0x4e220(%rbp)
lea    0xe80(%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    124f <create_Data_file+0xef>
movsd  -0x4e218(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  -0x4e218(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <log@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  -0x4e218(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x4e218(%rbp),%xmm0
ff
cvttsd2si %xmm0,%edi
call   1080 <log@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x4e210(%rbp,%rax,8)
fb ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b3 <create_Data_file+0x53>
mov    -0x4e220(%rbp),%rdi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
mov    0x2d92(%rip),%rax
or     (%rax),%esi
mov    0x2d81(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x4e22c(%rbp)
mov    -0x4e228(%rbp),%rdi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
mov    0x2d60(%rip),%rax
or     (%rax),%esi
mov    0x2d4f(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x4e230(%rbp)
cmpl   $0x0,-0x4e22c(%rbp)
je     12cd <create_Data_file+0x16d>
cmpl   $0x0,-0x4e230(%rbp)
jne    12fb <create_Data_file+0x19b>
lea    0xd3a(%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    137d <create_Data_file+0x21d>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1360 <create_Data_file+0x200>
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    $0x8,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1302 <create_Data_file+0x1a2>
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    $0x4e238,%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
movapd 0xe67(%rip),%xmm1
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <log@plt>
movsd  %xmm0,0x27130(%rsp,%rbx,8)
movsd  0x8(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
addsd  0xe1b(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <log@plt>
movsd  %xmm0,0x30(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x4e20,%rbx
jne    11b0 <create_Data_file+0x50>
mov    0x2dba(%rip),%r14
mov    0x2dd3(%rip),%rbp
mov    0x0(%rbp),%esi
or     (%r14),%esi
mov    0x2dbe(%rip),%rbx
or     (%rbx),%esi
lea    0xdde(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%r15d
mov    0x0(%rbp),%esi
or     (%r14),%esi
or     (%rbx),%esi
lea    0xdc1(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%ebp
test   %r15d,%r15d
je     12bb <create_Data_file+0x15b>
test   %ebp,%ebp
je     12bb <create_Data_file+0x15b>
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rsi
add    $0x27130,%rsi
mov    %r15d,%edi
mov    $0x8,%edx
call   1030 <write@plt>
lea    (%rsp,%rbx,1),%rsi
add    $0x30,%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1280 <create_Data_file+0x120>
jmp    12cd <create_Data_file+0x16d>
lea    0xd64(%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    $0x4e238,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"fmod_inp.ref\00"
@.str.1 = [14 x i8] c"1fmod_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 = fneg double %7
br label %9
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %22, %9 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = tail call double @llvm.fmuladd.f64(double %7, double %12, double %7)
%14 = fptosi double %13 to i32
%15 = tail call double @log(i32 %14)
%16 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %10
store double %15, double* %16
%17 = tail call double @llvm.fmuladd.f64(double %8, double %12, double 2.000000e+04)
%18 = fadd double %17, %7
%19 = fptosi double %18 to i32
%20 = tail call double @log(i32 %19)
%21 = getelementptr inbounds [20000 x double], [20000 x double]* %2, i64 0, i64 %10
store double %20, double* %21
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, 20000
br i1 %23, label %24, label %9
24: ; preds = %9
%25 = load i32, i32* @O_RDWR
%26 = load i32, i32* @O_CREAT
%27 = or i32 %26, %25
%28 = load i32, i32* @O_TRUNC
%29 = or i32 %27, %28
%30 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %29, i32 511)
%31 = load i32, i32* @O_RDWR
%32 = load i32, i32* @O_CREAT
%33 = or i32 %32, %31
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 511)
%37 = icmp ne i32 %30, 0
%38 = icmp ne i32 %36, 0
%39 = and i1 %37, %38
br i1 %39, label %42, label %40
40: ; preds = %24
%41 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %50
42: ; preds = %24, %42
%43 = phi i64 [ %48, %42 ], [ 0, %24 ]
%44 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %43
%45 = call i32 @write(i32 %30, double* %44, i32 8)
%46 = getelementptr inbounds [20000 x double], [20000 x double]* %2, i64 0, i64 %43
%47 = call i32 @write(i32 %36, double* %46, i32 8)
%48 = add nuw nsw i64 %43, 1
%49 = icmp eq i64 %48, 20000
br i1 %49, label %50, label %42
50: ; preds = %42, %40
%51 = phi i32 [ -1, %40 ], [ 0, %42 ]
%52 = tail call i32 @close(i32 %30)
%53 = tail call i32 @close(i32 %36)
ret i32 %51
}