#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 = "dtanh";
  nbVal = 20000;
  Inc = exp(1) / 100;
  for (i = 0; i < nbVal; i++)
    tabD[i] = Inc * (i - nbVal / 2);
  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    $0x64,%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    11ea <create_Data_file+0x9a>
movsd  -0x27118(%rbp),%xmm0
ff
mov    -0x8(%rbp),%eax
mov    %eax,-0x27128(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x27128(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %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    0x2de0(%rip),%rax
mov    (%rax),%esi
mov    0x2df7(%rip),%rax
or     (%rax),%esi
mov    0x2de6(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    124c <create_Data_file+0xfc>
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a1 <create_Data_file+0x151>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128f <create_Data_file+0x13f>
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    1253 <create_Data_file+0x103>
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   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
unpcklpd %xmm0,%xmm0
movdqa 0xe75(%rip),%xmm1
mov    $0x6,%eax
movdqa 0xe77(%rip),%xmm8
movdqa 0xe7e(%rip),%xmm9
movdqa 0xe86(%rip),%xmm4
movdqa 0xe8e(%rip),%xmm5
movdqa 0xe96(%rip),%xmm6
nopw   0x0(%rax,%rax,1)
movdqa %xmm1,%xmm7
paddd  %xmm8,%xmm7
movdqa %xmm1,%xmm2
cvtdq2pd %xmm7,%xmm7
paddd  %xmm9,%xmm2
cvtdq2pd %xmm2,%xmm2
mulpd  %xmm0,%xmm7
mulpd  %xmm0,%xmm2
movapd %xmm7,-0x30(%rsp,%rax,8)
movdqa %xmm1,%xmm7
paddd  %xmm4,%xmm7
movdqa %xmm1,%xmm3
paddd  %xmm5,%xmm3
cvtdq2pd %xmm7,%xmm7
cvtdq2pd %xmm3,%xmm3
movapd %xmm2,-0x20(%rsp,%rax,8)
mulpd  %xmm0,%xmm7
mulpd  %xmm0,%xmm3
movapd %xmm7,-0x10(%rsp,%rax,8)
movapd %xmm3,(%rsp,%rax,8)
paddd  %xmm6,%xmm1
add    $0x8,%rax
cmp    $0x4e26,%rax
jne    11c0 <create_Data_file+0x70>
mov    0x2da8(%rip),%rax
mov    0x2dc1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dae(%rip),%rax
or     (%rax),%esi
lea    0xe15(%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
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    0xde0(%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 = [6 x i8] c"dtanh\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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 20000, i32* %3
%8 = call i32 @exp(i32 1)
%9 = sdiv i32 %8, 100
%10 = sitofp i32 %9 to double
store double %10, double* %5
store i32 0, i32* %2
br label %11
11: ; preds = %26, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load double, double* %5
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 2
%20 = sub nsw i32 %17, %19
%21 = sitofp i32 %20 to double
%22 = fmul double %16, %21
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %24
store double %22, double* %25
br label %26
26: ; preds = %15
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %11
29: ; preds = %11
%30 = load i8*, i8** %6
%31 = load i32, i32* @O_RDWR
%32 = load i32, i32* @O_CREAT
%33 = or i32 %31, %32
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = call i32 @open(i8* %30, i32 %35, i32 511)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %29
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %7
%42 = call i32 @close(i32 %41)
store i32 -1, i32* %1
br label %60
43: ; preds = %29
store i32 0, i32* %2
br label %44
44: ; preds = %54, %43
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = load i32, i32* %7
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %51
%53 = call i32 @write(i32 %49, double* %52, i32 8)
br label %54
54: ; preds = %48
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %44
57: ; preds = %44
%58 = load i32, i32* %7
%59 = call i32 @close(i32 %58)
store i32 0, i32* %1
br label %60
60: ; preds = %57, %39
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [6 x i8] c"dtanh\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, 100
%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 ], [ %34, %10 ]
%12 = phi <2 x i32> [ <i32 0, i32 1>, %0 ], [ %35, %10 ]
%13 = add <2 x i32> %12, <i32 -10000, i32 -10000>
%14 = add <2 x i32> %12, <i32 -9998, i32 -9998>
%15 = sitofp <2 x i32> %13 to <2 x double>
%16 = sitofp <2 x i32> %14 to <2 x double>
%17 = fmul <2 x double> %7, %15
%18 = fmul <2 x double> %9, %16
%19 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %11
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> %17, <2 x double>* %20
%21 = getelementptr inbounds double, double* %19, i64 2
%22 = bitcast double* %21 to <2 x double>*
store <2 x double> %18, <2 x double>* %22
%23 = or i64 %11, 4
%24 = add <2 x i32> %12, <i32 -9996, i32 -9996>
%25 = add <2 x i32> %12, <i32 -9994, i32 -9994>
%26 = sitofp <2 x i32> %24 to <2 x double>
%27 = sitofp <2 x i32> %25 to <2 x double>
%28 = fmul <2 x double> %7, %26
%29 = fmul <2 x double> %9, %27
%30 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %23
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %28, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> %29, <2 x double>* %33
%34 = add nuw nsw i64 %11, 8
%35 = add <2 x i32> %12, <i32 8, i32 8>
%36 = icmp eq i64 %34, 20000
br i1 %36, label %37, label %10
37: ; preds = %10
%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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %42, i32 511)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %53
47: ; preds = %37, %47
%48 = phi i64 [ %51, %47 ], [ 0, %37 ]
%49 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %48
%50 = call i32 @write(i32 %43, double* %49, i32 8)
%51 = add nuw nsw i64 %48, 1
%52 = icmp eq i64 %51, 20000
br i1 %52, label %53, label %47
53: ; preds = %47, %45
%54 = phi i32 [ 0, %45 ], [ %43, %47 ]
%55 = phi i32 [ -1, %45 ], [ 0, %47 ]
%56 = tail call i32 @close(i32 %54)
ret i32 %55
}