#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);
double cosh(double);
int exp(int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, double *, int);
int create_Result_file() {
  int i, nbVal;
  double tabR[20000], Inc;
  char *F_name;
  int fp;
  F_name = "rcosh";
  nbVal = 20000;
  Inc = exp(1) / 100;
  for (i = 0; i < nbVal; i++)
    tabR[i] = cosh((Inc * i) + Inc);
  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, &tabR[i], sizeof(double));
    }
    close(fp);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Result_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27130,%rsp
lea    0xe8e(%rip),%rax
mov    %rax,-0x27120(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    $0x1,%edi
call   1070 <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    11ee <create_Result_file+0x8e>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  -0x27118(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <cosh@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a5 <create_Result_file+0x45>
mov    -0x27120(%rbp),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
mov    0x2df3(%rip),%rax
or     (%rax),%esi
mov    0x2de2(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1080 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    1250 <create_Result_file+0xf0>
lea    0xdd2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a5 <create_Result_file+0x145>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1293 <create_Result_file+0x133>
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    1257 <create_Result_file+0xf7>
mov    -0x27124(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_Result_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x27110,%rsp
mov    $0x1,%edi
call   1070 <exp@plt>
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
call   1040 <cosh@plt>
movsd  %xmm0,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x4e20,%rbx
jne    11a0 <create_Result_file+0x40>
mov    0x2e04(%rip),%rax
mov    0x2e1d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e0a(%rip),%rax
or     (%rax),%esi
lea    0xe11(%rip),%rdi
mov    $0x1ff,%edx
call   1080 <open@plt>
test   %eax,%eax
je     1233 <create_Result_file+0xd3>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1210 <create_Result_file+0xb0>
jmp    1247 <create_Result_file+0xe7>
lea    0xdcc(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
xor    %ebp,%ebp
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14d,%eax
add    $0x27110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"rcosh\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 ([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 = %25, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = load double, double* %5
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to double
%19 = load double, double* %5
%20 = call double @llvm.fmuladd.f64(double %16, double %18, double %19)
%21 = call double @cosh(double %20)
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %23
store double %21, double* %24
br label %25
25: ; preds = %15
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %11
28: ; preds = %11
%29 = load i8*, i8** %6
%30 = load i32, i32* @O_RDWR
%31 = load i32, i32* @O_CREAT
%32 = or i32 %30, %31
%33 = load i32, i32* @O_TRUNC
%34 = or i32 %32, %33
%35 = call i32 @open(i8* %29, i32 %34, i32 511)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %28
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* %7
%41 = call i32 @close(i32 %40)
store i32 -1, i32* %1
br label %59
42: ; preds = %28
store i32 0, i32* %2
br label %43
43: ; preds = %53, %42
%44 = load i32, i32* %2
%45 = load i32, i32* %3
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %56
47: ; preds = %43
%48 = load i32, i32* %7
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %50
%52 = call i32 @write(i32 %48, double* %51, i32 8)
br label %53
53: ; preds = %47
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
br label %43
56: ; preds = %43
%57 = load i32, i32* %7
%58 = call i32 @close(i32 %57)
store i32 0, i32* %1
br label %59
59: ; preds = %56, %38
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [6 x i8] c"rcosh\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*
%3 = tail call i32 @exp(i32 1)
%4 = sdiv i32 %3, 100
%5 = sitofp i32 %4 to double
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %13, %6 ]
%8 = trunc i64 %7 to i32
%9 = sitofp i32 %8 to double
%10 = tail call double @llvm.fmuladd.f64(double %5, double %9, double %5)
%11 = tail call double @cosh(double %10)
%12 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %7
store double %11, double* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 20000
br i1 %14, label %15, label %6
15: ; preds = %6
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_CREAT
%18 = or i32 %17, %16
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %18, %19
%21 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20, i32 511)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %31
25: ; preds = %15, %25
%26 = phi i64 [ %29, %25 ], [ 0, %15 ]
%27 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %26
%28 = call i32 @write(i32 %21, double* %27, i32 8)
%29 = add nuw nsw i64 %26, 1
%30 = icmp eq i64 %29, 20000
br i1 %30, label %31, label %25
31: ; preds = %25, %23
%32 = phi i32 [ 0, %23 ], [ %21, %25 ]
%33 = phi i32 [ -1, %23 ], [ 0, %25 ]
%34 = tail call i32 @close(i32 %32)
ret i32 %33
}