#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 hamming_dist(char *, char *);
int /*<<< orphan*/ help();
int levenshtein_dist(char *, char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc == 1) {
    help();
    return 0;
  }
  if (strcmp(argv[1], "--help") == 0)
    help();
  if (argc != 4) {
    usage();
    return -1;
  }
  if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--hamming") == 0) {
    printf("%d\n", hamming_dist(argv[2], argv[3]));
  }
  if (strcmp(argv[1], "-l") == 0 || strcmp(argv[1], "--levenshtein") == 0) {
    printf("%d\n", levenshtein_dist(argv[2], argv[3]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1193 <main+0x33>
mov    $0x0,%al
call   1080 <help@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <main+0x13a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <main+0x58>
mov    $0x0,%al
call   1080 <help@plt>
cmpl   $0x4,-0x8(%rbp)
je     11d5 <main+0x75>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <main+0x13a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1211 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe08(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <hamming_dist@plt>
mov    %eax,%esi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1270 <main+0x110>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdba(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1293 <main+0x133>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1050 <levenshtein_dist@plt>
mov    %eax,%esi
lea    0xd86(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1176 <main+0x16>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <help@plt>
jmp    1249 <main+0xe9>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     122d <main+0xcd>
cmp    $0x4,%ebp
jne    123d <main+0xdd>
mov    0x8(%rbx),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11c7 <main+0x67>
mov    0x8(%rbx),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11e2 <main+0x82>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <hamming_dist@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     120e <main+0xae>
mov    0x8(%rbx),%rdi
lea    0xe19(%rip),%rsi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1249 <main+0xe9>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <levenshtein_dist@plt>
lea    0xdf2(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %ebp,%ebp
jmp    1249 <main+0xe9>
xor    %eax,%eax
call   1080 <help@plt>
cmp    $0x4,%ebp
je     119d <main+0x3d>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [10 x i8] c"--hamming\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [3 x i8] c"-l\00"
@.str.5 = [14 x i8] c"--levenshtein\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @help()
store i32 0, i32* %3
br label %66
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (...) @help()
br label %18
18: ; preds = %16, %10
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 4
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %66
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %44
35: ; preds = %29, %23
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @hamming_dist(i8* %38, i8* %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %35, %29
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %44
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %50, %44
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32 @levenshtein_dist(i8* %59, i8* %62)
%64 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %56, %50
store i32 0, i32* %3
br label %66
66: ; preds = %65, %21, %8
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [10 x i8] c"--hamming\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [3 x i8] c"-l\00"
@.str.5 = [14 x i8] c"--levenshtein\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @help()
br label %47
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (...) @help()
br label %13
13: ; preds = %11, %6
%14 = icmp eq i32 %0, 4
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 (...) @usage()
br label %47
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %21, %17
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 @hamming_dist(i8* %27, i8* %29)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25, %21
%33 = load i8*, i8** %7
%34 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i8*, i8** %7
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %36, %32
%41 = getelementptr inbounds i8*, i8** %1, i64 2
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32 @levenshtein_dist(i8* %42, i8* %44)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %36, %40, %15, %4
%48 = phi i32 [ 0, %4 ], [ -1, %15 ], [ 0, %40 ], [ 0, %36 ]
ret i32 %48
}