#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;
int EXIT_SUCCESS;
int /*<<< orphan*/ *abreFichero(char *);
int /*<<< orphan*/ cierraFichero(int /*<<< orphan*/ *);
int /*<<< orphan*/ escribeFichero(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ pideDatos(int *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int);
main() {
  FILE *fichero = NULL;
  int semilla = 1, numDatos = 1;
  pideDatos(&semilla, &numDatos);
  srand(semilla);
  fichero = abreFichero("datos.txt");
  if (fichero != NULL) {
    escribeFichero(fichero, numDatos);
    if (!cierraFichero(fichero)) {
      printf("Error! al cerrar el fichero. "
             "datos.txt");
      exit(EXIT_FAILURE);
    }
  } else {
    printf("\nError al abrir el fichero. "
           "datos.txt");
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <pideDatos@plt>
mov    -0x14(%rbp),%edi
call   1040 <srand@plt>
lea    0xe6c(%rip),%rdi
call   1090 <abreFichero@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1202 <main+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <escribeFichero@plt>
mov    -0x10(%rbp),%rdi
call   1050 <cierraFichero@plt>
cmp    $0x0,%eax
jne    11fd <main+0x8d>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    121c <main+0xac>
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <pideDatos@plt>
mov    0xc(%rsp),%edi
call   1040 <srand@plt>
lea    0xe79(%rip),%rdi
call   1090 <abreFichero@plt>
test   %rax,%rax
je     11d8 <main+0x68>
mov    %rax,%rbx
mov    0x8(%rsp),%esi
mov    %rax,%rdi
call   1060 <escribeFichero@plt>
mov    %rbx,%rdi
call   1050 <cierraFichero@plt>
test   %eax,%eax
je     11e1 <main+0x71>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe48(%rip),%rdi
jmp    11e8 <main+0x78>
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"datos.txt\00"
@.str.1 = [39 x i8] c"Error! al cerrar el fichero. datos.txt\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"\0AError al abrir el fichero. datos.txt\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
store i32 1, i32* %3
store i32 1, i32* %4
%5 = call i32 @pideDatos(i32* %3, i32* %4)
%6 = load i32, i32* %3
%7 = call i32 @srand(i32 %6)
%8 = call i32* @abreFichero(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %23
11: ; preds = %0
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = call i32 @escribeFichero(i32* %12, i32 %13)
%15 = load i32*, i32** %2
%16 = call i32 @cierraFichero(i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
br label %27
23: ; preds = %0
%24 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %22
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}

LLVM IR (-O2):
@.str = [10 x i8] c"datos.txt\00"
@.str.1 = [39 x i8] c"Error! al cerrar el fichero. datos.txt\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"\0AError al abrir el fichero. datos.txt\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = call i32 @pideDatos(i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = call i32 @srand(i32 %6)
%8 = call i32* @abreFichero(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %19, label %10
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 @escribeFichero(i32* %8, i32 %11)
%13 = call i32 @cierraFichero(i32* %8)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %0
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %10
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}