#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*/ printf(char *, char *);
int strlen(char *);
void removeDuplicate(char *str) {
  int compare = 0, j = 0;
  char val = 0;
  for (int i = 0; i < strlen(str); i++) {
    val = str[i] - 'a';
    if ((compare & 1 << val)) {
      for (j = i; j < strlen(str); j++)
        str[j] = str[j + 1];
      i = i - 1;
    } else
      compare |= 1 << val;
  }
  printf("%s\n", str);
}


x86 assembly (clang, -O0):
<removeDuplicate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    120b <removeDuplicate+0xeb>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
mov    %al,-0x11(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0x11(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11e7 <removeDuplicate+0xc7>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11d9 <removeDuplicate+0xb9>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1194 <removeDuplicate+0x74>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f8 <removeDuplicate+0xd8>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11fd <removeDuplicate+0xdd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <removeDuplicate+0x25>
mov    -0x8(%rbp),%rsi
lea    0xdea(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeDuplicate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b5 <removeDuplicate+0x95>
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    1155 <removeDuplicate+0x35>
add    $0xffffffff,%r15d
add    $0x1,%r15d
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
jge    11b5 <removeDuplicate+0x95>
movslq %r15d,%rbp
mov    (%r12,%rbp,1),%cl
add    $0x9f,%cl
mov    $0x1,%eax
shl    %cl,%eax
movzbl %cl,%ecx
bt     %ecx,%r14d
jae    11b0 <removeDuplicate+0x90>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r15d
jge    1140 <removeDuplicate+0x20>
nopl   0x0(%rax)
lea    0x1(%rbp),%rbx
movzbl 0x1(%r12,%rbp,1),%eax
mov    %al,(%r12,%rbp,1)
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
mov    %rbx,%rbp
cmp    %rax,%rbx
jl     1180 <removeDuplicate+0x60>
jmp    1140 <removeDuplicate+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
or     %eax,%r14d
jmp    1144 <removeDuplicate+0x24>
lea    0xe44(%rip),%rdi
mov    %r12,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @removeDuplicate(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i8 0, i8* %5
store i32 0, i32* %6
br label %7
7: ; preds = %58, %1
%8 = load i32, i32* %6
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %61
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = sub nsw i32 %18, 97
%20 = trunc i32 %19 to i8
store i8 %20, i8* %5
%21 = load i32, i32* %3
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = shl i32 1, %23
%25 = and i32 %21, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %51
27: ; preds = %12
%28 = load i32, i32* %6
store i32 %28, i32* %4
br label %29
29: ; preds = %45, %27
%30 = load i32, i32* %4
%31 = load i8*, i8** %2
%32 = call i32 @strlen(i8* %31)
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %48
34: ; preds = %29
%35 = load i8*, i8** %2
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %2
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
br label %45
45: ; preds = %34
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %29
48: ; preds = %29
%49 = load i32, i32* %6
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %6
br label %57
51: ; preds = %12
%52 = load i8, i8* %5
%53 = sext i8 %52 to i32
%54 = shl i32 1, %53
%55 = load i32, i32* %3
%56 = or i32 %55, %54
store i32 %56, i32* %3
br label %57
57: ; preds = %51, %48
br label %58
58: ; preds = %57
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %7
61: ; preds = %7
%62 = load i8*, i8** %2
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %62)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @removeDuplicate(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %33, %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
6: ; preds = %1, %33
%7 = phi i32 [ %36, %33 ], [ 0, %1 ]
%8 = phi i32 [ %34, %33 ], [ 0, %1 ]
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = add i8 %11, -97
%13 = zext i8 %12 to i32
%14 = shl nuw i32 1, %13
%15 = and i32 %14, %8
%16 = icmp eq i32 %15, 0
br i1 %16, label %31, label %17
17: ; preds = %6
%18 = tail call i32 @strlen(i8* %0)
%19 = icmp slt i32 %7, %18
br i1 %19, label %20, label %29
20: ; preds = %17, %20
%21 = phi i64 [ %22, %20 ], [ %9, %17 ]
%22 = add nsw i64 %21, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 %24, i8* %25
%26 = tail call i32 @strlen(i8* %0)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %22, %27
br i1 %28, label %20, label %29
29: ; preds = %20, %17
%30 = add nsw i32 %7, -1
br label %33
31: ; preds = %6
%32 = or i32 %14, %8
br label %33
33: ; preds = %29, %31
%34 = phi i32 [ %8, %29 ], [ %32, %31 ]
%35 = phi i32 [ %30, %29 ], [ %7, %31 ]
%36 = add nsw i32 %35, 1
%37 = tail call i32 @strlen(i8* %0)
%38 = icmp slt i32 %36, %37
br i1 %38, label %6, label %4
}