#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*/ *);
scalar_t__ find_in_unsorted_vocabulary(char **, int, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free_string_array(char ***, int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int read_string(int /*<<< orphan*/ *, char *);
char **realloc(char **, int);
int /*<<< orphan*/ select_word_and_transcription(char *, char **, char **);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int load_words_vocabulary(char *file_name, char ***words_vocabulary) {
  int i, n, buffer_size = 0, vocabulary_size = 0;
  int is_ok = 1;
  char buffer[1001];
  char *word_name = NULL, *word_transcription = NULL;
  char **temp_vocabulary;
  FILE *vocabulary_file = NULL;
  if (words_vocabulary == NULL) {
    return 0;
  }
  *words_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;
    }
    if (!select_word_and_transcription(buffer, &word_name,
                                       &word_transcription)) {
      is_ok = 0;
      break;
    }
    if (find_in_unsorted_vocabulary(*words_vocabulary, vocabulary_size,
                                    word_name) < 0) {
      *words_vocabulary =
          realloc(*words_vocabulary, (vocabulary_size + 1) * sizeof(char *));
      temp_vocabulary = *words_vocabulary;
      i = vocabulary_size;
      n = strlen(word_name);
      temp_vocabulary[i] = malloc((n + 1) * sizeof(char));
      memset(temp_vocabulary[i], 0, (n + 1) * sizeof(char));
      strcpy(temp_vocabulary[i], word_name);
      vocabulary_size++;
    }
  }
  fclose(vocabulary_file);
  if (!is_ok) {
    free_string_array(words_vocabulary, vocabulary_size);
    vocabulary_size = 0;
  }
  return vocabulary_size;
}


x86 assembly (clang, -O0):
<load_words_vocabulary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movq   $0x0,-0x428(%rbp)
movq   $0x0,-0x430(%rbp)
movq   $0x0,-0x440(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1220 <load_words_vocabulary+0x60>
movl   $0x0,-0x4(%rbp)
jmp    13de <load_words_vocabulary+0x21e>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    125c <load_words_vocabulary+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    13de <load_words_vocabulary+0x21e>
jmp    1261 <load_words_vocabulary+0xa1>
mov    -0x440(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1282 <load_words_vocabulary+0xc2>
jmp    13af <load_words_vocabulary+0x1ef>
mov    -0x440(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   10e0 <read_string@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     12a7 <load_words_vocabulary+0xe7>
jmp    1261 <load_words_vocabulary+0xa1>
lea    -0x420(%rbp),%rdi
lea    -0x428(%rbp),%rsi
lea    -0x430(%rbp),%rdx
call   10c0 <select_word_and_transcription@plt>
cmp    $0x0,%eax
jne    12d6 <load_words_vocabulary+0x116>
movl   $0x0,-0x2c(%rbp)
jmp    13af <load_words_vocabulary+0x1ef>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%esi
mov    -0x428(%rbp),%rdx
call   1080 <find_in_unsorted_vocabulary@plt>
cmp    $0x0,%rax
jge    13aa <load_words_vocabulary+0x1ea>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   10b0 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x438(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x428(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,%rdx
mov    -0x438(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x438(%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   1060 <memset@plt>
mov    -0x438(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x428(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1261 <load_words_vocabulary+0xa1>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    13d8 <load_words_vocabulary+0x218>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1090 <free_string_array@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_words_vocabulary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x28(%rsp)
xor    %r14d,%r14d
test   %rsi,%rsi
je     12f6 <load_words_vocabulary+0x136>
mov    %rsi,%r15
movq   $0x0,(%rsi)
lea    0xe00(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12f6 <load_words_vocabulary+0x136>
mov    %rax,%rbx
xor    %r14d,%r14d
lea    0x30(%rsp),%r12
lea    0x8(%rsp),%r13
lea    0x28(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    12ee <load_words_vocabulary+0x12e>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10e0 <read_string@plt>
test   %eax,%eax
jle    1230 <load_words_vocabulary+0x70>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   10c0 <select_word_and_transcription@plt>
test   %eax,%eax
je     130b <load_words_vocabulary+0x14b>
mov    (%r15),%rdi
mov    0x8(%rsp),%rdx
mov    %r14d,%esi
call   1080 <find_in_unsorted_vocabulary@plt>
test   %rax,%rax
jns    1230 <load_words_vocabulary+0x70>
mov    (%r15),%rdi
lea    0x1(%r14),%eax
mov    %eax,0x14(%rsp)
lea    0x8(,%r14,8),%esi
call   10b0 <realloc@plt>
mov    %rax,0x20(%rsp)
mov    %rax,(%r15)
mov    0x8(%rsp),%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
mov    %edi,0x10(%rsp)
call   10a0 <malloc@plt>
mov    %r14d,%ecx
mov    %rcx,0x18(%rsp)
mov    0x20(%rsp),%r14
mov    %rax,(%r14,%rcx,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    0x10(%rsp),%edx
call   1060 <memset@plt>
mov    0x18(%rsp),%rax
mov    (%r14,%rax,8),%rdi
mov    0x8(%rsp),%rsi
call   1030 <strcpy@plt>
mov    0x14(%rsp),%eax
mov    %eax,%r14d
jmp    1230 <load_words_vocabulary+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1090 <free_string_array@plt>
xor    %r14d,%r14d
jmp    12f6 <load_words_vocabulary+0x136>

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

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