#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 */
scalar_t__ CrearDiccionario(char *);
char *Traducir(char *, char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
main() {
  char *palabras = malloc(2 * 100 * 40 * sizeof(char));
  if (palabras == NULL) {
    printf("Insuficiente memoria\n");
    return -1;
  }
  if (CrearDiccionario(palabras) == 0) {
    printf("\nNinguna palabra en el diccionario.\n");
    return 0;
  }
  printf("Inserte las palabras que quiera traducir:\n"
         "(Para terminar pulse [Ctrl]+[z].)\n");
  while (1) {
    char palabra[40], *p;
    if (fgets(palabra, 40, stdin) == NULL)
      break;
    if ((p = Traducir(palabra, palabras)) == NULL) {
      printf("Palabra no encontrada.\n");
      continue;
    }
    printf(" ===> %s\n", p);
  }
  free(palabras);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1f40,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a2 <main+0x42>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <main+0xf8>
mov    -0x10(%rbp),%rdi
call   1080 <CrearDiccionario@plt>
cmp    $0x0,%rax
jne    11cf <main+0x6f>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1258 <main+0xf8>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
jmp    1248 <main+0xe8>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <Traducir@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1231 <main+0xd1>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11dd <main+0x7d>
mov    -0x48(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11dd <main+0x7d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    $0x1f40,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1227 <main+0xb7>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <CrearDiccionario@plt>
test   %rax,%rax
je     123a <main+0xca>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e31(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rdi
mov    $0x28,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     121d <main+0xad>
mov    %rsp,%rbx
lea    0xe7f(%rip),%r15
lea    0xe22(%rip),%r12
jmp    1203 <main+0x93>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x28,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     121d <main+0xad>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <Traducir@plt>
test   %rax,%rax
jne    11e0 <main+0x70>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    11ed <main+0x7d>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1246 <main+0xd6>
lea    0xe63(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    1248 <main+0xd8>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Insuficiente memoria\0A\00"
@.str.1 = [37 x i8] c"\0ANinguna palabra en el diccionario.\0A\00"
@.str.2 = [77 x i8] c"Inserte las palabras que quiera traducir:\0A(Para terminar pulse [Ctrl]+[z].)\0A\00"
@stdin = global i32 0
@.str.3 = [24 x i8] c"Palabra no encontrada.\0A\00"
@.str.4 = [10 x i8] c" ===> %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [40 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i8* @malloc(i32 8000)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %37
10: ; preds = %0
%11 = load i8*, i8** %2
%12 = call i64 @CrearDiccionario(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %37
16: ; preds = %10
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %29, %31
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32* @fgets(i8* %19, i32 40, i32 %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
br label %34
24: ; preds = %18
%25 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%26 = load i8*, i8** %2
%27 = call i8* @Traducir(i8* %25, i8* %26)
store i8* %27, i8** %4
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %18
31: ; preds = %24
%32 = load i8*, i8** %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %32)
br label %18
34: ; preds = %23
%35 = load i8*, i8** %2
%36 = call i32 @free(i8* %35)
store i32 0, i32* %1
br label %37
37: ; preds = %34, %14, %8
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.4 = [10 x i8] c" ===> %s\0A\00"
@str = [76 x i8] c"Inserte las palabras que quiera traducir:\0A(Para terminar pulse [Ctrl]+[z].)\00"
@str.5 = [23 x i8] c"Palabra no encontrada.\00"
@str.6 = [36 x i8] c"\0ANinguna palabra en el diccionario.\00"
@str.7 = [21 x i8] c"Insuficiente memoria\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = tail call dereferenceable_or_null(8000) i8* @malloc(i32 8000)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
br label %30
6: ; preds = %0
%7 = tail call i64 @CrearDiccionario(i8* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
br label %30
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str, i64 0, i64 0))
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32* @fgets(i8* %13, i32 40, i32 %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %28, label %17
17: ; preds = %11, %24
%18 = call i8* @Traducir(i8* %13, i8* %2)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
br label %24
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* @stdin
%26 = call i32* @fgets(i8* %13, i32 40, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %17
28: ; preds = %24, %11
%29 = call i32 @free(i8* %2)
br label %30
30: ; preds = %28, %9, %4
%31 = phi i32 [ -1, %4 ], [ 0, %9 ], [ 0, %28 ]
ret i32 %31
}