#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 */

/* Variables and functions */
int /*<<< orphan*/ codificarF(char *, char *, char *);
int /*<<< orphan*/ crearAlfabero(char *);
int /*<<< orphan*/ decodificarF(char *, char *, char *);
int getint(char *);
int /*<<< orphan*/ leerTexto(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
scalar_t__ yesNo(char *);
int main(void) {
  srand(time(0));
  static char alfabeto[26];
  char codificar[100];
  char salida[100];
  int opcion;
  crearAlfabero(alfabeto);
  do {
    printf("Introducir el texto:\n");
    leerTexto(codificar);
    do {
      printf("\nQue desea hacer?\n1) Codificar\n2) Decodificar\n");
      switch (opcion = getint("Opcion: ")) {
      case 1:
        codificarF(codificar, alfabeto, salida);
        break;
      case 2:
        decodificarF(codificar, alfabeto, salida);
        break;
      case 3:
        return 1;
      default:
        printf("Opcion incorrecta.\n");
        break;
      }
    } while (opcion != 1 && opcion != 2);
    printf("%s", codificar);
    printf("\n");
    printf("%s", salida);
    printf("\n");
  } while (yesNo("Seguir? "));
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0x2ec9(%rip),%rdi
call   1030 <crearAlfabero@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   10b0 <leerTexto@plt>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1060 <getint@plt>
mov    %eax,-0xe4(%rbp)
mov    %eax,%ecx
mov    %ecx,-0xe8(%rbp)
sub    $0x1,%eax
je     1231 <main+0xa1>
jmp    1209 <main+0x79>
mov    -0xe8(%rbp),%eax
sub    $0x2,%eax
je     124d <main+0xbd>
jmp    121d <main+0x8d>
mov    -0xe8(%rbp),%eax
sub    $0x3,%eax
je     1269 <main+0xd9>
jmp    1275 <main+0xe5>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    0x2e3d(%rip),%rsi
call   1050 <codificarF@plt>
jmp    1283 <main+0xf3>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    0x2e21(%rip),%rsi
call   10a0 <decodificarF@plt>
jmp    1283 <main+0xf3>
movl   $0x1,-0x4(%rbp)
jmp    131b <main+0x18b>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1288 <main+0xf8>
xor    %eax,%eax
cmpl   $0x1,-0xe4(%rbp)
mov    %al,-0xe9(%rbp)
je     12ad <main+0x11d>
cmpl   $0x2,-0xe4(%rbp)
setne  %al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
test   $0x1,%al
jne    11d3 <main+0x43>
lea    -0x70(%rbp),%rsi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd60(%rip),%rdi
call   1080 <yesNo@plt>
cmp    $0x0,%rax
jne    11bc <main+0x2c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
lea    0x2eba(%rip),%rdi
call   1050 <crearAlfabero@plt>
lea    0x70(%rsp),%r12
lea    0xe43(%rip),%r13
lea    0xe12(%rip),%rbx
mov    %rsp,%rbp
lea    0xe11(%rip),%r14
lea    0xe59(%rip),%r15
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   10d0 <leerTexto@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <getint@plt>
cmp    $0x3,%eax
je     12c5 <main+0x115>
cmp    $0x2,%eax
je     1250 <main+0xa0>
cmp    $0x1,%eax
je     1270 <main+0xc0>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    1220 <main+0x70>
nopl   (%rax)
mov    %r12,%rdi
lea    0x2e36(%rip),%rsi
mov    %rbp,%rdx
call   10c0 <decodificarF@plt>
jmp    1282 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
lea    0x2e16(%rip),%rsi
mov    %rbp,%rdx
call   1070 <codificarF@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd55(%rip),%rdi
call   10a0 <yesNo@plt>
test   %rax,%rax
jne    11ff <main+0x4f>
mov    $0x1,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.alfabeto = internal global [26 x i8] zeroinitializer
@.str = [22 x i8] c"Introducir el texto:\0A\00"
@.str.1 = [47 x i8] c"\0AQue desea hacer?\0A1) Codificar\0A2) Decodificar\0A\00"
@.str.2 = [9 x i8] c"Opcion: \00"
@.str.3 = [20 x i8] c"Opcion incorrecta.\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [9 x i8] c"Seguir? \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32 0)
%6 = call i32 @srand(i32 %5)
%7 = call i32 @crearAlfabero(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0))
br label %8
8: ; preds = %42, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @leerTexto(i8* %10)
br label %12
12: ; preds = %33, %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @getint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 %14, i32* %4
switch i32 %14, label %24 [
i32 1, label %15
i32 2, label %19
i32 3, label %23
]
15: ; preds = %12
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%18 = call i32 @codificarF(i8* %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0), i8* %17)
br label %26
19: ; preds = %12
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = call i32 @decodificarF(i8* %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0), i8* %21)
br label %26
23: ; preds = %12
store i32 1, i32* %1
br label %46
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %19, %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 2
br label %33
33: ; preds = %30, %27
%34 = phi i1 [ false, %27 ], [ %32, %30 ]
br i1 %34, label %12, label %35
35: ; preds = %33
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %35
%43 = call i64 @yesNo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp ne i64 %43, 0
br i1 %44, label %8, label %45
45: ; preds = %42
store i32 1, i32* %1
br label %46
46: ; preds = %45, %23
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@main.alfabeto = internal global [26 x i8] zeroinitializer
@.str.2 = [9 x i8] c"Opcion: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.6 = [9 x i8] c"Seguir? \00"
@str = [21 x i8] c"Introducir el texto:\00"
@str.7 = [46 x i8] c"\0AQue desea hacer?\0A1) Codificar\0A2) Decodificar\00"
@str.8 = [19 x i8] c"Opcion incorrecta.\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = tail call i32 @crearAlfabero(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0))
br label %8
8: ; preds = %20, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = call i32 @leerTexto(i8* %5)
br label %11
11: ; preds = %18, %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.7, i64 0, i64 0))
%13 = call i32 @getint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
switch i32 %13, label %18 [
i32 1, label %14
i32 2, label %16
i32 3, label %27
]
14: ; preds = %11
%15 = call i32 @codificarF(i8* %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0), i8* %6)
br label %20
16: ; preds = %11
%17 = call i32 @decodificarF(i8* %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @main.alfabeto, i64 0, i64 0), i8* %6)
br label %20
18: ; preds = %11
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
br label %11
20: ; preds = %14, %16
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%22 = call i32 @putchar(i32 10)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%24 = call i32 @putchar(i32 10)
%25 = call i64 @yesNo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %8
27: ; preds = %20, %11
ret i32 1
}