#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*/ memcmp(int *, int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int same_digits(int a, int b) {
  int digits[10];
  int goal[10];
  memset(digits, 0, 10 * sizeof(int));
  memset(goal, 0, 10 * sizeof(int));
  for (; a > 0; a /= 10) {
    --digits[a % 10];
  }
  for (; b > 0; b /= 10) {
    ++digits[b % 10];
  }
  return !memcmp(digits, goal, 10);
}


x86 assembly (clang, -O0):
<same_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1184 <same_digits+0x64>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    114e <same_digits+0x2e>
jmp    1189 <same_digits+0x69>
cmpl   $0x0,-0x8(%rbp)
jle    11bf <same_digits+0x9f>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1189 <same_digits+0x69>
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<same_digits>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
test   %ebp,%ebp
jle    117f <same_digits+0x5f>
mov    $0xcccccccd,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ebp,%esi
sub    %edx,%esi
addl   $0xffffffff,(%rsp,%rsi,4)
cmp    $0xa,%ebp
mov    %ecx,%ebp
jae    1160 <same_digits+0x40>
test   %ebx,%ebx
jle    11af <same_digits+0x8f>
mov    $0xcccccccd,%eax
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ebx,%esi
sub    %edx,%esi
addl   $0x1,(%rsp,%rsi,4)
cmp    $0x9,%ebx
mov    %ecx,%ebx
ja     1190 <same_digits+0x70>
mov    %rsp,%rdi
lea    0x30(%rsp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @same_digits(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
%6 = alloca [10 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%8 = call i32 @memset(i32* %7, i32 0, i32 40)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 40)
br label %11
11: ; preds = %21, %2
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %3
%16 = srem i32 %15, 10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, -1
store i32 %20, i32* %18
br label %21
21: ; preds = %14
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 10
store i32 %23, i32* %3
br label %11
24: ; preds = %11
br label %25
25: ; preds = %35, %24
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %4
%30 = srem i32 %29, 10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
br label %35
35: ; preds = %28
%36 = load i32, i32* %4
%37 = sdiv i32 %36, 10
store i32 %37, i32* %4
br label %25
38: ; preds = %25
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%41 = call i32 @memcmp(i32* %39, i32* %40, i32 10)
%42 = icmp ne i32 %41, 0
%43 = xor i1 %42, true
%44 = zext i1 %43 to i32
ret i32 %44
}

LLVM IR (-O2):
define i32 @same_digits(i32 %0, i32 %1) {
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = bitcast [10 x i32]* %3 to i8*
%6 = bitcast [10 x i32]* %4 to i8*
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%8 = call i32 @memset(i32* %7, i32 0, i32 40)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 40)
%11 = icmp sgt i32 %0, 0
br i1 %11, label %14, label %12
12: ; preds = %14, %2
%13 = icmp sgt i32 %1, 0
br i1 %13, label %23, label %32
14: ; preds = %2, %14
%15 = phi i32 [ %21, %14 ], [ %0, %2 ]
%16 = urem i32 %15, 10
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, -1
store i32 %20, i32* %18
%21 = udiv i32 %15, 10
%22 = icmp ult i32 %15, 10
br i1 %22, label %12, label %14
23: ; preds = %12, %23
%24 = phi i32 [ %30, %23 ], [ %1, %12 ]
%25 = urem i32 %24, 10
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
%30 = udiv i32 %24, 10
%31 = icmp ult i32 %24, 10
br i1 %31, label %32, label %23
32: ; preds = %23, %12
%33 = call i32 @memcmp(i32* %7, i32* %9, i32 10)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
ret i32 %35
}