#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 strlen(char const *);
float _sub_cost_1_min_2(const char *str1, const int str1_idx, const char *str2,
                        const int str2_idx) {
  size_t l1 = strlen(str1);
  size_t l2 = strlen(str2);
  if (((int)l1 <= str1_idx) || (str1_idx < 0))
    return ((float)0);
  if (((int)l2 <= str2_idx) || (str2_idx < 0))
    return ((float)0);
  if (str1[str1_idx] == str2[str2_idx])
    return ((float)1);
  else
    return ((float)-2);
}


x86 assembly (clang, -O0):
<_sub_cost_1_min_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x14(%rbp),%eax
jle    1157 <_sub_cost_1_min_2+0x47>
cmpl   $0x0,-0x14(%rbp)
jge    1164 <_sub_cost_1_min_2+0x54>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <_sub_cost_1_min_2+0xb7>
mov    -0x38(%rbp),%rax
cmp    -0x24(%rbp),%eax
jle    117b <_sub_cost_1_min_2+0x6b>
cmpl   $0x0,-0x24(%rbp)
jge    1188 <_sub_cost_1_min_2+0x78>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <_sub_cost_1_min_2+0xb7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11ba <_sub_cost_1_min_2+0xaa>
movss  0xe54(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c7 <_sub_cost_1_min_2+0xb7>
movss  0xe3e(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sub_cost_1_min_2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
xorps  %xmm0,%xmm0
test   %ebp,%ebp
js     1169 <_sub_cost_1_min_2+0x59>
cmp    %ebp,%eax
jle    1169 <_sub_cost_1_min_2+0x59>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %r15d,%r15d
js     1166 <_sub_cost_1_min_2+0x56>
cmp    %r15d,%eax
xorps  %xmm0,%xmm0
jle    1169 <_sub_cost_1_min_2+0x59>
mov    %ebp,%eax
mov    (%rbx,%rax,1),%al
mov    %r15d,%ecx
xor    %edx,%edx
cmp    (%r14,%rcx,1),%al
sete   %dl
lea    0xea1(%rip),%rax
movss  (%rax,%rdx,4),%xmm0
jmp    1169 <_sub_cost_1_min_2+0x59>
xorps  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float @_sub_cost_1_min_2(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca float
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %6
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %10
%14 = load i8*, i8** %8
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %11
%16 = load i64, i64* %10
%17 = trunc i64 %16 to i32
%18 = load i32, i32* %7
%19 = icmp sle i32 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %4
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20, %4
store float 0.000000e+00, float* %5
br label %49
24: ; preds = %20
%25 = load i64, i64* %11
%26 = trunc i64 %25 to i32
%27 = load i32, i32* %9
%28 = icmp sle i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29, %24
store float 0.000000e+00, float* %5
br label %49
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i8*, i8** %8
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %39, %45
br i1 %46, label %47, label %48
47: ; preds = %33
store float 1.000000e+00, float* %5
br label %49
48: ; preds = %33
store float -2.000000e+00, float* %5
br label %49
49: ; preds = %48, %47, %32, %23
%50 = load float, float* %5
ret float %50
}

LLVM IR (-O2):
define float @_sub_cost_1_min_2(i8* nocapture %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = trunc i64 %5 to i32
%7 = icmp sle i32 %6, %1
%8 = icmp slt i32 %1, 0
%9 = or i1 %8, %7
br i1 %9, label %25, label %10
10: ; preds = %4
%11 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%12 = trunc i64 %11 to i32
%13 = icmp sle i32 %12, %3
%14 = icmp slt i32 %3, 0
%15 = or i1 %14, %13
br i1 %15, label %25, label %16
16: ; preds = %10
%17 = zext i32 %1 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = zext i32 %3 to i64
%21 = getelementptr inbounds i8, i8* %2, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %19, %22
%24 = select i1 %23, float 1.000000e+00, float -2.000000e+00
br label %25
25: ; preds = %16, %10, %4
%26 = phi float [ 0.000000e+00, %4 ], [ 0.000000e+00, %10 ], [ %24, %16 ]
ret float %26
}