#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 */
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ char32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ fc_lcsubseq(int /*<<< orphan*/ const *, scalar_t__,
                       int /*<<< orphan*/ const *, scalar_t__);
double fc_nlcsubseq(const char32_t *seq1, int32_t len1, const char32_t *seq2,
                    int32_t len2) {
  assert((len1 >= 0 && len1 <= 4096) && (len2 >= 0 && len2 <= 4096));
  if (len1 == 0 && len2 == 0)
    return 1.;
  const int32_t lcs = fc_lcsubseq(seq1, len1, seq2, len2);
  return 1. - (2. * lcs) / (double)(len1 + len2);
}


x86 assembly (clang, -O0):
<fc_nlcsubseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x31(%rbp)
jl     117f <fc_nlcsubseq+0x5f>
xor    %eax,%eax
cmpq   $0x1000,-0x18(%rbp)
mov    %al,-0x31(%rbp)
jg     117f <fc_nlcsubseq+0x5f>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x32(%rbp)
jl     1179 <fc_nlcsubseq+0x59>
cmpq   $0x1000,-0x28(%rbp)
setle  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11b4 <fc_nlcsubseq+0x94>
cmpq   $0x0,-0x28(%rbp)
jne    11b4 <fc_nlcsubseq+0x94>
movsd  0xe56(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1201 <fc_nlcsubseq+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <fc_lcsubseq@plt>
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
movsd  0xe2d(%rip),%xmm1
mulsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe08(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc_nlcsubseq>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
cmp    $0x1001,%rsi
setb   %al
cmp    $0x1001,%rcx
setb   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    %rbx,%rax
or     %r14,%rax
je     118e <fc_nlcsubseq+0x6e>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1030 <fc_lcsubseq@plt>
cvtsi2sd %rax,%xmm1
add    %r14,%rbx
cvtsi2sd %rbx,%xmm0
addsd  %xmm1,%xmm1
divsd  %xmm0,%xmm1
movsd  0xe78(%rip),%xmm0
subsd  %xmm1,%xmm0
jmp    1196 <fc_nlcsubseq+0x76>
movsd  0xe6a(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @fc_nlcsubseq(i32* %0, i64 %1, i32* %2, i64 %3) {
%5 = icmp ult i64 %1, 4097
%6 = icmp ult i64 %3, 4097
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = or i64 %3, %1
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %4
%13 = tail call i64 @fc_lcsubseq(i32* %0, i64 %1, i32* %2, i64 %3)
%14 = sitofp i64 %13 to double
%15 = fmul double %14, 2.000000e+00
%16 = add nsw i64 %3, %1
%17 = sitofp i64 %16 to double
%18 = fdiv double %15, %17
%19 = fsub double 1.000000e+00, %18
br label %20
20: ; preds = %4, %12
%21 = phi double [ %19, %12 ], [ 1.000000e+00, %4 ]
ret double %21
}