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


x86 assembly (clang, -O0):
<create_Result_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27140,%rsp
lea    0xebe(%rip),%rax
mov    %rax,-0x27120(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x27128(%rbp)
fildl  -0x27128(%rbp)
fldt   0xe7b(%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    123c <create_Result_file+0xec>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x27138(%rbp)
ff
fldl   -0x27138(%rbp)
fldt   0xe3b(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11ec <create_Result_file+0x9c>
jp     11ec <create_Result_file+0x9c>
jmp    1214 <create_Result_file+0xc4>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <tan@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
jmp    1229 <create_Result_file+0xd9>
xorps  %xmm0,%xmm0
call   1060 <tan@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
jmp    122e <create_Result_file+0xde>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a4 <create_Result_file+0x54>
mov    -0x27120(%rbp),%rdi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
mov    0x2da5(%rip),%rax
or     (%rax),%esi
mov    0x2d94(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    129e <create_Result_file+0x14e>
lea    0xda3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f3 <create_Result_file+0x1a3>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e1 <create_Result_file+0x191>
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    12a5 <create_Result_file+0x155>
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_Result_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x27120,%rsp
xor    %ebx,%ebx
fldt   0xead(%rip)
fstpt  0x14(%rsp)
jmp    1188 <create_Result_file+0x38>
nopl   0x0(%rax)
call   1060 <tan@plt>
movsd  %xmm0,0x20(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x4e20,%rbx
je     11b5 <create_Result_file+0x65>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe69(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
fldl   0x8(%rsp)
fldt   0x14(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1170 <create_Result_file+0x20>
jp     1170 <create_Result_file+0x20>
xorpd  %xmm0,%xmm0
jmp    1175 <create_Result_file+0x25>
mov    0x2e1c(%rip),%rax
mov    0x2e35(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e22(%rip),%rax
or     (%rax),%esi
lea    0xe49(%rip),%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
test   %eax,%eax
je     1213 <create_Result_file+0xc3>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%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    11f0 <create_Result_file+0xa0>
jmp    1227 <create_Result_file+0xd7>
lea    0xe0b(%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"rtan\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_Result_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 = %38, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %41
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 %32
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 = call double @tan(double %27)
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %30
store double %28, double* %31
br label %37
32: ; preds = %16
%33 = call double @tan(double 0.000000e+00)
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %35
store double %33, double* %36
br label %37
37: ; preds = %32, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %12
41: ; preds = %12
%42 = load i8*, i8** %6
%43 = load i32, i32* @O_RDWR
%44 = load i32, i32* @O_CREAT
%45 = or i32 %43, %44
%46 = load i32, i32* @O_TRUNC
%47 = or i32 %45, %46
%48 = call i32 @open(i8* %42, i32 %47, i32 511)
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = icmp ne i32 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %41
%52 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%53 = load i32, i32* %7
%54 = call i32 @close(i32 %53)
store i32 -1, i32* %1
br label %72
55: ; preds = %41
store i32 0, i32* %2
br label %56
56: ; preds = %66, %55
%57 = load i32, i32* %2
%58 = load i32, i32* %3
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = load i32, i32* %7
%62 = load i32, i32* %2
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %63
%65 = call i32 @write(i32 %61, double* %64, i32 8)
br label %66
66: ; preds = %60
%67 = load i32, i32* %2
%68 = add nsw i32 %67, 1
store i32 %68, i32* %2
br label %56
69: ; preds = %56
%70 = load i32, i32* %7
%71 = call i32 @close(i32 %70)
store i32 0, i32* %1
br label %72
72: ; preds = %69, %51
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [5 x i8] c"rtan\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_Result_file() {
%1 = alloca [20000 x double]
%2 = bitcast [20000 x double]* %1 to i8*
br label %3
3: ; preds = %0, %12
%4 = phi i64 [ 0, %0 ], [ %15, %12 ]
%5 = trunc i64 %4 to i32
%6 = sitofp i32 %5 to double
%7 = fmul double %6, 0x3F3496B7C53C5B02
%8 = fpext double %7 to x86_fp80
%9 = fcmp une x86_fp80 %8, 0xK3FFFC90FDAA22168C235
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call double @tan(double %7)
br label %12
12: ; preds = %3, %10
%13 = phi double [ %11, %10 ], [ 0.000000e+00, %3 ]
%14 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %4
store double %13, double* %14
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 20000
br i1 %16, label %17, label %3
17: ; preds = %12
%18 = load i32, i32* @O_RDWR
%19 = load i32, i32* @O_CREAT
%20 = or i32 %19, %18
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = tail call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22, i32 511)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %33
27: ; preds = %17, %27
%28 = phi i64 [ %31, %27 ], [ 0, %17 ]
%29 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %28
%30 = call i32 @write(i32 %23, double* %29, i32 8)
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, 20000
br i1 %32, label %33, label %27
33: ; preds = %27, %25
%34 = phi i32 [ 0, %25 ], [ %23, %27 ]
%35 = phi i32 [ -1, %25 ], [ 0, %27 ]
%36 = tail call i32 @close(i32 %34)
ret i32 %35
}