#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 open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, double *, int);
int create_Data_file() {
  int i, nbVal;
  double tabDtan[20000], Inc;
  char *F_name;
  int fp;
  F_name = "dtan";
  nbVal = 20000;
  Inc = (2 * 3.1415926535897932384626433832795029L) / nbVal;
  for (i = 0; i < nbVal; i++) {
    if ((Inc * i) != (3.1415926535897932384626433832795029L / 2))
      tabDtan[i] = (Inc * i);
    else
      tabDtan[i] = 0;
  }
  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, &tabDtan[i], sizeof(double));
    }
    close(fp);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Data_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27140,%rsp
lea    0xece(%rip),%rax
mov    %rax,-0x27120(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x27128(%rbp)
fildl  -0x27128(%rbp)
fldt   0xe8b(%rip)
fdivp  %st,%st(1)
fstpl  -0x27130(%rbp)
movsd  -0x27130(%rbp),%xmm0
ff
movsd  %xmm0,-0x27118(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1222 <create_Data_file+0xe2>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x27138(%rbp)
ff
fldl   -0x27138(%rbp)
fldt   0xe4b(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11dc <create_Data_file+0x9c>
jp     11dc <create_Data_file+0x9c>
jmp    11ff <create_Data_file+0xbf>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
jmp    120f <create_Data_file+0xcf>
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
jmp    1214 <create_Data_file+0xd4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1194 <create_Data_file+0x54>
mov    -0x27120(%rbp),%rdi
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
mov    0x2dbf(%rip),%rax
or     (%rax),%esi
mov    0x2dae(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1060 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    1284 <create_Data_file+0x144>
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d9 <create_Data_file+0x199>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c7 <create_Data_file+0x187>
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    128b <create_Data_file+0x14b>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_Data_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x27120,%rsp
movdqa 0xead(%rip),%xmm0
mov    $0x2,%eax
movdqa 0xeaf(%rip),%xmm8
movapd 0xeb7(%rip),%xmm2
fldt   0xec1(%rip)
movdqa 0xec8(%rip),%xmm9
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
cvtdq2pd %xmm0,%xmm5
cvtdq2pd %xmm4,%xmm4
mulpd  %xmm2,%xmm5
mulpd  %xmm2,%xmm4
movlpd %xmm5,0x18(%rsp)
movhpd %xmm5,0x10(%rsp)
fldl   0x18(%rsp)
fldl   0x10(%rsp)
movlpd %xmm4,0x8(%rsp)
movhpd %xmm4,(%rsp)
fldl   (%rsp)
fxch   %st(1)
fucomip %st(3),%st
setp   %cl
setne  %dl
or     %cl,%dl
movzbl %dl,%ecx
neg    %rcx
fxch   %st(1)
fucomip %st(2),%st
setp   %dl
setne  %bl
or     %dl,%bl
movzbl %bl,%edx
neg    %rdx
fucomip %st(1),%st
setp   %sil
setne  %bl
or     %sil,%bl
fldl   0x8(%rsp)
movq   %rcx,%xmm6
movzbl %bl,%ecx
neg    %rcx
fucomip %st(1),%st
movq   %rdx,%xmm7
setp   %dl
setne  %bl
or     %dl,%bl
movq   %rcx,%xmm1
movzbl %bl,%ecx
neg    %rcx
movq   %rcx,%xmm3
punpcklqdq %xmm6,%xmm7
punpcklqdq %xmm1,%xmm3
pand   %xmm5,%xmm7
pand   %xmm4,%xmm3
movdqa %xmm7,0x10(%rsp,%rax,8)
movdqa %xmm3,0x20(%rsp,%rax,8)
paddd  %xmm9,%xmm0
add    $0x4,%rax
cmp    $0x4e22,%rax
jne    1180 <create_Data_file+0x40>
fstp   %st(0)
mov    0x2d85(%rip),%rax
mov    0x2d9e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d8b(%rip),%rax
or     (%rax),%esi
lea    0xde2(%rip),%rdi
mov    $0x1ff,%edx
call   1060 <open@plt>
test   %eax,%eax
je     12b3 <create_Data_file+0x173>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rsp,%rbx,1),%rsi
add    $0x20,%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1290 <create_Data_file+0x150>
jmp    12c7 <create_Data_file+0x187>
lea    0xd9b(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
xor    %ebp,%ebp
mov    %ebp,%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x27120,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"dtan\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 20000, i32* %3
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to x86_fp80
%10 = fdiv x86_fp80 0xK4001C90FDAA22168C235, %9
%11 = fptrunc x86_fp80 %10 to double
store double %11, double* %5
store i32 0, i32* %2
br label %12
12: ; preds = %36, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %39
16: ; preds = %12
%17 = load double, double* %5
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = fmul double %17, %19
%21 = fpext double %20 to x86_fp80
%22 = fcmp une x86_fp80 %21, 0xK3FFFC90FDAA22168C235
br i1 %22, label %23, label %31
23: ; preds = %16
%24 = load double, double* %5
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to double
%27 = fmul double %24, %26
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %29
store double %27, double* %30
br label %35
31: ; preds = %16
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %33
store double 0.000000e+00, double* %34
br label %35
35: ; preds = %31, %23
br label %36
36: ; preds = %35
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %12
39: ; preds = %12
%40 = load i8*, i8** %6
%41 = load i32, i32* @O_RDWR
%42 = load i32, i32* @O_CREAT
%43 = or i32 %41, %42
%44 = load i32, i32* @O_TRUNC
%45 = or i32 %43, %44
%46 = call i32 @open(i8* %40, i32 %45, i32 511)
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %39
%50 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%51 = load i32, i32* %7
%52 = call i32 @close(i32 %51)
store i32 -1, i32* %1
br label %70
53: ; preds = %39
store i32 0, i32* %2
br label %54
54: ; preds = %64, %53
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = load i32, i32* %7
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %61
%63 = call i32 @write(i32 %59, double* %62, i32 8)
br label %64
64: ; preds = %58
%65 = load i32, i32* %2
%66 = add nsw i32 %65, 1
store i32 %66, i32* %2
br label %54
67: ; preds = %54
%68 = load i32, i32* %7
%69 = call i32 @close(i32 %68)
store i32 0, i32* %1
br label %70
70: ; preds = %67, %49
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [5 x i8] c"dtan\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*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %21, %3 ]
%5 = phi <2 x i32> [ <i32 0, i32 1>, %0 ], [ %22, %3 ]
%6 = add <2 x i32> %5, <i32 2, i32 2>
%7 = sitofp <2 x i32> %5 to <2 x double>
%8 = sitofp <2 x i32> %6 to <2 x double>
%9 = fmul <2 x double> %7, <double 0x3F3496B7C53C5B02, double 0x3F3496B7C53C5B02>
%10 = fmul <2 x double> %8, <double 0x3F3496B7C53C5B02, double 0x3F3496B7C53C5B02>
%11 = fpext <2 x double> %9 to <2 x x86_fp80>
%12 = fpext <2 x double> %10 to <2 x x86_fp80>
%13 = fcmp une <2 x x86_fp80> %11, <x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xK3FFFC90FDAA22168C235>
%14 = fcmp une <2 x x86_fp80> %12, <x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xK3FFFC90FDAA22168C235>
%15 = select <2 x i1> %13, <2 x double> %9, <2 x double> zeroinitializer
%16 = select <2 x i1> %14, <2 x double> %10, <2 x double> zeroinitializer
%17 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %4
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> %15, <2 x double>* %18
%19 = getelementptr inbounds double, double* %17, i64 2
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> %16, <2 x double>* %20
%21 = add nuw i64 %4, 4
%22 = add <2 x i32> %5, <i32 4, i32 4>
%23 = icmp eq i64 %21, 20000
br i1 %23, label %24, label %3
24: ; preds = %3
%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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %29, i32 511)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %40
34: ; preds = %24, %34
%35 = phi i64 [ %38, %34 ], [ 0, %24 ]
%36 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %35
%37 = call i32 @write(i32 %30, double* %36, i32 8)
%38 = add nuw nsw i64 %35, 1
%39 = icmp eq i64 %38, 20000
br i1 %39, label %40, label %34
40: ; preds = %34, %32
%41 = phi i32 [ 0, %32 ], [ %30, %34 ]
%42 = phi i32 [ -1, %32 ], [ 0, %34 ]
%43 = tail call i32 @close(i32 %41)
ret i32 %42
}