#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*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char getchar();
int /*<<< orphan*/ mezclaNatural(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char tolower(char);
main(int argc, char *argv[]) {
  FILE *pfichero = NULL;
  char respuesta = 0, str[256];
  if (argc != 2) {
    fprintf(stderr, "Sintaxis: %s fichero", argv[0]);
    exit(-1);
  }
  if ((pfichero = fopen(argv[1], "r+")) == NULL) {
    perror(argv[1]);
    exit(-1);
  }
  mezclaNatural(pfichero);
  do {
    printf("¿Desea visualizar el fichero? (s/n)  ");
    respuesta = getchar();
    fflush(stdin);
  } while (tolower(respuesta) != 's' && tolower(respuesta) != 'n');
  if (respuesta == 's') {
    rewind(pfichero);
    while (fgets(str, 256, pfichero))
      printf("%s", str);
  }
  if (ferror(pfichero))
    perror("Error durante la lectura");
  fclose(pfichero);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1225 <main+0x55>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdea(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde1(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    125e <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <mezclaNatural@plt>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x19(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
movsbl -0x19(%rbp),%edi
call   10b0 <tolower@plt>
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x73,%ecx
mov    %al,-0x121(%rbp)
je     12c2 <main+0xf2>
movsbl -0x19(%rbp),%edi
call   10b0 <tolower@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x121(%rbp)
mov    -0x121(%rbp),%al
test   $0x1,%al
jne    1267 <main+0x97>
movsbl -0x19(%rbp),%eax
cmp    $0x73,%eax
jne    1324 <main+0x154>
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     131f <main+0x14f>
lea    -0x120(%rbp),%rsi
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12e6 <main+0x116>
jmp    1324 <main+0x154>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1343 <main+0x173>
lea    0xd04(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    12e7 <main+0x117>
mov    0x8(%rbx),%rdi
lea    0xe1f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1309 <main+0x139>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <mezclaNatural@plt>
lea    0xe02(%rip),%r15
mov    0x2dcb(%rip),%r12
nopl   (%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%ebx
mov    (%r12),%edi
call   10c0 <fflush@plt>
movsbl %bl,%ebp
mov    %ebp,%edi
call   10b0 <tolower@plt>
cmp    $0x73,%al
je     1255 <main+0x85>
mov    %ebp,%edi
call   10b0 <tolower@plt>
cmp    $0x6e,%al
jne    1220 <main+0x50>
cmp    $0x73,%bl
jne    12b2 <main+0xe2>
mov    %r14,%rdi
call   1070 <rewind@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12b2 <main+0xe2>
lea    0xdc1(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1290 <main+0xc0>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    12d9 <main+0x109>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd62(%rip),%rdi
call   10e0 <perror@plt>
jmp    12bf <main+0xef>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd06(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    0x8(%rbx),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Sintaxis: %s fichero\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [39 x i8] c"\C2\BFDesea visualizar el fichero? (s/n) \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [25 x i8] c"Error durante la lectura\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i8 0, i8* %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @perror(i8* %27)
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %18
%31 = load i32*, i32** %6
%32 = call i32 @mezclaNatural(i32* %31)
br label %33
33: ; preds = %48, %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%35 = call signext i8 (...) @getchar()
store i8 %35, i8* %7
%36 = load i32, i32* @stdin
%37 = call i32 @fflush(i32 %36)
br label %38
38: ; preds = %33
%39 = load i8, i8* %7
%40 = call signext i8 @tolower(i8 signext %39)
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 115
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = load i8, i8* %7
%45 = call signext i8 @tolower(i8 signext %44)
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 110
br label %48
48: ; preds = %43, %38
%49 = phi i1 [ false, %38 ], [ %47, %43 ]
br i1 %49, label %33, label %50
50: ; preds = %48
%51 = load i8, i8* %7
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 115
br i1 %53, label %54, label %66
54: ; preds = %50
%55 = load i32*, i32** %6
%56 = call i32 @rewind(i32* %55)
br label %57
57: ; preds = %62, %54
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%59 = load i32*, i32** %6
%60 = call i64 @fgets(i8* %58, i32 256, i32* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %57
65: ; preds = %57
br label %66
66: ; preds = %65, %50
%67 = load i32*, i32** %6
%68 = call i64 @ferror(i32* %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %70, %66
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Sintaxis: %s fichero\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [39 x i8] c"\C2\BFDesea visualizar el fichero? (s/n) \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [25 x i8] c"Error durante la lectura\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 @perror(i8* %17)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %11
%21 = tail call i32 @mezclaNatural(i32* %14)
br label %22
22: ; preds = %29, %20
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call signext i8 (...) @getchar()
%25 = load i32, i32* @stdin
%26 = tail call i32 @fflush(i32 %25)
%27 = tail call signext i8 @tolower(i8 signext %24)
%28 = icmp eq i8 %27, 115
br i1 %28, label %32, label %29
29: ; preds = %22
%30 = tail call signext i8 @tolower(i8 signext %24)
%31 = icmp eq i8 %30, 110
br i1 %31, label %32, label %22
32: ; preds = %22, %29
%33 = icmp eq i8 %24, 115
br i1 %33, label %34, label %42
34: ; preds = %32
%35 = tail call i32 @rewind(i32* %14)
%36 = call i64 @fgets(i8* %4, i32 256, i32* %14)
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34, %38
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%40 = call i64 @fgets(i8* %4, i32 256, i32* %14)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %38
42: ; preds = %38, %34, %32
%43 = call i64 @ferror(i32* %14)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
%48 = call i32 @fclose(i32* %14)
ret i32 0
}