int main(int argc, char **argv) {
  if (argc < 2) {
    printf("removeDuplicateLetters <string>\n");
    return 0;
  }
  char boolStr[][8] = {"false", "true"};
  char *r = removeDuplicateLetters(argv[1]);
  char *r2 = removeDuplicateLetters2(argv[1]);
  printf("%s\t%s\tEqual=%s\n", r, r2, boolStr[!strcmp(r, r2)]);
  free(r);
  free(r2);
  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)
cmpl   $0x2,-0x8(%rbp)
jge    118a <main+0x3a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <main+0xe0>
mov    0xeaf(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1030 <removeDuplicateLetters@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1050 <removeDuplicateLetters2@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <strcmp@plt>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cltq
lea    -0x20(%rbp),%rcx
shl    $0x3,%rax
add    %rax,%rcx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jg     117a <main+0x1a>
lea    0xead(%rip),%rdi
call   1050 <puts@plt>
jmp    11de <main+0x7e>
mov    %rsi,%rbx
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x8(%rsi),%rdi
xor    %eax,%eax
call   1030 <removeDuplicateLetters@plt>
movslq %eax,%r14
mov    0x8(%rbx),%rdi
xor    %eax,%eax
call   1060 <removeDuplicateLetters2@plt>
movslq %eax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rsp,%rcx,8),%rcx
lea    0xe4f(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"removeDuplicateLetters <string>\0A\00"
@__const.main.boolStr = [2 x [8 x i8]] [[8 x i8] c"false\00\00\00", [8 x i8] c"true\00\00\00\00"]
@.str.1 = [16 x i8] c"%s\09%s\09Equal=%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x [8 x i8]]
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %41
13: ; preds = %2
%14 = bitcast [2 x [8 x i8]]* %6 to i8*
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @removeDuplicateLetters to i32 (i8*, ...)*)(i8* %17)
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @removeDuplicateLetters2 to i32 (i8*, ...)*)(i8* %23)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %8
%27 = load i8*, i8** %7
%28 = load i8*, i8** %8
%29 = load i8*, i8** %7
%30 = load i8*, i8** %8
%31 = call i32 @strcmp(i8* %29, i8* %30)
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
%34 = zext i1 %33 to i32
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %6, i64 0, i64 %35
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %36, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28, i8* %37)
%39 = load i8*, i8** %7
%40 = load i8*, i8** %8
store i32 0, i32* %3
br label %41
41: ; preds = %13, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@__const.main.boolStr = [2 x [8 x i8]] [[8 x i8] c"false\00\00\00", [8 x i8] c"true\00\00\00\00"]
@.str.1 = [16 x i8] c"%s\09%s\09Equal=%s\0A\00"
@str = [32 x i8] c"removeDuplicateLetters <string>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x [8 x i8]]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %23
7: ; preds = %2
%8 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %3, i64 0, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @removeDuplicateLetters to i32 (i8*, ...)*)(i8* %10)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) bitcast (i32 (...)* @removeDuplicateLetters2 to i32 (i8*, ...)*)(i8* %14)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(1) %17)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i64
%21 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %3, i64 0, i64 %20, i64 0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %17, i8* %21)
br label %23
23: ; preds = %7, %5
ret i32 0
}