#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main() {
  char input[100], output[100];
  char visti[100];
  int i, k, m = 0, n = 0;
  bool trovato;
  printf("Rimovitore di lettere duplicate");
  printf("\nInserisci stringa: ");
  gets(input);
  for (i = 0; i < strlen(input); i++) {
    for (k = 0, trovato = false; k < n && !trovato; k++) {
      if (input[i] == visti[k]) {
        trovato = true;
      }
    }
    if (!trovato) {
      output[m] = input[i];
      visti[n] = input[i];
      m++, n++;
    }
  }
  puts(output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x15c(%rbp)
movl   $0x0,-0x160(%rbp)
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
movl   $0x0,-0x154(%rbp)
mov    -0x154(%rbp),%eax
mov    %eax,-0x168(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x168(%rbp),%eax
cmp    %ecx,%eax
jge    12c5 <main+0x185>
movl   $0x0,-0x158(%rbp)
movl   $0x0,-0x164(%rbp)
mov    -0x158(%rbp),%ecx
xor    %eax,%eax
cmp    -0x160(%rbp),%ecx
mov    %al,-0x169(%rbp)
jge    11f6 <main+0xb6>
cmpl   $0x0,-0x164(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x169(%rbp)
mov    -0x169(%rbp),%al
test   $0x1,%al
jne    1209 <main+0xc9>
jmp    124f <main+0x10f>
movslq -0x154(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
movslq -0x158(%rbp),%rcx
movsbl -0x150(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    1236 <main+0xf6>
movl   $0x1,-0x164(%rbp)
jmp    123b <main+0xfb>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
jmp    11ca <main+0x8a>
cmpl   $0x0,-0x164(%rbp)
jne    12ac <main+0x16c>
movslq -0x154(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x15c(%rbp),%rax
mov    %cl,-0xe0(%rbp,%rax,1)
movslq -0x154(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x160(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
mov    -0x160(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x160(%rbp)
jmp    12b1 <main+0x171>
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    1191 <main+0x51>
lea    -0xe0(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x150,%rsp
lea    0xeaa(%rip),%rdi
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e8 <main+0xa8>
xor    %ebp,%ebp
mov    %rsp,%r14
xor    %r12d,%r12d
xor    %r15d,%r15d
jmp    11c0 <main+0x80>
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbp,1),%al
movslq %r15d,%r15
mov    %al,0xe0(%rsp,%r15,1)
movslq %r12d,%rcx
mov    %al,0x70(%rsp,%rcx,1)
add    $0x1,%r15d
add    $0x1,%r12d
add    $0x1,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11e8 <main+0xa8>
test   %r12d,%r12d
jle    1190 <main+0x50>
mov    (%rsp,%rbp,1),%al
mov    %r12d,%ecx
mov    $0x1,%edx
movzbl 0x6f(%rsp,%rdx,1),%ebx
cmp    %rcx,%rdx
jae    11e2 <main+0xa2>
add    $0x1,%rdx
cmp    %bl,%al
jne    11d0 <main+0x90>
cmp    %bl,%al
jne    1190 <main+0x50>
jmp    11ad <main+0x6d>
lea    0xe0(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Rimovitore di lettere duplicate\00"
@.str.1 = [21 x i8] c"\0AInserisci stringa: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
store i32 0, i32* %5
br label %14
14: ; preds = %70, %0
%15 = load i32, i32* %5
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %73
19: ; preds = %14
store i32 0, i32* %6
store i32 0, i32* %9
br label %20
20: ; preds = %44, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %24, %20
%29 = phi i1 [ false, %20 ], [ %27, %24 ]
br i1 %29, label %30, label %47
30: ; preds = %28
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %35, %40
br i1 %41, label %42, label %43
42: ; preds = %30
store i32 1, i32* %9
br label %43
43: ; preds = %42, %30
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %20
47: ; preds = %28
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
br i1 %49, label %69, label %50
50: ; preds = %47
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %56
store i8 %54, i8* %57
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %63
store i8 %61, i8* %64
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %69
69: ; preds = %50, %47
br label %70
70: ; preds = %69
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %14
73: ; preds = %14
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%75 = call i32 @puts(i8* %74)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Rimovitore di lettere duplicate\00"
@.str.1 = [21 x i8] c"\0AInserisci stringa: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @gets(i8* %4)
%10 = call i32 @strlen(i8* %4)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %46
12: ; preds = %0, %39
%13 = phi i64 [ %42, %39 ], [ 0, %0 ]
%14 = phi i32 [ %41, %39 ], [ 0, %0 ]
%15 = phi i32 [ %40, %39 ], [ 0, %0 ]
%16 = icmp sgt i32 %14, 0
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%19 = load i8, i8* %18
%20 = zext i32 %14 to i64
br label %21
21: ; preds = %17, %21
%22 = phi i64 [ 0, %17 ], [ %26, %21 ]
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp ne i8 %19, %24
%26 = add nuw nsw i64 %22, 1
%27 = icmp ult i64 %26, %20
%28 = select i1 %27, i1 %25, i1 false
br i1 %28, label %21, label %29
29: ; preds = %21
br i1 %25, label %30, label %39
30: ; preds = %12, %29
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%32 = load i8, i8* %31
%33 = sext i32 %15 to i64
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %33
store i8 %32, i8* %34
%35 = sext i32 %14 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %35
store i8 %32, i8* %36
%37 = add nsw i32 %15, 1
%38 = add nsw i32 %14, 1
br label %39
39: ; preds = %29, %30
%40 = phi i32 [ %15, %29 ], [ %37, %30 ]
%41 = phi i32 [ %14, %29 ], [ %38, %30 ]
%42 = add nuw nsw i64 %13, 1
%43 = call i32 @strlen(i8* %4)
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %12, label %46
46: ; preds = %39, %0
%47 = call i32 @puts(i8* %5)
ret i32 0
}