#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int find_in_unsorted_vocabulary(char **, int, char *);
int /*<<< orphan*/ *fopen(char *, char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int read_string(int /*<<< orphan*/ *, char *);
char **realloc(char **, int);
int /*<<< orphan*/ strcpy(char *, char *);
int load_phonemes_vocabulary(char *file_name, char ***phonemes_vocabulary) {
  int i, buffer_size = 0, vocabulary_size = 0;
  char buffer[1001];
  char **temp_vocabulary;
  FILE *vocabulary_file = NULL;
  if (phonemes_vocabulary == NULL) {
    return 0;
  }
  *phonemes_vocabulary = NULL;
  vocabulary_file = fopen(file_name, "r");
  if (vocabulary_file == NULL) {
    return 0;
  }
  while (!feof(vocabulary_file)) {
    buffer_size = read_string(vocabulary_file, buffer);
    if (buffer_size <= 0) {
      continue;
    }
    i = find_in_unsorted_vocabulary(*phonemes_vocabulary, vocabulary_size,
                                    buffer);
    if (i < 0) {
      *phonemes_vocabulary =
          realloc(*phonemes_vocabulary, (vocabulary_size + 1) * sizeof(char *));
      temp_vocabulary = *phonemes_vocabulary;
      i = vocabulary_size;
      temp_vocabulary[i] = malloc((buffer_size + 1) * sizeof(char));
      memset(temp_vocabulary[i], 0, (buffer_size + 1) * sizeof(char));
      strcpy(temp_vocabulary[i], buffer);
      vocabulary_size++;
    }
  }
  fclose(vocabulary_file);
  return vocabulary_size;
}


x86 assembly (clang, -O0):
<load_phonemes_vocabulary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x420(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d3 <load_phonemes_vocabulary+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1339 <load_phonemes_vocabulary+0x1a9>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    120f <load_phonemes_vocabulary+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1339 <load_phonemes_vocabulary+0x1a9>
jmp    1214 <load_phonemes_vocabulary+0x84>
mov    -0x420(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1235 <load_phonemes_vocabulary+0xa5>
jmp    1327 <load_phonemes_vocabulary+0x197>
mov    -0x420(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   10b0 <read_string@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     125a <load_phonemes_vocabulary+0xca>
jmp    1214 <load_phonemes_vocabulary+0x84>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%esi
lea    -0x410(%rbp),%rdx
call   1070 <find_in_unsorted_vocabulary@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1322 <load_phonemes_vocabulary+0x192>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x418(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x418(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x418(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x418(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1214 <load_phonemes_vocabulary+0x84>
mov    -0x420(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_phonemes_vocabulary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
xor    %r14d,%r14d
test   %rsi,%rsi
je     126c <load_phonemes_vocabulary+0xdc>
mov    %rsi,%r15
movq   $0x0,(%rsi)
lea    0xe42(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     126c <load_phonemes_vocabulary+0xdc>
mov    %rax,%rbx
xor    %r14d,%r14d
lea    0x10(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1264 <load_phonemes_vocabulary+0xd4>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <read_string@plt>
test   %eax,%eax
jle    11e0 <load_phonemes_vocabulary+0x50>
mov    %eax,%ebp
mov    (%r15),%rdi
mov    %r14d,%esi
mov    %r12,%rdx
call   1070 <find_in_unsorted_vocabulary@plt>
test   %eax,%eax
jns    11e0 <load_phonemes_vocabulary+0x50>
mov    (%r15),%rdi
lea    0x1(%r14),%eax
mov    %eax,0xc(%rsp)
lea    0x8(,%r14,8),%esi
call   1090 <realloc@plt>
mov    %rax,%r13
mov    %rax,(%r15)
add    $0x1,%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %r14d,%r14d
mov    %rax,0x0(%r13,%r14,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
mov    0x0(%r13,%r14,8),%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%eax
mov    %eax,%r14d
jmp    11e0 <load_phonemes_vocabulary+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @load_phonemes_vocabulary(i8* %0, i8*** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8***
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1001 x i8]
%10 = alloca i8**
%11 = alloca i32*
store i8* %0, i8** %4
store i8*** %1, i8**** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32* null, i32** %11
%12 = load i8***, i8**** %5
%13 = icmp eq i8*** %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %91
15: ; preds = %2
%16 = load i8***, i8**** %5
store i8** null, i8*** %16
%17 = load i8*, i8** %4
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %11
%19 = load i32*, i32** %11
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %3
br label %91
22: ; preds = %15
br label %23
23: ; preds = %86, %34, %22
%24 = load i32*, i32** %11
%25 = call i32 @feof(i32* %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %28, label %87
28: ; preds = %23
%29 = load i32*, i32** %11
%30 = getelementptr inbounds [1001 x i8], [1001 x i8]* %9, i64 0, i64 0
%31 = call i32 @read_string(i32* %29, i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %28
br label %23
35: ; preds = %28
%36 = load i8***, i8**** %5
%37 = load i8**, i8*** %36
%38 = load i32, i32* %8
%39 = getelementptr inbounds [1001 x i8], [1001 x i8]* %9, i64 0, i64 0
%40 = call i32 @find_in_unsorted_vocabulary(i8** %37, i32 %38, i8* %39)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %86
43: ; preds = %35
%44 = load i8***, i8**** %5
%45 = load i8**, i8*** %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = mul i64 %48, 8
%50 = trunc i64 %49 to i32
%51 = call i8** @realloc(i8** %45, i32 %50)
%52 = load i8***, i8**** %5
store i8** %51, i8*** %52
%53 = load i8***, i8**** %5
%54 = load i8**, i8*** %53
store i8** %54, i8*** %10
%55 = load i32, i32* %8
store i32 %55, i32* %6
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 1
%60 = trunc i64 %59 to i32
%61 = call i8* @malloc(i32 %60)
%62 = load i8**, i8*** %10
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
store i8* %61, i8** %65
%66 = load i8**, i8*** %10
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = mul i64 %73, 1
%75 = trunc i64 %74 to i32
%76 = call i32 @memset(i8* %70, i32 0, i32 %75)
%77 = load i8**, i8*** %10
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = getelementptr inbounds [1001 x i8], [1001 x i8]* %9, i64 0, i64 0
%83 = call i32 @strcpy(i8* %81, i8* %82)
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %86
86: ; preds = %43, %35
br label %23
87: ; preds = %23
%88 = load i32*, i32** %11
%89 = call i32 @fclose(i32* %88)
%90 = load i32, i32* %8
store i32 %90, i32* %3
br label %91
91: ; preds = %87, %21, %14
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @load_phonemes_vocabulary(i8* nocapture %0, i8*** %1) {
%3 = alloca [1001 x i8]
%4 = getelementptr inbounds [1001 x i8], [1001 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8*** %1, null
br i1 %5, label %36, label %6
6: ; preds = %2
store i8** null, i8*** %1
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %36, label %9
9: ; preds = %6, %22
%10 = phi i32 [ %24, %22 ], [ 0, %6 ]
br label %11
11: ; preds = %9, %18
br label %12
12: ; preds = %11, %15
%13 = call i32 @feof(i32* %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = call i32 @read_string(i32* %7, i8* %4)
%17 = icmp slt i32 %16, 1
br i1 %17, label %12, label %18
18: ; preds = %15
%19 = load i8**, i8*** %1
%20 = call i32 @find_in_unsorted_vocabulary(i8** %19, i32 %10, i8* %4)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %18
%23 = load i8**, i8*** %1
%24 = add nuw nsw i32 %10, 1
%25 = shl i32 %24, 3
%26 = call i8** @realloc(i8** %23, i32 %25)
store i8** %26, i8*** %1
%27 = add nuw nsw i32 %16, 1
%28 = call i8* @malloc(i32 %27)
%29 = zext i32 %10 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
store i8* %28, i8** %30
%31 = call i32 @memset(i8* %28, i32 0, i32 %27)
%32 = load i8*, i8** %30
%33 = call i32 @strcpy(i8* %32, i8* %4)
br label %9
34: ; preds = %12
%35 = call i32 @fclose(i32* %7)
br label %36
36: ; preds = %6, %2, %34
%37 = phi i32 [ %10, %34 ], [ 0, %2 ], [ 0, %6 ]
ret i32 %37
}