#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
double RAND_MAX;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
double rand();
int /*<<< orphan*/ stderr;
scalar_t__ strerror(int /*<<< orphan*/);
void CreaFile(void) {
  FILE *fp;
  int vett[20];
  int i;
  if ((fp = fopen("inputFile.txt", "w+")) == NULL) {
    fprintf(stderr, "%s- creazione file di input", (char *)strerror(errno));
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 20; i++) {
    vett[i] = 20 * (1.0 * rand() / RAND_MAX);
    fprintf(fp, "%d\n", vett[i]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<CreaFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xea1(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11c8 <CreaFile+0x68>
mov    0x2e48(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    1237 <CreaFile+0xd7>
mov    $0x0,%al
call   1080 <rand@plt>
movsd  0xe20(%rip),%xmm1
mulsd  %xmm0,%xmm1
mov    0x2df5(%rip),%rax
divsd  (%rax),%xmm1
movsd  0xe01(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movslq -0x64(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x8(%rbp),%rdi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11cf <CreaFile+0x6f>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreaFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe9a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11dc <CreaFile+0x7c>
mov    %rax,%rbx
mov    $0x14,%ebp
mov    0x2e5a(%rip),%r15
lea    0xea0(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <rand@plt>
divsd  (%r15),%xmm0
mulsd  0xe4c(%rip),%xmm0
cvttsd2si %xmm0,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11a0 <CreaFile+0x40>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
mov    0x2df5(%rip),%rax
movslq (%rax),%rbx
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"inputFile.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s- creazione file di input\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@RAND_MAX = global double 0.000000e+00
@.str.3 = [4 x i8] c"%d\0A\00"
define void @CreaFile() {
%1 = alloca i32*
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = load i32, i32* @errno
%11 = call i64 @strerror(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %0
store i32 0, i32* %3
br label %17
17: ; preds = %36, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 20
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = call double (...) @rand()
%22 = fmul double 1.000000e+00, %21
%23 = load double, double* @RAND_MAX
%24 = fdiv double %22, %23
%25 = fmul double 2.000000e+01, %24
%26 = fptosi double %25 to i32
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %28
store i32 %26, i32* %29
%30 = load i32*, i32** %1
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %20
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %17
39: ; preds = %17
%40 = load i32*, i32** %1
%41 = call i32 @fclose(i32* %40)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"inputFile.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s- creazione file di input\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@RAND_MAX = global double 0.000000e+00
@.str.3 = [4 x i8] c"%d\0A\00"
define void @CreaFile() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i32*
%7 = load i32, i32* @errno
%8 = tail call i64 @strerror(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0, %13
%14 = phi i32 [ %21, %13 ], [ 0, %0 ]
%15 = tail call double (...) @rand()
%16 = load double, double* @RAND_MAX
%17 = fdiv double %15, %16
%18 = fmul double %17, 2.000000e+01
%19 = fptosi double %18 to i32
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i32 %14, 1
%22 = icmp eq i32 %21, 20
br i1 %22, label %23, label %13
23: ; preds = %13
%24 = tail call i32 @fclose(i32* %1)
ret void
}