#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;
scalar_t__ contadigitos(int, int);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
main() {
  setlocale(LC_ALL, "Portuguese");
  int a, b, d;
  int perm;
  printf("Digite o primeiro número inteiros: ");
  scanf("%d", &a);
  printf("Digite o segundo número inteiro: ");
  scanf("%d", &b);
  perm = 1;
  for (d = 1; d <= 9; d++)
    if (contadigitos(a, d) != contadigitos(b, d))
      perm = 0;
  if (perm == 1)
    printf("%d é permutacao de %d\n", a, b);
  else
    printf("%d nao é permutacao de %d\n", a, b);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1040 <setlocale@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jg     120c <main+0xbc>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <contadigitos@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <contadigitos@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11f9 <main+0xa9>
movl   $0x0,-0x14(%rbp)
jmp    11fe <main+0xae>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11be <main+0x6e>
cmpl   $0x1,-0x14(%rbp)
jne    122f <main+0xdf>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <main+0xf3>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <setlocale@plt>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeae(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%esi
call   1070 <contadigitos@plt>
mov    %rax,%rbx
mov    (%rsp),%edi
mov    $0x1,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r14
xor    %rbx,%r14
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r15
mov    (%rsp),%edi
mov    $0x2,%esi
call   1070 <contadigitos@plt>
mov    %rax,%rbx
xor    %r15,%rbx
or     %r14,%rbx
mov    0x4(%rsp),%edi
mov    $0x3,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r14
mov    (%rsp),%edi
mov    $0x3,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r15
xor    %r14,%r15
mov    0x4(%rsp),%edi
mov    $0x4,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r12
mov    (%rsp),%edi
mov    $0x4,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r14
xor    %r12,%r14
or     %r15,%r14
or     %rbx,%r14
mov    0x4(%rsp),%edi
mov    $0x5,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r15
mov    (%rsp),%edi
mov    $0x5,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r12
xor    %r15,%r12
mov    0x4(%rsp),%edi
mov    $0x6,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r15
mov    (%rsp),%edi
mov    $0x6,%esi
call   1070 <contadigitos@plt>
mov    %rax,%rbx
xor    %r15,%rbx
or     %r12,%rbx
mov    0x4(%rsp),%edi
mov    $0x7,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r12
mov    (%rsp),%edi
mov    $0x7,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r15
xor    %r12,%r15
or     %rbx,%r15
or     %r14,%r15
mov    0x4(%rsp),%edi
mov    $0x8,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r14
mov    (%rsp),%edi
mov    $0x8,%esi
call   1070 <contadigitos@plt>
mov    %rax,%rbx
xor    %r14,%rbx
mov    0x4(%rsp),%edi
mov    $0x9,%esi
call   1070 <contadigitos@plt>
mov    %rax,%r14
mov    (%rsp),%edi
mov    $0x9,%esi
call   1070 <contadigitos@plt>
xor    %r14,%rax
or     %rbx,%rax
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xd4a(%rip),%rcx
lea    0xd5b(%rip),%rdi
or     %r15,%rax
cmove  %rcx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x8,%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 = [37 x i8] c"Digite o primeiro n\C3\BAmero inteiros: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Digite o segundo n\C3\BAmero inteiro: \00"
@.str.4 = [24 x i8] c"%d \C3\A9 permutacao de %d\0A\00"
@.str.5 = [28 x i8] c"%d nao \C3\A9 permutacao de %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%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 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 1, i32* %5
store i32 1, i32* %4
br label %12
12: ; preds = %25, %0
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 9
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = call i64 @contadigitos(i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i64 @contadigitos(i32 %19, i32 %20)
%22 = icmp ne i64 %18, %21
br i1 %22, label %23, label %24
23: ; preds = %15
store i32 0, i32* %5
br label %24
24: ; preds = %23, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %12
28: ; preds = %12
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33)
br label %39
35: ; preds = %28
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %37)
br label %39
39: ; preds = %35, %31
%40 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [37 x i8] c"Digite o primeiro n\C3\BAmero inteiros: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Digite o segundo n\C3\BAmero inteiro: \00"
@.str.4 = [24 x i8] c"%d \C3\A9 permutacao de %d\0A\00"
@.str.5 = [28 x i8] c"%d nao \C3\A9 permutacao de %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%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 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = call i64 @contadigitos(i32 %11, i32 1)
%13 = load i32, i32* %2
%14 = call i64 @contadigitos(i32 %13, i32 1)
%15 = icmp eq i64 %12, %14
%16 = load i32, i32* %1
%17 = call i64 @contadigitos(i32 %16, i32 2)
%18 = load i32, i32* %2
%19 = call i64 @contadigitos(i32 %18, i32 2)
%20 = icmp eq i64 %17, %19
%21 = load i32, i32* %1
%22 = call i64 @contadigitos(i32 %21, i32 3)
%23 = load i32, i32* %2
%24 = call i64 @contadigitos(i32 %23, i32 3)
%25 = icmp eq i64 %22, %24
%26 = load i32, i32* %1
%27 = call i64 @contadigitos(i32 %26, i32 4)
%28 = load i32, i32* %2
%29 = call i64 @contadigitos(i32 %28, i32 4)
%30 = icmp eq i64 %27, %29
%31 = load i32, i32* %1
%32 = call i64 @contadigitos(i32 %31, i32 5)
%33 = load i32, i32* %2
%34 = call i64 @contadigitos(i32 %33, i32 5)
%35 = icmp eq i64 %32, %34
%36 = load i32, i32* %1
%37 = call i64 @contadigitos(i32 %36, i32 6)
%38 = load i32, i32* %2
%39 = call i64 @contadigitos(i32 %38, i32 6)
%40 = icmp eq i64 %37, %39
%41 = load i32, i32* %1
%42 = call i64 @contadigitos(i32 %41, i32 7)
%43 = load i32, i32* %2
%44 = call i64 @contadigitos(i32 %43, i32 7)
%45 = icmp eq i64 %42, %44
%46 = load i32, i32* %1
%47 = call i64 @contadigitos(i32 %46, i32 8)
%48 = load i32, i32* %2
%49 = call i64 @contadigitos(i32 %48, i32 8)
%50 = icmp eq i64 %47, %49
%51 = load i32, i32* %1
%52 = call i64 @contadigitos(i32 %51, i32 9)
%53 = load i32, i32* %2
%54 = call i64 @contadigitos(i32 %53, i32 9)
%55 = icmp eq i64 %52, %54
%56 = select i1 %55, i1 %50, i1 false
%57 = select i1 %56, i1 %45, i1 false
%58 = select i1 %57, i1 %40, i1 false
%59 = select i1 %58, i1 %35, i1 false
%60 = select i1 %59, i1 %30, i1 false
%61 = select i1 %60, i1 %25, i1 false
%62 = select i1 %61, i1 %20, i1 false
%63 = select i1 %62, i1 %15, i1 false
%64 = load i32, i32* %1
%65 = load i32, i32* %2
%66 = select i1 %63, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %66, i32 %64, i32 %65)
%68 = call i32 (...) @getch()
ret i32 0
}