#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*/ assert(int /*<<< orphan*/);
double jaro(char const *, char const *);
scalar_t__ strlen(char const *);
double jaro_winkler(const char *str1, const char *str2) {
  assert(str1 != NULL);
  assert(str2 != NULL);
  double dist = jaro(str1, str2);
  int prefix_length = 0;
  if (strlen(str1) != 0 && strlen(str2) != 0) {
    while (prefix_length < 3 && ((*str1++) == (*str2++))) {
      prefix_length++;
    }
  }
  return dist + prefix_length * 0.1 * (1 - dist);
}


x86 assembly (clang, -O0):
<jaro_winkler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <jaro@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     1206 <jaro_winkler+0xd6>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     1206 <jaro_winkler+0xd6>
jmp    11a8 <jaro_winkler+0x78>
xor    %eax,%eax
cmpl   $0x3,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jge    11e3 <jaro_winkler+0xb3>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11f3 <jaro_winkler+0xc3>
jmp    1201 <jaro_winkler+0xd1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <jaro_winkler+0x78>
jmp    1206 <jaro_winkler+0xd6>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xddc(%rip),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jaro_winkler>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <jaro@plt>
mov    (%rbx),%al
xorpd  %xmm2,%xmm2
test   %al,%al
je     1191 <jaro_winkler+0x71>
mov    (%r14),%cl
test   %cl,%cl
je     1191 <jaro_winkler+0x71>
cmp    %cl,%al
jne    1191 <jaro_winkler+0x71>
mov    0x1(%rbx),%al
cmp    0x1(%r14),%al
jne    1189 <jaro_winkler+0x69>
mov    0x2(%rbx),%al
xor    %ecx,%ecx
cmp    0x2(%r14),%al
sete   %cl
lea    0xe8e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm2
jmp    1191 <jaro_winkler+0x71>
movsd  0xe6f(%rip),%xmm2
movsd  0xe6f(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @jaro_winkler(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call double @jaro(i8* %15, i8* %16)
store double %17, double* %5
store i32 0, i32* %6
%18 = load i8*, i8** %3
%19 = call i64 @strlen(i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %45
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i64 @strlen(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %45
25: ; preds = %21
br label %26
26: ; preds = %41, %25
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
%32 = load i8, i8* %30
%33 = sext i8 %32 to i32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
%36 = load i8, i8* %34
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %33, %37
br label %39
39: ; preds = %29, %26
%40 = phi i1 [ false, %26 ], [ %38, %29 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %26
44: ; preds = %39
br label %45
45: ; preds = %44, %21, %2
%46 = load double, double* %5
%47 = load i32, i32* %6
%48 = sitofp i32 %47 to double
%49 = fmul double %48, 1.000000e-01
%50 = load double, double* %5
%51 = fsub double 1.000000e+00, %50
%52 = call double @llvm.fmuladd.f64(double %49, double %51, double %46)
ret double %52
}

LLVM IR (-O2):
define double @jaro_winkler(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i8* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call double @jaro(i8* %0, i8* %1)
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %30, label %12
12: ; preds = %2
%13 = load i8, i8* %1
%14 = icmp ne i8 %13, 0
%15 = icmp eq i8 %10, %13
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %1, i64 1
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = load i8, i8* %19
%21 = load i8, i8* %18
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = getelementptr inbounds i8, i8* %1, i64 2
%25 = getelementptr inbounds i8, i8* %0, i64 2
%26 = load i8, i8* %25
%27 = load i8, i8* %24
%28 = icmp eq i8 %26, %27
%29 = select i1 %28, double 0x3FD3333333333334, double 2.000000e-01
br label %30
30: ; preds = %23, %17, %12, %2
%31 = phi double [ 0.000000e+00, %12 ], [ 0.000000e+00, %2 ], [ 1.000000e-01, %17 ], [ %29, %23 ]
%32 = fsub double 1.000000e+00, %9
%33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %9)
ret double %33
}