#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
void rellenaFichero(char *nombreFichero, int *limite, int nEle) {
  FILE *fichero;
  int num = 0;
  int i = 0;
  if ((fichero = fopen(nombreFichero, "w")) != NULL) {
    printf("\nEl fichero %s ha sido abierto correctamente\n", nombreFichero);
  } else {
    printf("\nError. El fichero %s no se ha podido abrir\n", nombreFichero);
    exit(-1);
  }
  for (i = 0; i < nEle; i++) {
    num = limite[0] + rand() % (limite[1] + 1 - limite[0]);
    printf("\nEl numero a introducir es → %i \n", num);
    fprintf(fichero, "%i ", num);
  }
  fclose(fichero);
}


x86 assembly (clang, -O0):
<rellenaFichero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11b6 <rellenaFichero+0x56>
mov    -0x8(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d2 <rellenaFichero+0x72>
mov    -0x8(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1242 <rellenaFichero+0xe2>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rdx
sub    (%rdx),%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d9 <rellenaFichero+0x79>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rellenaFichero>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe86(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1204 <rellenaFichero+0xa4>
mov    %rax,%r15
lea    0xe70(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11ee <rellenaFichero+0x8e>
lea    0xeda(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    (%r14),%r12d
xor    %eax,%eax
call   1080 <rand@plt>
mov    0x4(%r14),%ecx
sub    (%r14),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,%ebp
add    %r12d,%ebp
lea    0xe8a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1050 <fprintf@plt>
add    $0xffffffff,%ebx
jne    11b0 <rellenaFichero+0x50>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe25(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [46 x i8] c"\0AEl fichero %s ha sido abierto correctamente\0A\00"
@.str.2 = [45 x i8] c"\0AError. El fichero %s no se ha podido abrir\0A\00"
@.str.3 = [36 x i8] c"\0AEl numero a introducir es \E2\86\92 %i \0A\00"
@.str.4 = [4 x i8] c"%i \00"
define void @rellenaFichero(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %13
store i32 0, i32* %9
br label %21
21: ; preds = %45, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %48
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = call i32 (...) @rand()
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 0
%36 = load i32, i32* %35
%37 = sub nsw i32 %33, %36
%38 = srem i32 %29, %37
%39 = add nsw i32 %28, %38
store i32 %39, i32* %8
%40 = load i32, i32* %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %7
%43 = load i32, i32* %8
%44 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %25
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %21
48: ; preds = %21
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [46 x i8] c"\0AEl fichero %s ha sido abierto correctamente\0A\00"
@.str.2 = [45 x i8] c"\0AError. El fichero %s no se ha podido abrir\0A\00"
@.str.3 = [36 x i8] c"\0AEl numero a introducir es \E2\86\92 %i \0A\00"
@.str.4 = [4 x i8] c"%i \00"
define void @rellenaFichero(i8* %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = getelementptr inbounds i32, i32* %1, i64 1
br label %14
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %9, %14
%15 = phi i32 [ 0, %9 ], [ %26, %14 ]
%16 = load i32, i32* %1
%17 = tail call i32 (...) @rand()
%18 = load i32, i32* %10
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %1
%21 = sub i32 %19, %20
%22 = srem i32 %17, %21
%23 = add nsw i32 %22, %16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%26 = add nuw nsw i32 %15, 1
%27 = icmp eq i32 %26, %2
br i1 %27, label %28, label %14
28: ; preds = %14, %6
%29 = tail call i32 @fclose(i32* %4)
ret void
}