#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
unsigned int levenshtein(char *, unsigned int, char *, unsigned int);
char *optarg;
char optopt;
int /*<<< orphan*/ printf(char *, char *, char *, unsigned int);
int /*<<< orphan*/ stderr;
unsigned int strlen(char *);
int main(int argc, char **argv) {
  int c;
  char *s;
  char *t;
  unsigned int distance = 0;
  unsigned int len_s;
  unsigned int len_t;
  while ((c = getopt(argc, argv, "s:t:")) != -1) {
    switch (c) {
    case 's':
      s = optarg;
      break;
    case 't':
      t = optarg;
      break;
    case '?':
      if ((optopt == 's') || (optopt == 't'))
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      return 1;
    }
  }
  len_s = strlen(s);
  len_t = strlen(t);
  distance = levenshtein(s, len_s, t, len_t);
  printf("The levesthein distance between words: '%s' and '%s' is %d\n", s, t,
         distance);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1262 <main+0x112>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x3f,%eax
je     11e8 <main+0x98>
jmp    11a0 <main+0x50>
mov    -0x38(%rbp),%eax
sub    $0x73,%eax
je     11c2 <main+0x72>
jmp    11b1 <main+0x61>
mov    -0x38(%rbp),%eax
sub    $0x74,%eax
je     11d5 <main+0x85>
jmp    125d <main+0x10d>
mov    0x2e2f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    125d <main+0x10d>
mov    0x2e1c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    125d <main+0x10d>
mov    0x2df1(%rip),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
je     120e <main+0xbe>
mov    0x2dde(%rip),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
jne    1232 <main+0xe2>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
mov    0x2dbb(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1251 <main+0x101>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
mov    0x2d97(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ae <main+0x15e>
jmp    116d <main+0x1d>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%ecx
call   1060 <levenshtein@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
lea    0xd9c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe99(%rip),%r12
mov    0x2e8a(%rip),%r13
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x72,%eax
jg     1190 <main+0x40>
cmp    $0xffffffff,%eax
je     11cc <main+0x7c>
cmp    $0x3f,%eax
jne    1170 <main+0x20>
jmp    11a6 <main+0x56>
xchg   %ax,%ax
cmp    $0x74,%eax
je     11a0 <main+0x50>
cmp    $0x73,%eax
jne    1170 <main+0x20>
mov    0x0(%r13),%r15
jmp    1170 <main+0x20>
mov    0x0(%r13),%r14
jmp    1170 <main+0x20>
mov    0x2e33(%rip),%rax
mov    (%rax),%al
lea    -0x73(%rax),%ecx
mov    0x2e17(%rip),%rdx
mov    (%rdx),%edi
movsbl %al,%edx
cmp    $0x1,%cl
ja     1205 <main+0xb5>
lea    0xe3b(%rip),%rsi
jmp    120c <main+0xbc>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <levenshtein@plt>
lea    0xe4a(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1216 <main+0xc6>
lea    0xe1b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"s:t:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [60 x i8] c"The levesthein distance between words: '%s' and '%s' is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
br label %12
12: ; preds = %40, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = load i32, i32* %6
switch i32 %18, label %40 [
i32 115, label %19
i32 116, label %21
i32 63, label %23
]
19: ; preds = %17
%20 = load i8*, i8** @optarg
store i8* %20, i8** %7
br label %40
21: ; preds = %17
%22 = load i8*, i8** @optarg
store i8* %22, i8** %8
br label %40
23: ; preds = %17
%24 = load i8, i8* @optopt
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 115
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8, i8* @optopt
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 116
br i1 %30, label %31, label %35
31: ; preds = %27, %23
%32 = load i32, i32* @stderr
%33 = load i8, i8* @optopt
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %33)
br label %39
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = load i8, i8* @optopt
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %37)
br label %39
39: ; preds = %35, %31
store i32 1, i32* %3
br label %55
40: ; preds = %17, %21, %19
br label %12
41: ; preds = %12
%42 = load i8*, i8** %7
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %10
%44 = load i8*, i8** %8
%45 = call i32 @strlen(i8* %44)
store i32 %45, i32* %11
%46 = load i8*, i8** %7
%47 = load i32, i32* %10
%48 = load i8*, i8** %8
%49 = load i32, i32* %11
%50 = call i32 @levenshtein(i8* %46, i32 %47, i8* %48, i32 %49)
store i32 %50, i32* %9
%51 = load i8*, i8** %7
%52 = load i8*, i8** %8
%53 = load i32, i32* %9
%54 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i8* %51, i8* %52, i32 %53)
store i32 0, i32* %3
br label %55
55: ; preds = %41, %39
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [5 x i8] c"s:t:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [60 x i8] c"The levesthein distance between words: '%s' and '%s' is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i8* [ %13, %12 ], [ undef, %2 ]
%5 = phi i8* [ %7, %12 ], [ undef, %2 ]
br label %6
6: ; preds = %3, %10
%7 = phi i8* [ %5, %3 ], [ %11, %10 ]
br label %8
8: ; preds = %6, %8
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %8 [
i32 -1, label %23
i32 115, label %10
i32 116, label %12
i32 63, label %14
]
10: ; preds = %8
%11 = load i8*, i8** @optarg
br label %6
12: ; preds = %8
%13 = load i8*, i8** @optarg
br label %3
14: ; preds = %8
%15 = load i8, i8* @optopt
%16 = add i8 %15, -115
%17 = icmp ult i8 %16, 2
%18 = load i32, i32* @stderr
br i1 %17, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %15)
br label %28
21: ; preds = %14
%22 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %15)
br label %28
23: ; preds = %8
%24 = tail call i32 @strlen(i8* %7)
%25 = tail call i32 @strlen(i8* %4)
%26 = tail call i32 @levenshtein(i8* %7, i32 %24, i8* %4, i32 %25)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %4, i32 %26)
br label %28
28: ; preds = %19, %21, %23
%29 = phi i32 [ 0, %23 ], [ 1, %21 ], [ 1, %19 ]
ret i32 %29
}