#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 */
size_t getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove_duplicates(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char const *argv[]) {
  char *line = NULL;
  size_t len = 0;
  size_t read;
  while ((read = getline(&line, &len, stdin)) != -1) {
    if (read > 0) {
      line[read - 1] = '\0';
      remove_duplicates(line);
      printf("%s\n", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <getline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0xffffffffffffffff,%rax
je     11b3 <main+0x83>
cmpq   $0x0,-0x28(%rbp)
jbe    11ae <main+0x7e>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <remove_duplicates@plt>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    1156 <main+0x26>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e94(%rip),%r12
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xe9b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <getline@plt>
test   %rax,%rax
je     1170 <main+0x40>
cmp    $0xffffffffffffffff,%rax
je     11ad <main+0x7d>
mov    0x8(%rsp),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    0x8(%rsp),%rdi
call   1040 <remove_duplicates@plt>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %7
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* @stdin
%11 = call i64 @getline(i8** %6, i64* %7, i32 %10)
store i64 %11, i64* %8
%12 = icmp ne i64 %11, -1
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i64, i64* %8
%15 = icmp ugt i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = load i64, i64* %8
%19 = sub i64 %18, 1
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
%21 = load i8*, i8** %6
%22 = call i32 @remove_duplicates(i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %16, %13
br label %9
26: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
br label %7
7: ; preds = %10, %2
%8 = load i32, i32* @stdin
%9 = call i64 @getline(i8** %3, i64* %4, i32 %8)
switch i64 %9, label %11 [
i64 -1, label %19
i64 0, label %10
]
10: ; preds = %7, %11
br label %7
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = add i64 %9, -1
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8 0, i8* %14
%15 = load i8*, i8** %3
%16 = call i32 @remove_duplicates(i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %10
19: ; preds = %7
ret i32 0
}