#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*/ assert(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
char *removeDuplicateLetters(char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char s1[] = "bcabc";
  char expected1[] = "abc";
  char *result1 = removeDuplicateLetters(s1);
  assert(strcmp(expected1, result1) == 0);
  printf("First case: OK\n");
  free(result1);
  char s2[] = "cbacdcbc";
  char expected2[] = "acdb";
  char *result2 = removeDuplicateLetters(s2);
  assert(strcmp(expected2, result2) == 0);
  printf("Second case: OK\n");
  free(result2);
  char s3[] = "thesqtitxyetpxloeevdeqifkz";
  char expected3[] = "hesitxyplovdqfkz";
  char *result3 = removeDuplicateLetters(s3);
  assert(strcmp(expected3, result3) == 0);
  printf("Second case: OK\n");
  free(result3);
  char s4[] = "mitnlruhznjfyzmtmfnstsxwktxlboxutbic";
  char expected4[] = "ilrhjfyzmnstwkboxuc";
  char *result4 = removeDuplicateLetters(s4);
  assert(strcmp(expected4, result4) == 0);
  printf("Second case: OK\n");
  free(result4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe88(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe82(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xe76(%rip),%eax
mov    %eax,-0xe(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,-0x18(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    0xe40(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xe3e(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe36(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe31(%rip),%al
mov    %al,-0x22(%rbp)
lea    -0x21(%rbp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,-0x30(%rbp)
lea    -0x26(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdfd(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    0xe04(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe01(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xdfe(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xdfb(%rip),%ax
mov    %ax,-0x38(%rbp)
mov    0xdf3(%rip),%al
mov    %al,-0x36(%rbp)
mov    0xdef(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xdec(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xdea(%rip),%al
mov    %al,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd69(%rip),%rdi
call   1050 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1040 <free@plt>
lea    -0xa0(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x25,%edx
call   1080 <memcpy@plt>
mov    0xdc8(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    0xdc2(%rip),%rax
mov    %rax,-0xb8(%rbp)
mov    0xdbd(%rip),%eax
mov    %eax,-0xb0(%rbp)
lea    -0xa0(%rbp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,-0xc8(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xcdd(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc8(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
movw   $0x63,0x1c(%rsp)
movl   $0x62616362,0x18(%rsp)
62
movl   $0x636261,0x14(%rsp)
lea    0x18(%rsp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,%rbx
lea    0x14(%rsp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe74(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
movabs $0x6362636463616263,%rax
63 62 63
mov    %rax,0x20(%rsp)
movb   $0x0,0x28(%rsp)
movb   $0x0,0x10(%rsp)
movl   $0x62646361,0xc(%rsp)
62
lea    0x20(%rsp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe26(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
movups 0xe37(%rip),%xmm0
movups %xmm0,0x7b(%rsp)
movaps 0xe20(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe34(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movb   $0x0,0x40(%rsp)
lea    0x70(%rsp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,%rbx
lea    0x30(%rsp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
movaps 0xe1b(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xdfc(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movabs $0x6369627475786f,%rax
mov    %rax,0xad(%rsp)
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movl   $0x637578,0x60(%rsp)
lea    0x90(%rsp),%rdi
call   1030 <removeDuplicateLetters@plt>
mov    %rax,%rbx
lea    0x50(%rsp),%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s1 = [6 x i8] c"bcabc\00"
@__const.main.expected1 = [4 x i8] c"abc\00"
@.str = [16 x i8] c"First case: OK\0A\00"
@__const.main.s2 = [9 x i8] c"cbacdcbc\00"
@__const.main.expected2 = [5 x i8] c"acdb\00"
@.str.1 = [17 x i8] c"Second case: OK\0A\00"
@__const.main.s3 = [27 x i8] c"thesqtitxyetpxloeevdeqifkz\00"
@__const.main.expected3 = [17 x i8] c"hesitxyplovdqfkz\00"
@__const.main.s4 = [37 x i8] c"mitnlruhznjfyzmtmfnstsxwktxlboxutbic\00"
@__const.main.expected4 = [20 x i8] c"ilrhjfyzmnstwkboxuc\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [4 x i8]
%4 = alloca i8*
%5 = alloca [9 x i8]
%6 = alloca [5 x i8]
%7 = alloca i8*
%8 = alloca [27 x i8]
%9 = alloca [17 x i8]
%10 = alloca i8*
%11 = alloca [37 x i8]
%12 = alloca [20 x i8]
%13 = alloca i8*
store i32 0, i32* %1
%14 = bitcast [6 x i8]* %2 to i8*
%15 = bitcast [4 x i8]* %3 to i8*
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%17 = call i8* @removeDuplicateLetters(i8* %16)
store i8* %17, i8** %4
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
%27 = bitcast [9 x i8]* %5 to i8*
%28 = bitcast [5 x i8]* %6 to i8*
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%30 = call i8* @removeDuplicateLetters(i8* %29)
store i8* %30, i8** %7
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%32 = load i8*, i8** %7
%33 = call i64 @strcmp(i8* %31, i8* %32)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%38 = load i8*, i8** %7
%39 = call i32 @free(i8* %38)
%40 = bitcast [27 x i8]* %8 to i8*
%41 = bitcast [17 x i8]* %9 to i8*
%42 = getelementptr inbounds [27 x i8], [27 x i8]* %8, i64 0, i64 0
%43 = call i8* @removeDuplicateLetters(i8* %42)
store i8* %43, i8** %10
%44 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%45 = load i8*, i8** %10
%46 = call i64 @strcmp(i8* %44, i8* %45)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%51 = load i8*, i8** %10
%52 = call i32 @free(i8* %51)
%53 = bitcast [37 x i8]* %11 to i8*
%54 = bitcast [20 x i8]* %12 to i8*
%55 = getelementptr inbounds [37 x i8], [37 x i8]* %11, i64 0, i64 0
%56 = call i8* @removeDuplicateLetters(i8* %55)
store i8* %56, i8** %13
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%58 = load i8*, i8** %13
%59 = call i64 @strcmp(i8* %57, i8* %58)
%60 = icmp eq i64 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%64 = load i8*, i8** %13
%65 = call i32 @free(i8* %64)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [6 x i8] c"bcabc\00"
@__const.main.s2 = [9 x i8] c"cbacdcbc\00"
@__const.main.expected2 = [5 x i8] c"acdb\00"
@__const.main.s3 = [27 x i8] c"thesqtitxyetpxloeevdeqifkz\00"
@__const.main.expected3 = [17 x i8] c"hesitxyplovdqfkz\00"
@__const.main.s4 = [37 x i8] c"mitnlruhznjfyzmtmfnstsxwktxlboxutbic\00"
@__const.main.expected4 = [20 x i8] c"ilrhjfyzmnstwkboxuc\00"
@str = [15 x i8] c"First case: OK\00"
@str.4 = [16 x i8] c"Second case: OK\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca i32
%3 = alloca [9 x i8]
%4 = alloca [5 x i8]
%5 = alloca [27 x i8]
%6 = alloca [17 x i8]
%7 = alloca [37 x i8]
%8 = alloca [20 x i8]
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%10 = bitcast i32* %2 to i8*
store i32 6513249, i32* %2
%11 = call i8* @removeDuplicateLetters(i8* %9)
%12 = call i64 @strcmp(i8* %10, i8* %11)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%17 = call i32 @free(i8* %11)
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%20 = call i8* @removeDuplicateLetters(i8* %18)
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%26 = call i32 @free(i8* %20)
%27 = getelementptr inbounds [27 x i8], [27 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%29 = call i8* @removeDuplicateLetters(i8* %27)
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%35 = call i32 @free(i8* %29)
%36 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%38 = call i8* @removeDuplicateLetters(i8* %36)
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%44 = call i32 @free(i8* %38)
ret i32 0
}