#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*/ shrink(char *);
void dedup(char *input) {
  unsigned char lookup[256] = {0};
  unsigned int i = 0;
  while (input[i] != '\0') {
    if (lookup[input[i]] != 0)
      shrink(&input[i]);
    else {
      lookup[input[i]] = 1;
      ++i;
    }
  }
}


x86 assembly (clang, -O0):
<dedup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
movl   $0x0,-0x114(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x114(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c5 <dedup+0xa5>
mov    -0x8(%rbp),%rax
mov    -0x114(%rbp),%ecx
movsbq (%rax,%rcx,1),%rax
movzbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     119a <dedup+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x114(%rbp),%eax
add    %rax,%rdi
call   1040 <shrink@plt>
jmp    11c0 <dedup+0xa0>
mov    -0x8(%rbp),%rax
mov    -0x114(%rbp),%ecx
movsbq (%rax,%rcx,1),%rax
movb   $0x1,-0x110(%rbp,%rax,1)
01
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    114c <dedup+0x2c>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dedup>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    (%rdi),%al
test   %al,%al
je     11b6 <dedup+0xa6>
mov    %rdi,%rbx
xor    %ebp,%ebp
jmp    11a5 <dedup+0x95>
movb   $0x1,(%rsp,%rax,1)
add    $0x1,%ebp
mov    %ebp,%eax
lea    (%rbx,%rax,1),%rdi
movzbl (%rbx,%rax,1),%eax
test   %al,%al
je     11b6 <dedup+0xa6>
movsbq %al,%rax
cmpb   $0x0,(%rsp,%rax,1)
je     1190 <dedup+0x80>
call   1030 <shrink@plt>
jmp    1197 <dedup+0x87>
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @dedup(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = bitcast [256 x i8]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %41, %1
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %42
14: ; preds = %6
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %14
%26 = load i8*, i8** %2
%27 = load i32, i32* %4
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @shrink(i8* %29)
br label %41
31: ; preds = %14
%32 = load i8*, i8** %2
%33 = load i32, i32* %4
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %37
store i8 1, i8* %38
%39 = load i32, i32* %4
%40 = add i32 %39, 1
store i32 %40, i32* %4
br label %41
41: ; preds = %31, %25
br label %6
42: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @dedup(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1, %18
%7 = phi i8 [ %22, %18 ], [ %4, %1 ]
%8 = phi i8* [ %21, %18 ], [ %0, %1 ]
%9 = phi i32 [ %19, %18 ], [ 0, %1 ]
%10 = sext i8 %7 to i64
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %6
%15 = tail call i32 @shrink(i8* %8)
br label %18
16: ; preds = %6
store i8 1, i8* %11
%17 = add i32 %9, 1
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %9, %14 ], [ %17, %16 ]
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %6
24: ; preds = %18, %1
ret void
}