#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 */
double levenshtein_distance(char const *, char const *);
int strlen(char const *);
double normalized_levenshtein_distance(const char *s, const char *t) {
  int sl = strlen(s);
  int tl = strlen(t);
  double d = levenshtein_distance(s, t);
  return 1 - (d / (sl > tl ? sl : tl));
}


x86 assembly (clang, -O0):
<normalized_levenshtein_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <levenshtein_distance@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    117b <normalized_levenshtein_distance+0x5b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1181 <normalized_levenshtein_distance+0x61>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm1
mov    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe67(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalized_levenshtein_distance>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <levenshtein_distance@plt>
cmp    %ebp,%r15d
cmovg  %r15d,%ebp
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe9f(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @normalized_levenshtein_distance(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call double @levenshtein_distance(i8* %12, i8* %13)
store double %14, double* %7
%15 = load double, double* %7
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = load i32, i32* %5
br label %23
21: ; preds = %2
%22 = load i32, i32* %6
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ %20, %19 ], [ %22, %21 ]
%25 = sitofp i32 %24 to double
%26 = fdiv double %15, %25
%27 = fsub double 1.000000e+00, %26
ret double %27
}

LLVM IR (-O2):
define double @normalized_levenshtein_distance(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call double @levenshtein_distance(i8* %0, i8* %1)
%6 = icmp sgt i32 %3, %4
%7 = select i1 %6, i32 %3, i32 %4
%8 = sitofp i32 %7 to double
%9 = fdiv double %5, %8
%10 = fsub double 1.000000e+00, %9
ret double %10
}