#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ *strchr(char *, char const);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, int);
char *chaine_vers_caracteres_uniques(const char *chaine) {
  char *ensemble, *retour;
  ensemble = (char *)malloc(sizeof(char) * 26);
  strcpy(ensemble, "");
  int taille = strlen(chaine), i;
  for (i = 0; i < taille; i++) {
    if (strchr(ensemble, chaine[i]) == NULL) {
      strncat(ensemble, &chaine[i], 1);
    }
  }
  retour = (char *)malloc(sizeof(char) * (strlen(ensemble) + 1));
  strcpy(retour, ensemble);
  return retour;
}


x86 assembly (clang, -O0):
<chaine_vers_caracteres_uniques>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1a,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e4 <chaine_vers_caracteres_uniques+0x94>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    11d1 <chaine_vers_caracteres_uniques+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1060 <strncat@plt>
jmp    11d6 <chaine_vers_caracteres_uniques+0x86>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118d <chaine_vers_caracteres_uniques+0x3d>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaine_vers_caracteres_uniques>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x1a,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe94(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11bd <chaine_vers_caracteres_uniques+0x6d>
mov    %eax,%ebx
jmp    119a <chaine_vers_caracteres_uniques+0x4a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
add    $0xffffffffffffffff,%rbx
je     11bd <chaine_vers_caracteres_uniques+0x6d>
movsbl (%r15),%esi
mov    %r14,%rdi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1190 <chaine_vers_caracteres_uniques+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1060 <strncat@plt>
jmp    1190 <chaine_vers_caracteres_uniques+0x40>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @chaine_vers_caracteres_uniques(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = call i64 @malloc(i32 26)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %5
store i32 0, i32* %6
br label %13
13: ; preds = %34, %1
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %37
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i8*, i8** %2
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i32* @strchr(i8* %18, i8 signext %23)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %33
26: ; preds = %17
%27 = load i8*, i8** %3
%28 = load i8*, i8** %2
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = call i32 @strncat(i8* %27, i8* %31, i32 1)
br label %33
33: ; preds = %26, %17
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %13
37: ; preds = %13
%38 = load i8*, i8** %3
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = mul i64 1, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %4
%46 = load i8*, i8** %4
%47 = load i8*, i8** %3
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = load i8*, i8** %4
ret i8* %49
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @chaine_vers_caracteres_uniques(i8* %0) {
%2 = tail call i64 @malloc(i32 26)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %17
%10 = phi i64 [ 0, %7 ], [ %18, %17 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32* @strchr(i8* %3, i8 signext %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @strncat(i8* %3, i8* %11, i32 1)
br label %17
17: ; preds = %9, %15
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %20, label %9
20: ; preds = %17, %1
%21 = tail call i32 @strlen(i8* %3)
%22 = add nsw i32 %21, 1
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 @strcpy(i8* %24, i8* %3)
ret i8* %24
}