#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 */
float get_closeless(char *, char *);
int get_closest_word(char *word, char **dictionary, int N) {
  float close, mclose;
  int i, index;
  mclose = get_closeless(word, dictionary[0]);
  index = 0;
  for (i = 1; i < N; i++) {
    close = get_closeless(word, dictionary[i]);
    if (close > mclose) {
      mclose = close;
      index = i;
    }
  }
  return index;
}


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)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <get_closeless@plt>
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119e <get_closest_word+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <get_closeless@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    118b <get_closest_word+0x7b>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1190 <get_closest_word+0x80>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1146 <get_closest_word+0x36>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_closest_word>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rsi),%rsi
call   1030 <get_closeless@plt>
xor    %ebp,%ebp
cmp    $0x2,%r15d
jl     116b <get_closest_word+0x5b>
mov    %r15d,%r15d
xor    %ebp,%ebp
mov    $0x1,%ebx
nop
movss  %xmm0,0xc(%rsp)
mov    (%r14,%rbx,8),%rsi
mov    %r12,%rdi
call   1030 <get_closeless@plt>
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
cmova  %ebx,%ebp
maxss  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <get_closest_word+0x30>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @get_closest_word(i8* %0, i8** nocapture %1, i32 %2) {
%4 = load i8*, i8** %1
%5 = tail call float @get_closeless(i8* %0, i8* %4)
%6 = icmp sgt i32 %2, 1
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 1, %7 ], [ %20, %9 ]
%11 = phi i32 [ 0, %7 ], [ %19, %9 ]
%12 = phi float [ %5, %7 ], [ %17, %9 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %10
%14 = load i8*, i8** %13
%15 = tail call float @get_closeless(i8* %0, i8* %14)
%16 = fcmp ogt float %15, %12
%17 = select i1 %16, float %15, float %12
%18 = trunc i64 %10 to i32
%19 = select i1 %16, i32 %18, i32 %11
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %3
%23 = phi i32 [ 0, %3 ], [ %19, %9 ]
ret i32 %23
}