#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*/ LC_ALL;
int /*<<< orphan*/ getch();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int strlen(char *);
main() {
  setlocale(LC_ALL, "Portuguese");
  char string[50];
  char string2[50];
  printf("Digite uma palavra: ");
  gets(string);
  printf("Digite outra palavra: ");
  gets(string2);
  int i;
  int x;
  for (i = 0; i < strlen(string); i++) {
    for (x = 0; x < strlen(string2); x++) {
      if (string[i] == string2[x]) {
        i++;
      }
    }
  }
  if (x == strlen(string2)) {
    printf("são anagramas");
  } else {
    printf("não são anagramas");
  }
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <gets@plt>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    1260 <main+0x110>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
cmp    %ecx,%eax
jge    1247 <main+0xf7>
movslq -0x84(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
movslq -0x88(%rbp),%rcx
movsbl -0x80(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    122e <main+0xde>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1233 <main+0xe3>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11da <main+0x8a>
jmp    124c <main+0xfc>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11ab <main+0x5b>
mov    -0x88(%rbp),%eax
mov    %eax,-0x94(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jne    1296 <main+0x146>
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
jmp    12a2 <main+0x152>
lea    0xd9a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1227 <main+0xd7>
xor    %ebx,%ebx
mov    %rsp,%r15
lea    0x40(%rsp),%r14
jmp    11cf <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jge    1208 <main+0xb8>
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %r12d,%r12d
test   %eax,%eax
jle    11c0 <main+0x70>
xchg   %ax,%ax
movslq %ebx,%rbx
movzbl 0x40(%rsp,%rbx,1),%eax
xor    %ecx,%ecx
cmp    (%rsp,%r12,1),%al
sete   %cl
add    %ecx,%ebx
add    $0x1,%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r12
jl     11e0 <main+0x90>
jmp    11c0 <main+0x70>
mov    %rsp,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r12d
lea    0xe22(%rip),%rax
lea    0xe16(%rip),%rdi
cmove  %rax,%rdi
jmp    1236 <main+0xe6>
mov    %rsp,%rdi
call   1030 <strlen@plt>
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getch@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [21 x i8] c"Digite uma palavra: \00"
@.str.2 = [23 x i8] c"Digite outra palavra: \00"
@.str.3 = [15 x i8] c"s\C3\A3o anagramas\00"
@.str.4 = [20 x i8] c"n\C3\A3o s\C3\A3o anagramas\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @LC_ALL
%7 = call i32 @setlocale(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
store i32 0, i32* %4
br label %14
14: ; preds = %45, %0
%15 = load i32, i32* %4
%16 = getelementptr inbounds [50 x i8], [50 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 %48
19: ; preds = %14
store i32 0, i32* %5
br label %20
20: ; preds = %41, %19
%21 = load i32, i32* %5
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %44
25: ; preds = %20
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %30, %35
br i1 %36, label %37, label %40
37: ; preds = %25
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %40
40: ; preds = %37, %25
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %20
44: ; preds = %20
br label %45
45: ; preds = %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %14
48: ; preds = %14
%49 = load i32, i32* %5
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = icmp eq i32 %49, %51
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %57
55: ; preds = %48
%56 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
%58 = call i32 (...) @getch()
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [21 x i8] c"Digite uma palavra: \00"
@.str.2 = [23 x i8] c"Digite outra palavra: \00"
@.str.3 = [15 x i8] c"s\C3\A3o anagramas\00"
@.str.4 = [20 x i8] c"n\C3\A3o s\C3\A3o anagramas\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %5)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @gets(i8* %6)
%11 = call i32 @strlen(i8* %5)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @strlen(i8* %6)
br label %46
15: ; preds = %0, %36
%16 = phi i32 [ %39, %36 ], [ 0, %0 ]
%17 = call i32 @strlen(i8* %6)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %15, %19
%20 = phi i64 [ %30, %19 ], [ 0, %15 ]
%21 = phi i32 [ %29, %19 ], [ %16, %15 ]
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %20
%26 = load i8, i8* %25
%27 = icmp eq i8 %24, %26
%28 = zext i1 %27 to i32
%29 = add nsw i32 %21, %28
%30 = add nuw nsw i64 %20, 1
%31 = call i32 @strlen(i8* %6)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %19, label %34
34: ; preds = %19
%35 = trunc i64 %30 to i32
br label %36
36: ; preds = %34, %15
%37 = phi i32 [ %16, %15 ], [ %29, %34 ]
%38 = phi i32 [ 0, %15 ], [ %35, %34 ]
%39 = add nsw i32 %37, 1
%40 = call i32 @strlen(i8* %5)
%41 = icmp slt i32 %39, %40
br i1 %41, label %15, label %42
42: ; preds = %36
%43 = call i32 @strlen(i8* %6)
%44 = icmp eq i32 %38, %43
%45 = select i1 %44, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0)
br label %46
46: ; preds = %42, %13
%47 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %13 ], [ %45, %42 ]
%48 = call i32 @printf(i8* dereferenceable(1) %47)
%49 = call i32 (...) @getch()
ret i32 0
}