#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
char fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char dizionario[100][80 + 1];
  char parola[80 + 1];
  int indice;
  FILE *fp1, *fp2;
  char c;
  if ((fp1 = fopen("dizionario.txt", "r")) == NULL) {
    fprintf(stderr, "Impossibile aprire il file %s\n", "dizionario.txt");
    return -1;
  }
  while (fscanf(fp1, "%d %s", &indice, parola) != EOF)
    strcpy(dizionario[indice], parola);
  fclose(fp1);
  if ((fp1 = fopen("codificato.txt", "r")) == NULL) {
    fprintf(stderr, "Impossibile aprire il file %s\n", "codificato.txt");
    return -2;
  }
  if ((fp2 = fopen("decodificato.txt", "w")) == NULL) {
    fprintf(stderr, "Impossibile aprire il file %s\n", "decodificato.txt");
    return -3;
  }
  while ((c = fgetc(fp1)) != EOF) {
    if (c != '$')
      fputc(c, fp2);
    else {
      fscanf(fp1, "%d", &indice);
      fprintf(fp2, "%s", dizionario[indice]);
    }
  }
  fclose(fp1);
  fclose(fp2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
jne    11d6 <main+0x66>
mov    0x2e24(%rip),%rax
mov    (%rax),%rdi
lea    0xe53(%rip),%rsi
lea    0xe3b(%rip),%rdx
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    139d <main+0x22d>
jmp    11db <main+0x6b>
mov    -0x2030(%rbp),%rdi
lea    -0x2020(%rbp),%rcx
lea    0xe40(%rip),%rsi
lea    -0x2024(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movsbl %al,%eax
mov    0x2de0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1239 <main+0xc9>
movslq -0x2024(%rbp),%rax
lea    -0x1fc0(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
lea    -0x2020(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11db <main+0x6b>
mov    -0x2030(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdec(%rip),%rdi
lea    0xdbc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
jne    1292 <main+0x122>
mov    0x2d68(%rip),%rax
mov    (%rax),%rdi
lea    0xd97(%rip),%rsi
lea    0xdb7(%rip),%rdx
call   1080 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    139d <main+0x22d>
lea    0xd9d(%rip),%rdi
lea    0xda7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x2038(%rbp)
cmp    $0x0,%rax
jne    12df <main+0x16f>
mov    0x2d1b(%rip),%rax
mov    (%rax),%rdi
lea    0xd4a(%rip),%rsi
lea    0xd68(%rip),%rdx
call   1080 <fprintf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    139d <main+0x22d>
jmp    12e4 <main+0x174>
mov    -0x2030(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x2039(%rbp)
movsbl %al,%eax
mov    0x2ce8(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     137e <main+0x20e>
movsbl -0x2039(%rbp),%eax
cmp    $0x24,%eax
je     1335 <main+0x1c5>
mov    -0x2039(%rbp),%al
mov    -0x2038(%rbp),%rsi
movsbl %al,%edi
call   1070 <fputc@plt>
jmp    1379 <main+0x209>
mov    -0x2030(%rbp),%rdi
lea    0xd06(%rip),%rsi
lea    -0x2024(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x2038(%rbp),%rdi
movslq -0x2024(%rbp),%rax
lea    -0x1fc0(%rbp),%rdx
imul   $0x51,%rax,%rax
add    %rax,%rdx
lea    0xcbf(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12e4 <main+0x174>
mov    -0x2030(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x2038(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2020,%rsp
lea    0xe69(%rip),%rdi
lea    0xe71(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     128a <main+0x10a>
mov    %rax,%r14
lea    0xe7a(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x2e17(%rip),%r13
cmp    0x0(%r13),%al
je     1226 <main+0xa6>
lea    0x10(%rsp),%rbx
lea    0xe4d(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax,%rax,1)
movslq 0xc(%rsp),%rax
lea    (%rax,%rax,8),%rax
lea    (%rax,%rax,8),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x70,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <fscanf@plt>
cmp    0x0(%r13),%al
jne    11f0 <main+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xe03(%rip),%rdi
lea    0xdd3(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12ae <main+0x12e>
mov    %rax,%rbx
lea    0xde6(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12d2 <main+0x152>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    0x0(%r13),%al
jne    1305 <main+0x185>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12f4 <main+0x174>
mov    0x2d47(%rip),%rax
mov    (%rax),%rdi
lea    0xd76(%rip),%rsi
lea    0xd5e(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    12f4 <main+0x174>
mov    0x2d23(%rip),%rax
mov    (%rax),%rdi
lea    0xd52(%rip),%rsi
lea    0xd72(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0xfffffffe,%eax
jmp    12f4 <main+0x174>
mov    0x2cff(%rip),%rax
mov    (%rax),%rdi
lea    0xd2e(%rip),%rsi
lea    0xd4c(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0xfffffffd,%eax
add    $0x2020,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd3d(%rip),%r15
lea    0xc(%rsp),%r12
jmp    135f <main+0x1df>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
movslq 0xc(%rsp),%rax
lea    (%rax,%rax,8),%rax
lea    (%rax,%rax,8),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x70,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    0x0(%r13),%al
je     1276 <main+0xf6>
cmp    $0x24,%al
je     1320 <main+0x1a0>
movsbl %al,%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
jmp    134d <main+0x1cd>

LLVM IR (-O0):
@.str = [15 x i8] c"dizionario.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32* null
@.str.2 = [31 x i8] c"Impossibile aprire il file %s\0A\00"
@.str.3 = [6 x i8] c"%d %s\00"
@EOF = global i8 0
@.str.4 = [15 x i8] c"codificato.txt\00"
@.str.5 = [17 x i8] c"decodificato.txt\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x [81 x i8]]
%7 = alloca [81 x i8]
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %9
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32*, i32** @stderr
%16 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %78
17: ; preds = %2
br label %18
18: ; preds = %26, %17
%19 = load i32*, i32** %9
%20 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%21 = call signext i8 (i32*, i8*, i32*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %8, i8* %20)
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %33
26: ; preds = %18
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %6, i64 0, i64 %28
%30 = getelementptr inbounds [81 x i8], [81 x i8]* %29, i64 0, i64 0
%31 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%32 = call i32 @strcpy(i8* %30, i8* %31)
br label %18
33: ; preds = %18
%34 = load i32*, i32** %9
%35 = call i32 @fclose(i32* %34)
%36 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %9
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32*, i32** @stderr
%40 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 -2, i32* %3
br label %78
41: ; preds = %33
%42 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %42, i32** %10
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32*, i32** @stderr
%46 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 -3, i32* %3
br label %78
47: ; preds = %41
br label %48
48: ; preds = %72, %47
%49 = load i32*, i32** %9
%50 = call signext i8 @fgetc(i32* %49)
store i8 %50, i8* %11
%51 = sext i8 %50 to i32
%52 = load i8, i8* @EOF
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %51, %53
br i1 %54, label %55, label %73
55: ; preds = %48
%56 = load i8, i8* %11
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 36
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i8, i8* %11
%61 = load i32*, i32** %10
%62 = call i32 @fputc(i8 signext %60, i32* %61)
br label %72
63: ; preds = %55
%64 = load i32*, i32** %9
%65 = call signext i8 (i32*, i8*, i32*, ...) @fscanf(i32* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %8)
%66 = load i32*, i32** %10
%67 = load i32, i32* %8
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %6, i64 0, i64 %68
%70 = getelementptr inbounds [81 x i8], [81 x i8]* %69, i64 0, i64 0
%71 = call i32 @fprintf(i32* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %63, %59
br label %48
73: ; preds = %48
%74 = load i32*, i32** %9
%75 = call i32 @fclose(i32* %74)
%76 = load i32*, i32** %10
%77 = call i32 @fclose(i32* %76)
store i32 0, i32* %3
br label %78
78: ; preds = %73, %44, %38, %14
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
@.str = [15 x i8] c"dizionario.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32* null
@.str.2 = [31 x i8] c"Impossibile aprire il file %s\0A\00"
@.str.3 = [6 x i8] c"%d %s\00"
@EOF = global i8 0
@.str.4 = [15 x i8] c"codificato.txt\00"
@.str.5 = [17 x i8] c"decodificato.txt\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x [81 x i8]]
%4 = alloca [81 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %3, i64 0, i64 0, i64 0
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = call signext i8 (i32*, i8*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %5, i8* %7)
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %26, label %18
15: ; preds = %2
%16 = load i32*, i32** @stderr
%17 = tail call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %61
18: ; preds = %11, %18
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %3, i64 0, i64 %20, i64 0
%22 = call i32 @strcpy(i8* %21, i8* %7)
%23 = call signext i8 (i32*, i8*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %5, i8* %7)
%24 = load i8, i8* @EOF
%25 = icmp eq i8 %23, %24
br i1 %25, label %26, label %18
26: ; preds = %18, %11
%27 = call i32 @fclose(i32* %9)
%28 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32*, i32** @stderr
%32 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %61
33: ; preds = %26
%34 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %40, label %36
36: ; preds = %33
%37 = call signext i8 @fgetc(i32* %28)
%38 = load i8, i8* @EOF
%39 = icmp eq i8 %37, %38
br i1 %39, label %58, label %43
40: ; preds = %33
%41 = load i32*, i32** @stderr
%42 = call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %61
43: ; preds = %36, %54
%44 = phi i8 [ %55, %54 ], [ %37, %36 ]
%45 = icmp eq i8 %44, 36
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @fputc(i8 signext %44, i32* %34)
br label %54
48: ; preds = %43
%49 = call signext i8 (i32*, i8*, i32*, ...) @fscanf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x [81 x i8]], [100 x [81 x i8]]* %3, i64 0, i64 %51, i64 0
%53 = call i32 @fputs(i8* %52, i32* %34)
br label %54
54: ; preds = %48, %46
%55 = call signext i8 @fgetc(i32* %28)
%56 = load i8, i8* @EOF
%57 = icmp eq i8 %55, %56
br i1 %57, label %58, label %43
58: ; preds = %54, %36
%59 = call i32 @fclose(i32* %28)
%60 = call i32 @fclose(i32* %34)
br label %61
61: ; preds = %58, %40, %30, %15
%62 = phi i32 [ -1, %15 ], [ -2, %30 ], [ -3, %40 ], [ 0, %58 ]
ret i32 %62
}