#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 */
struct Lista {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ adicionaItemNoFim(struct Lista *, int /*<<< orphan*/);
struct Lista *criaLista();
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ mostraLista(struct Lista *);
int /*<<< orphan*/ ordena(struct Lista *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strdup(char *);
int main(int argc, char **argv) {
  FILE *f;
  char palavra[16];
  struct Lista *lista;
  if (argc < 2) {
    printf("Uso: %s arquivo_de_palavras\n", argv[0]);
    return 0;
  }
  if ((f = fopen(argv[1], "r")) == NULL) {
    perror("Ao abrir o arquivo");
    return errno;
  }
  lista = criaLista();
  while (!feof(f)) {
    if (fscanf(f, "%16[a-zA-ZãÃáÁçéÉóÓúâÂíÍêÊõÕàÀ-]", palavra) > 0) {
      adicionaItemNoFim(lista, strdup(palavra));
    } else {
      fscanf(f, "%*[^a-zA-ZãÃáÁçéÉóÓúâÂíÍêÊõÕàÀ-]");
    }
  }
  fclose(f);
  ordena(lista);
  mostraLista(lista);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ef <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d1 <main+0x121>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    122e <main+0x7e>
lea    0xe07(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d1 <main+0x121>
mov    $0x0,%al
call   10c0 <criaLista@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1257 <main+0xa7>
jmp    12af <main+0xff>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
cmp    $0x0,%rax
jle    1298 <main+0xe8>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   10d0 <strdup@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1080 <adicionaItemNoFim@plt>
jmp    12aa <main+0xfa>
mov    -0x18(%rbp),%rdi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
jmp    1239 <main+0x89>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <ordena@plt>
mov    -0x38(%rbp),%rdi
call   1090 <mostraLista@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jg     11d7 <main+0x27>
mov    (%rsi),%rsi
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
xor    %r14d,%r14d
jmp    1224 <main+0x74>
mov    0x8(%rsi),%rdi
lea    0xe3b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1292 <main+0xe2>
mov    %rax,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   10c0 <criaLista@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1236 <main+0x86>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1050 <ordena@plt>
mov    %r12,%rdi
call   1090 <mostraLista@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf5(%rip),%r15
mov    %rsp,%rbp
lea    0xe20(%rip),%r13
jmp    1269 <main+0xb9>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    120c <main+0x5c>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
test   %rax,%rax
jle    1250 <main+0xa0>
mov    %rbp,%rdi
call   10d0 <strdup@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1080 <adicionaItemNoFim@plt>
jmp    125d <main+0xad>
lea    0xd86(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%r14d
jmp    1224 <main+0x74>

LLVM IR (-O0):
%struct.Lista = type { i32 }
@.str = [29 x i8] c"Uso: %s arquivo_de_palavras\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Ao abrir o arquivo\00"
@errno = global i32 0
@.str.3 = [53 x i8] c"%16[a-zA-Z\C3\A3\C3\83\C3\A1\C3\81\C3\A7\C3\A9\C3\89\C3\B3\C3\93\C3\BA\C3\A2\C3\82\C3\AD\C3\8D\C3\AA\C3\8A\C3\B5\C3\95\C3\A0\C3\80-]\00"
@.str.4 = [53 x i8] c"%*[^a-zA-Z\C3\A3\C3\83\C3\A1\C3\81\C3\A7\C3\A9\C3\89\C3\B3\C3\93\C3\BA\C3\A2\C3\82\C3\AD\C3\8D\C3\AA\C3\8A\C3\B5\C3\95\C3\A0\C3\80-]\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [16 x i8]
%8 = alloca %struct.Lista*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %3
br label %53
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @errno
store i32 %24, i32* %3
br label %53
25: ; preds = %16
%26 = call %struct.Lista* (...) @criaLista()
store %struct.Lista* %26, %struct.Lista** %8
br label %27
27: ; preds = %45, %25
%28 = load i32*, i32** %6
%29 = call i32 @feof(i32* %28)
%30 = icmp ne i32 %29, 0
%31 = xor i1 %30, true
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = load i32*, i32** %6
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%35 = call i64 (i32*, i8*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = icmp sgt i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load %struct.Lista*, %struct.Lista** %8
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%40 = call i32 @strdup(i8* %39)
%41 = call i32 @adicionaItemNoFim(%struct.Lista* %38, i32 %40)
br label %45
42: ; preds = %32
%43 = load i32*, i32** %6
%44 = call i64 (i32*, i8*, ...) @fscanf(i32* %43, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %42, %37
br label %27
46: ; preds = %27
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
%49 = load %struct.Lista*, %struct.Lista** %8
%50 = call i32 @ordena(%struct.Lista* %49)
%51 = load %struct.Lista*, %struct.Lista** %8
%52 = call i32 @mostraLista(%struct.Lista* %51)
store i32 0, i32* %3
br label %53
53: ; preds = %46, %22, %11
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
%struct.Lista = type { i32 }
@.str = [29 x i8] c"Uso: %s arquivo_de_palavras\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Ao abrir o arquivo\00"
@errno = global i32 0
@.str.3 = [53 x i8] c"%16[a-zA-Z\C3\A3\C3\83\C3\A1\C3\81\C3\A7\C3\A9\C3\89\C3\B3\C3\93\C3\BA\C3\A2\C3\82\C3\AD\C3\8D\C3\AA\C3\8A\C3\B5\C3\95\C3\A0\C3\80-]\00"
@.str.4 = [53 x i8] c"%*[^a-zA-Z\C3\A3\C3\83\C3\A1\C3\81\C3\A7\C3\A9\C3\89\C3\B3\C3\93\C3\BA\C3\A2\C3\82\C3\AD\C3\8D\C3\AA\C3\8A\C3\B5\C3\95\C3\A0\C3\80-]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %36
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @errno
br label %36
17: ; preds = %9
%18 = tail call %struct.Lista* (...) @criaLista()
%19 = call i32 @feof(i32* %12)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %17, %29
%22 = call i64 (i32*, i8*, ...) @fscanf(i32* %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 @strdup(i8* %4)
%26 = call i32 @adicionaItemNoFim(%struct.Lista* %18, i32 %25)
br label %29
27: ; preds = %21
%28 = call i64 (i32*, i8*, ...) @fscanf(i32* %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = call i32 @feof(i32* %12)
%31 = icmp eq i32 %30, 0
br i1 %31, label %21, label %32
32: ; preds = %29, %17
%33 = call i32 @fclose(i32* %12)
%34 = call i32 @ordena(%struct.Lista* %18)
%35 = call i32 @mostraLista(%struct.Lista* %18)
br label %36
36: ; preds = %32, %14, %6
%37 = phi i32 [ 0, %6 ], [ %16, %14 ], [ 0, %32 ]
ret i32 %37
}