#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 strlen(char *);
int main() {
  int i, j, cont = 0, tam;
  char frase[50];
  printf("entr com um frase: ");
  gets(frase);
  tam = strlen(frase);
  printf("%d\n", tam);
  for (i = 0; i < tam; i++) {
    for (j = i + 1; j < tam; j++) {
      if ((i != j) && frase[i] == frase[j]) {
        cont++;
        break;
      }
    }
  }
  printf("%d\n", cont);
  tam = tam - cont;
  printf("A frase tem %d letras diferentes\n", tam);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fc <main+0xcc>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e9 <main+0xb9>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11d6 <main+0xa6>
movslq -0x8(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x50(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11d6 <main+0xa6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e9 <main+0xb9>
jmp    11db <main+0xab>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
jmp    11ee <main+0xbe>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1181 <main+0x51>
mov    -0x10(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xec1(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xeaf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jle    11d0 <main+0xa0>
mov    %r14d,%eax
lea    0x1(%rsp),%rcx
lea    -0x1(%rax),%rdx
xor    %esi,%esi
xor    %ebp,%ebp
jmp    11a0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
cmp    %rax,%rsi
je     11d0 <main+0xa0>
mov    %rsi,%rdi
add    $0x1,%rsi
cmp    %rax,%rsi
jae    1193 <main+0x63>
mov    (%rsp,%rdi,1),%bl
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    (%rcx,%rdi,1),%bl
je     1190 <main+0x60>
add    $0x1,%rdi
cmp    %rdi,%rdx
jne    11c0 <main+0x90>
jmp    1193 <main+0x63>
lea    0xe3d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
sub    %ebp,%r14d
lea    0xe2e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"entr com um frase: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [34 x i8] c"A frase tem %d letras diferentes\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %34
8: ; preds = %0
%9 = zext i32 %5 to i64
%10 = zext i32 %5 to i64
br label %11
11: ; preds = %8, %30
%12 = phi i64 [ 0, %8 ], [ %15, %30 ]
%13 = phi i64 [ 1, %8 ], [ %32, %30 ]
%14 = phi i32 [ 0, %8 ], [ %31, %30 ]
%15 = add nuw nsw i64 %12, 1
%16 = icmp ult i64 %15, %9
br i1 %16, label %17, label %30
17: ; preds = %11
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %12
%19 = load i8, i8* %18
br label %20
20: ; preds = %27, %17
%21 = phi i64 [ %13, %17 ], [ %28, %27 ]
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %19, %23
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = add nsw i32 %14, 1
br label %30
27: ; preds = %20
%28 = add nuw nsw i64 %21, 1
%29 = icmp eq i64 %28, %10
br i1 %29, label %30, label %20
30: ; preds = %27, %11, %25
%31 = phi i32 [ %26, %25 ], [ %14, %11 ], [ %14, %27 ]
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %15, %10
br i1 %33, label %34, label %11
34: ; preds = %30, %0
%35 = phi i32 [ 0, %0 ], [ %31, %30 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = sub nsw i32 %5, %35
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %37)
ret i32 0
}