#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 */
unsigned long strlen(char *);
bool isOneEditAway(char *str1, char *str2) {
  bool checkThatOnlyOneReplace(char *str1, char *str2);
  bool checkThatOnlyOneInsertOrRemove(char *str1, char *str2);
  unsigned long int strLen1, strLen2;
  strLen1 = strlen(str1);
  strLen2 = strlen(str2);
  if (strLen1 == strLen2) {
    return checkThatOnlyOneReplace(str1, str2);
  }
  if ((strLen1 - 1) == strLen2) {
    return checkThatOnlyOneInsertOrRemove(str1, str2);
  }
  if ((strLen1 + 1) == strLen2) {
    return checkThatOnlyOneInsertOrRemove(str2, str1);
  }
  return false;
}


x86 assembly (clang, -O0):
<isOneEditAway>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    117d <isOneEditAway+0x4d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <checkThatOnlyOneReplace@plt>
mov    %eax,-0x4(%rbp)
jmp    11d2 <isOneEditAway+0xa2>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
cmp    -0x28(%rbp),%rax
jne    11a4 <isOneEditAway+0x74>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <checkThatOnlyOneInsertOrRemove@plt>
mov    %eax,-0x4(%rbp)
jmp    11d2 <isOneEditAway+0xa2>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
cmp    -0x28(%rbp),%rax
jne    11cb <isOneEditAway+0x9b>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <checkThatOnlyOneInsertOrRemove@plt>
mov    %eax,-0x4(%rbp)
jmp    11d2 <isOneEditAway+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isOneEditAway>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jne    1160 <isOneEditAway+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <checkThatOnlyOneReplace@plt>
lea    -0x1(%rbx),%rcx
cmp    %rax,%rcx
jne    1171 <isOneEditAway+0x41>
mov    %r15,%rdi
mov    %r14,%rsi
jmp    1180 <isOneEditAway+0x50>
add    $0x1,%rbx
cmp    %rax,%rbx
jne    118a <isOneEditAway+0x5a>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <checkThatOnlyOneInsertOrRemove@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @isOneEditAway(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %6
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %7
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = call i32 @checkThatOnlyOneReplace(i8* %16, i8* %17)
store i32 %18, i32* %3
br label %38
19: ; preds = %2
%20 = load i64, i64* %6
%21 = sub i64 %20, 1
%22 = load i64, i64* %7
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 @checkThatOnlyOneInsertOrRemove(i8* %25, i8* %26)
store i32 %27, i32* %3
br label %38
28: ; preds = %19
%29 = load i64, i64* %6
%30 = add i64 %29, 1
%31 = load i64, i64* %7
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i8*, i8** %5
%35 = load i8*, i8** %4
%36 = call i32 @checkThatOnlyOneInsertOrRemove(i8* %34, i8* %35)
store i32 %36, i32* %3
br label %38
37: ; preds = %28
store i32 0, i32* %3
br label %38
38: ; preds = %37, %33, %24, %15
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @isOneEditAway(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 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @checkThatOnlyOneReplace(i8* %0, i8* %1)
br label %18
8: ; preds = %2
%9 = add i64 %3, -1
%10 = icmp eq i64 %9, %4
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @checkThatOnlyOneInsertOrRemove(i8* %0, i8* %1)
br label %18
13: ; preds = %8
%14 = add i64 %3, 1
%15 = icmp eq i64 %14, %4
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @checkThatOnlyOneInsertOrRemove(i8* %1, i8* %0)
br label %18
18: ; preds = %13, %16, %11, %6
%19 = phi i32 [ %7, %6 ], [ %12, %11 ], [ %17, %16 ], [ 0, %13 ]
ret i32 %19
}