#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 levenshtein(char const *, char const *);
int /*<<< orphan*/ printf(char *, char const *, char const *, int);
int /*<<< orphan*/ puts(char *);
void testLevenshtein(const char *s1, const char *s2) {
  int distance = levenshtein(s1, s2);
  printf("Distance between \"%s\" and \"%s\": %d\n", s1, s2, distance);
  if (distance < 0)
    puts("strings are too big to be compared");
  else if (distance == 0)
    puts("strings are equal");
  else
    puts("strings are differents");
}


x86 assembly (clang, -O0):
<testLevenshtein>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <levenshtein@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1182 <testLevenshtein+0x52>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
jmp    11ae <testLevenshtein+0x7e>
cmpl   $0x0,-0x14(%rbp)
jne    119d <testLevenshtein+0x6d>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
jmp    11a9 <testLevenshtein+0x79>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
jmp    11ae <testLevenshtein+0x7e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testLevenshtein>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <levenshtein@plt>
mov    %eax,%ebp
lea    0xeb8(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
test   %ebp,%ebp
lea    0xee9(%rip),%rax
lea    0xef4(%rip),%rcx
cmove  %rax,%rcx
lea    0xeb4(%rip),%rdi
cmovns %rcx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Distance between \22%s\22 and \22%s\22: %d\0A\00"
@.str.1 = [35 x i8] c"strings are too big to be compared\00"
@.str.2 = [18 x i8] c"strings are equal\00"
@.str.3 = [23 x i8] c"strings are differents\00"
define void @testLevenshtein(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 @levenshtein(i8* %6, i8* %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i32 %11)
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %25
17: ; preds = %2
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %17
%23 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24, %15
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Distance between \22%s\22 and \22%s\22: %d\0A\00"
@.str.1 = [35 x i8] c"strings are too big to be compared\00"
@.str.2 = [18 x i8] c"strings are equal\00"
@.str.3 = [23 x i8] c"strings are differents\00"
define void @testLevenshtein(i8* %0, i8* %1) {
%3 = tail call i32 @levenshtein(i8* %0, i8* %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %3)
%5 = icmp slt i32 %3, 0
%6 = icmp eq i32 %3, 0
%7 = select i1 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0)
%8 = select i1 %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %7
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret void
}