#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char toupper(char);
minMayus(char *nombre, char *cadena) {
  int i = 0;
  FILE *fichero;
  FILE *ficheroMayus;
  char nombreSalida[50] = "mayusculas-";
  strcat(nombreSalida, nombre);
  char aux[strlen(cadena)];
  char c;
  printf("\nEl nombre de fichero de salida es → %s\n", nombreSalida);
  if ((fichero = fopen(nombre, "r")) == NULL) {
    printf("\nError al abrir el fichero %s\n", nombre);
    exit(-1);
  } else {
    printf("\nEl fichero %s se ha abierto correctamente \n", nombre);
  }
  while (fgets(aux, 100, fichero) != NULL) {
    if (aux[strlen(aux) - 1] == '\n') {
      cadena[strlen(cadena) - 1] = '\0';
    }
  }
  printf("\nLa cadena es: %s\n", aux);
  for (i = 0; i < (strlen(aux)); i++) {
    aux[i] = toupper(aux[i]);
  }
  if ((ficheroMayus = fopen(nombreSalida, "w")) == NULL) {
    printf("\nError al abrir el fichero %s\n", nombreSalida);
    exit(-1);
  } else {
    printf("\nEl fichero %s se ha abierto correctamente \n", nombreSalida);
  }
  fputs(aux, ficheroMayus);
  fclose(fichero);
  fclose(ficheroMayus);
}


x86 assembly (clang, -O0):
<minMayus>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movaps 0xe6f(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movaps 0xe54(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
movaps 0xe39(%rip),%xmm0
movaps %xmm0,-0x70(%rbp)
movw   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x70(%rbp),%rdi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe18(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1257 <minMayus+0xc7>
mov    -0x10(%rbp),%rsi
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1060 <printf@plt>
jmp    126c <minMayus+0xdc>
mov    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x64,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     12df <minMayus+0x14f>
mov    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12da <minMayus+0x14a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    126c <minMayus+0xdc>
mov    -0x90(%rbp),%rsi
lea    0xdbe(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cmp    %ecx,%eax
jge    1350 <minMayus+0x1c0>
mov    -0x90(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x90(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f9 <minMayus+0x169>
lea    -0x70(%rbp),%rdi
lea    0xd63(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1388 <minMayus+0x1f8>
lea    -0x70(%rbp),%rsi
lea    0xce6(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
lea    -0x70(%rbp),%rsi
lea    0xceb(%rip),%rdi
call   1060 <printf@plt>
mov    -0x90(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <fputs@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minMayus>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
movaps 0xe72(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0xe57(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movaps 0xe3c(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
movw   $0x0,-0x30(%rbp)
lea    -0x60(%rbp),%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   10a0 <strcat@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rbx
mov    %eax,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0xe30(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
lea    0xe4c(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1318 <minMayus+0x188>
mov    %rax,%r14
lea    0xe52(%rip),%rdi
mov    %r12,%rsi
call   1060 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1279 <minMayus+0xe9>
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r13,1)
jne    1240 <minMayus+0xb0>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
jmp    1240 <minMayus+0xb0>
mov    %rbx,%r12
lea    0xe28(%rip),%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    12c3 <minMayus+0x133>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl 0x0(%r13,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     12a0 <minMayus+0x110>
lea    0xdf4(%rip),%rsi
lea    -0x60(%rbp),%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1324 <minMayus+0x194>
mov    %rax,%r15
lea    0xd9c(%rip),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1070 <fputs@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd40(%rip),%rdi
mov    %r12,%rsi
jmp    132f <minMayus+0x19f>
lea    0xd34(%rip),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.minMayus.nombreSalida = [50 x i8] c"mayusculas-\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [43 x i8] c"\0AEl nombre de fichero de salida es \E2\86\92 %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"\0AError al abrir el fichero %s\0A\00"
@.str.3 = [45 x i8] c"\0AEl fichero %s se ha abierto correctamente \0A\00"
@.str.4 = [19 x i8] c"\0ALa cadena es: %s\0A\00"
@.str.5 = [2 x i8] c"w\00"
define i32 @minMayus(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [50 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%13 = bitcast [50 x i8]* %9 to i8*
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %10
%21 = alloca i8, i64 %19
store i64 %19, i64* %11
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %4
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %7
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %2
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %2
%32 = load i8*, i8** %4
%33 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31
br label %35
35: ; preds = %54, %34
%36 = load i32*, i32** %7
%37 = call i32* @fgets(i8* %21, i32 100, i32* %36)
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = call i32 @strlen(i8* %21)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %21, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %54
47: ; preds = %39
%48 = load i8*, i8** %5
%49 = load i8*, i8** %5
%50 = call i32 @strlen(i8* %49)
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %48, i64 %52
store i8 0, i8* %53
br label %54
54: ; preds = %47, %39
br label %35
55: ; preds = %35
%56 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %21)
store i32 0, i32* %6
br label %57
57: ; preds = %70, %55
%58 = load i32, i32* %6
%59 = call i32 @strlen(i8* %21)
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %73
61: ; preds = %57
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %21, i64 %63
%65 = load i8, i8* %64
%66 = call signext i8 @toupper(i8 signext %65)
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %21, i64 %68
store i8 %66, i8* %69
br label %70
70: ; preds = %61
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %57
73: ; preds = %57
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%75 = call i32* @fopen(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %75, i32** %8
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %81
77: ; preds = %73
%78 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%79 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %78)
%80 = call i32 @exit(i32 -1)
unreachable
81: ; preds = %73
%82 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%83 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %81
%85 = load i32*, i32** %8
%86 = call i32 @fputs(i8* %21, i32* %85)
%87 = load i32*, i32** %7
%88 = call i32 @fclose(i32* %87)
%89 = load i32*, i32** %8
%90 = call i32 @fclose(i32* %89)
%91 = load i8*, i8** %10
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@__const.minMayus.nombreSalida = [50 x i8] c"mayusculas-\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [43 x i8] c"\0AEl nombre de fichero de salida es \E2\86\92 %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"\0AError al abrir el fichero %s\0A\00"
@.str.3 = [45 x i8] c"\0AEl fichero %s se ha abierto correctamente \0A\00"
@.str.4 = [19 x i8] c"\0ALa cadena es: %s\0A\00"
@.str.5 = [2 x i8] c"w\00"
define i32 @minMayus(i8* %0, i8* %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcat(i8* %4, i8* %0)
%6 = call i32 @strlen(i8* %1)
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%18 = call i32* @fgets(i8* %9, i32 100, i32* %11)
%19 = icmp eq i32* %18, null
br i1 %19, label %35, label %20
20: ; preds = %16, %32
%21 = call i32 @strlen(i8* %9)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %9, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 10
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = call i32 @strlen(i8* %1)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %1, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %27, %20
%33 = call i32* @fgets(i8* %9, i32 100, i32* %11)
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %20
35: ; preds = %32, %16
%36 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%37 = call i32 @strlen(i8* %9)
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %35, %39
%40 = phi i64 [ %44, %39 ], [ 0, %35 ]
%41 = getelementptr inbounds i8, i8* %9, i64 %40
%42 = load i8, i8* %41
%43 = call signext i8 @toupper(i8 signext %42)
store i8 %43, i8* %41
%44 = add nuw nsw i64 %40, 1
%45 = call i32 @strlen(i8* %9)
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %39, label %48
48: ; preds = %39, %35
%49 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %48
%55 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%56 = call i32 @fputs(i8* %9, i32* %49)
%57 = call i32 @fclose(i32* %11)
%58 = call i32 @fclose(i32* %49)
ret i32 undef
}