#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 */
size_t min_match_length(char *, char *);
size_t strlen(char *);
float score(char *string, char *query) {
  size_t string_length, query_length, match_length;
  string_length = strlen(string);
  query_length = strlen(query);
  if (query_length == 0) {
    return 1;
  }
  if (string_length == 0) {
    return 0;
  }
  match_length = min_match_length(string, query);
  if (match_length == 0) {
    return 0;
  }
  return (float)query_length / (float)match_length / (float)string_length;
}


x86 assembly (clang, -O0):
<score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1167 <score+0x47>
movss  0xea3(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128f <score+0x16f>
cmpq   $0x0,-0x20(%rbp)
jne    117f <score+0x5f>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128f <score+0x16f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <min_match_length@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a8 <score+0x88>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128f <score+0x16f>
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x38(%rbp)
test   %rax,%rax
movss  %xmm0,-0x34(%rbp)
js     11e5 <score+0xc5>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x40(%rbp)
test   %rax,%rax
movss  %xmm0,-0x3c(%rbp)
js     122c <score+0x10c>
movss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x44(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x4c(%rbp)
test   %rax,%rax
movss  %xmm0,-0x48(%rbp)
js     127c <score+0x15c>
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x50(%rbp),%xmm0
movss  -0x48(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<score>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     1182 <score+0x62>
xorps  %xmm0,%xmm0
test   %r14,%r14
je     11ef <score+0xcf>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <min_match_length@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
je     11ef <score+0xcf>
test   %r12,%r12
js     118c <score+0x6c>
xorps  %xmm0,%xmm0
cvtsi2ss %r12,%xmm0
test   %rax,%rax
js     11aa <score+0x8a>
cvtsi2ss %rax,%xmm1
jmp    11bf <score+0x9f>
movss  0xe76(%rip),%xmm0
jmp    11ef <score+0xcf>
mov    %r12,%rcx
shr    %rcx
and    $0x1,%r12d
or     %rcx,%r12
xorps  %xmm0,%xmm0
cvtsi2ss %r12,%xmm0
addss  %xmm0,%xmm0
test   %rax,%rax
jns    117b <score+0x5b>
mov    %rax,%rcx
shr    %rcx
and    $0x1,%eax
or     %rcx,%rax
cvtsi2ss %rax,%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
test   %r14,%r14
js     11d2 <score+0xb2>
xorps  %xmm1,%xmm1
cvtsi2ss %r14,%xmm1
jmp    11eb <score+0xcb>
mov    %r14,%rax
shr    %rax
and    $0x1,%r14d
or     %rax,%r14
xorps  %xmm1,%xmm1
cvtsi2ss %r14,%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @score(i8* %0, i8* %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %6
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store float 1.000000e+00, float* %3
br label %36
16: ; preds = %2
%17 = load i64, i64* %6
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store float 0.000000e+00, float* %3
br label %36
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i64 @min_match_length(i8* %21, i8* %22)
store i64 %23, i64* %8
%24 = load i64, i64* %8
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store float 0.000000e+00, float* %3
br label %36
27: ; preds = %20
%28 = load i64, i64* %7
%29 = uitofp i64 %28 to float
%30 = load i64, i64* %8
%31 = uitofp i64 %30 to float
%32 = fdiv float %29, %31
%33 = load i64, i64* %6
%34 = uitofp i64 %33 to float
%35 = fdiv float %32, %34
store float %35, float* %3
br label %36
36: ; preds = %27, %26, %19, %15
%37 = load float, float* %3
ret float %37
}

LLVM IR (-O2):
define float @score(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = icmp eq i64 %3, 0
br i1 %7, label %17, label %8
8: ; preds = %6
%9 = tail call i64 @min_match_length(i8* %0, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = uitofp i64 %4 to float
%13 = uitofp i64 %9 to float
%14 = fdiv float %12, %13
%15 = uitofp i64 %3 to float
%16 = fdiv float %14, %15
br label %17
17: ; preds = %8, %6, %2, %11
%18 = phi float [ %16, %11 ], [ 1.000000e+00, %2 ], [ 0.000000e+00, %6 ], [ 0.000000e+00, %8 ]
ret float %18
}