#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;
double ceil(double);
int /*<<< orphan*/ close(int);
double exp(int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, double *, int);
int create_Result_file(void) {
  int i, nbVal;
  double tabR[20000], Inc;
  char *F_name;
  int fp;
  F_name = "ceil_out.ref";
  nbVal = 20000;
  Inc = exp(1);
  for (i = 0; i < nbVal; i++)
    tabR[i] = ceil((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>
movsd  %xmm0,-0x27118(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e2 <create_Result_file+0x82>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  -0x27118(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <ceil@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    1199 <create_Result_file+0x39>
mov    -0x27120(%rbp),%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
mov    0x2dff(%rip),%rax
or     (%rax),%esi
mov    0x2dee(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1080 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    1244 <create_Result_file+0xe4>
lea    0xde5(%rip),%rdi
call   1050 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1299 <create_Result_file+0x139>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1287 <create_Result_file+0x127>
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    124b <create_Result_file+0xeb>
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    $0x27140,%rsp
mov    $0x1,%edi
call   1070 <exp@plt>
movlhps %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movdqa 0xe7b(%rip),%xmm0
mov    $0x2,%ebx
nopw   0x0(%rax,%rax,1)
movdqa %xmm0,0x30(%rsp)
cvtdq2pd %xmm0,%xmm0
movapd 0x20(%rsp),%xmm1
mulpd  %xmm1,%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
call   1040 <ceil@plt>
movapd %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1040 <ceil@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movaps %xmm1,0x30(%rsp,%rbx,8)
movdqa 0x30(%rsp),%xmm0
paddd  0xe31(%rip),%xmm0
cvtdq2pd %xmm0,%xmm0
movapd 0x20(%rsp),%xmm1
mulpd  %xmm1,%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
call   1040 <ceil@plt>
movapd %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1040 <ceil@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movdqa 0x30(%rsp),%xmm0
movaps %xmm1,0x40(%rsp,%rbx,8)
paddd  0xdf8(%rip),%xmm0
add    $0x4,%rbx
cmp    $0x4e22,%rbx
jne    1190 <create_Result_file+0x30>
mov    0x2d98(%rip),%rax
mov    0x2db1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d9e(%rip),%rax
or     (%rax),%esi
lea    0xdd5(%rip),%rdi
mov    $0x1ff,%edx
call   1080 <open@plt>
test   %eax,%eax
je     1293 <create_Result_file+0x133>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
lea    (%rsp,%rbx,1),%rsi
add    $0x40,%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbx
cmp    $0x27100,%rbx
jne    1270 <create_Result_file+0x110>
jmp    12a7 <create_Result_file+0x147>
lea    0xda3(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
xor    %ebp,%ebp
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14d,%eax
add    $0x27140,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"ceil_out.ref\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 double @exp(i32 1)
%4 = insertelement <2 x double> poison, double %3, i64 0
%5 = shufflevector <2 x double> %4, <2 x double> poison, <2 x i32> zeroinitializer
br label %6
6: ; preds = %6, %0
%7 = phi i64 [ 0, %0 ], [ %21, %6 ]
%8 = phi <2 x i32> [ <i32 0, i32 1>, %0 ], [ %22, %6 ]
%9 = sitofp <2 x i32> %8 to <2 x double>
%10 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %5, <2 x double> %9, <2 x double> %5)
%11 = call <2 x double> @llvm.ceil.v2f64(<2 x double> %10)
%12 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %7
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> %11, <2 x double>* %13
%14 = or i64 %7, 2
%15 = add <2 x i32> %8, <i32 2, i32 2>
%16 = sitofp <2 x i32> %15 to <2 x double>
%17 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %5, <2 x double> %16, <2 x double> %5)
%18 = call <2 x double> @llvm.ceil.v2f64(<2 x double> %17)
%19 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %14
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> %18, <2 x double>* %20
%21 = add nuw nsw i64 %7, 4
%22 = add <2 x i32> %8, <i32 4, i32 4>
%23 = icmp eq i64 %21, 20000
br i1 %23, label %24, label %6
24: ; preds = %6
%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 = 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
}