#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 */
int /*<<< orphan*/ EXIT_FAILURE;
char **allocate_possibles(int /*<<< orphan*/);
int alterations(char *, char **, int);
char *better_candidate(char *, char **, int);
int deletions(char *, char **, int);
int /*<<< orphan*/ destroy_possibles(char **, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int inserts(char *, char **, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int transpositions(char *, char **, int);
char *find_corrections(char *word) {
  char **possibles = allocate_possibles(strlen(word));
  char *result;
  int index = 0;
  if (possibles == NULL) {
    fprintf(stderr, "cannot allocate the array of possibles");
    exit(EXIT_FAILURE);
  }
  index = deletions(word, possibles, index);
  index = transpositions(word, possibles, index);
  index = alterations(word, possibles, index);
  index = inserts(word, possibles, index);
  result = better_candidate(word, possibles, index);
  destroy_possibles(possibles, index);
  return result;
}


x86 assembly (clang, -O0):
<find_corrections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1040 <allocate_possibles@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f5 <find_corrections+0x55>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10b0 <deletions@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <transpositions@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <alterations@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10a0 <inserts@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <better_candidate@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <destroy_possibles@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_corrections>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <strlen@plt>
mov    %eax,%edi
call   1040 <allocate_possibles@plt>
test   %rax,%rax
je     1213 <find_corrections+0x73>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   10b0 <deletions@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <transpositions@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1080 <alterations@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   10a0 <inserts@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1090 <better_candidate@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <destroy_possibles@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"cannot allocate the array of possibles\00"
@EXIT_FAILURE = global i32 0
define i8* @find_corrections(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = call i8** @allocate_possibles(i32 %7)
store i8** %8, i8*** %3
store i32 0, i32* %5
%9 = load i8**, i8*** %3
%10 = icmp eq i8** %9, null
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = load i8**, i8*** %3
%19 = load i32, i32* %5
%20 = call i32 @deletions(i8* %17, i8** %18, i32 %19)
store i32 %20, i32* %5
%21 = load i8*, i8** %2
%22 = load i8**, i8*** %3
%23 = load i32, i32* %5
%24 = call i32 @transpositions(i8* %21, i8** %22, i32 %23)
store i32 %24, i32* %5
%25 = load i8*, i8** %2
%26 = load i8**, i8*** %3
%27 = load i32, i32* %5
%28 = call i32 @alterations(i8* %25, i8** %26, i32 %27)
store i32 %28, i32* %5
%29 = load i8*, i8** %2
%30 = load i8**, i8*** %3
%31 = load i32, i32* %5
%32 = call i32 @inserts(i8* %29, i8** %30, i32 %31)
store i32 %32, i32* %5
%33 = load i8*, i8** %2
%34 = load i8**, i8*** %3
%35 = load i32, i32* %5
%36 = call i8* @better_candidate(i8* %33, i8** %34, i32 %35)
store i8* %36, i8** %4
%37 = load i8**, i8*** %3
%38 = load i32, i32* %5
%39 = call i32 @destroy_possibles(i8** %37, i32 %38)
%40 = load i8*, i8** %4
ret i8* %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"cannot allocate the array of possibles\00"
@EXIT_FAILURE = global i32 0
define i8* @find_corrections(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i8** @allocate_possibles(i32 %2)
%4 = icmp eq i8** %3, null
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = tail call i32 @deletions(i8* %0, i8** %3, i32 0)
%12 = tail call i32 @transpositions(i8* %0, i8** %3, i32 %11)
%13 = tail call i32 @alterations(i8* %0, i8** %3, i32 %12)
%14 = tail call i32 @inserts(i8* %0, i8** %3, i32 %13)
%15 = tail call i8* @better_candidate(i8* %0, i8** %3, i32 %14)
%16 = tail call i32 @destroy_possibles(i8** %3, i32 %14)
ret i8* %15
}