#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 get_closeness(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void get_closest_word(char *word, char **dictionary, int n) {
  int i, closest = 0, maxscore = 0, buffer;
  for (i = 0; i < n; i++) {
    buffer = get_closeness(word, *(dictionary + i));
    if (buffer > maxscore) {
      maxscore = buffer;
      closest = i;
    }
  }
  printf("%s\n", *(dictionary + closest));
}


x86 assembly (clang, -O0):
<get_closest_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1197 <get_closest_word+0x77>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <get_closeness@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1184 <get_closest_word+0x64>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1189 <get_closest_word+0x69>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <get_closest_word+0x28>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_closest_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
xor    %r13d,%r13d
test   %edx,%edx
jle    1162 <get_closest_word+0x42>
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
nop
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
call   1040 <get_closeness@plt>
cmp    %r13d,%eax
cmovg  %ebx,%ebp
cmovg  %eax,%r13d
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <get_closest_word+0x20>
movslq %ebp,%r13
mov    (%r14,%r13,8),%rsi
lea    0xe93(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @get_closest_word(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %7
br label %11
11: ; preds = %30, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @get_closeness(i8* %16, i8* %21)
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = load i32, i32* %9
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = load i32, i32* %10
store i32 %27, i32* %9
%28 = load i32, i32* %7
store i32 %28, i32* %8
br label %29
29: ; preds = %26, %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %11
33: ; preds = %11
%34 = load i8**, i8*** %5
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @get_closest_word(i8* %0, i8** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %18, %7 ]
%9 = phi i32 [ 0, %5 ], [ %17, %7 ]
%10 = phi i32 [ 0, %5 ], [ %16, %7 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %8
%12 = load i8*, i8** %11
%13 = tail call i32 @get_closeness(i8* %0, i8* %12)
%14 = icmp sgt i32 %13, %9
%15 = trunc i64 %8 to i32
%16 = select i1 %14, i32 %15, i32 %10
%17 = select i1 %14, i32 %13, i32 %9
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = sext i32 %16 to i64
br label %22
22: ; preds = %20, %3
%23 = phi i64 [ 0, %3 ], [ %21, %20 ]
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
ret void
}