#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 */
typedef int /*<<< orphan*/ nums2;
typedef int /*<<< orphan*/ nums1;

/* Variables and functions */
int /*<<< orphan*/ memcmp(int *, int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int is_permutation(int n1, int n2) {
  int nums1[10], nums2[10];
  memset(nums1, 0, sizeof(nums1));
  memset(nums2, 0, sizeof(nums2));
  while (n1) {
    int digit = n1 % 10;
    n1 /= 10;
    nums1[digit]++;
  }
  while (n2) {
    int digit = n2 % 10;
    n2 /= 10;
    nums2[digit]++;
  }
  return !memcmp(nums1, nums2, sizeof(nums1));
}


x86 assembly (clang, -O0):
<is_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
je     1188 <is_permutation+0x68>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x64(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
movslq -0x64(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    114e <is_permutation+0x2e>
jmp    118d <is_permutation+0x6d>
cmpl   $0x0,-0x8(%rbp)
je     11c7 <is_permutation+0xa7>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x68(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x60(%rbp,%rax,4)
jmp    118d <is_permutation+0x6d>
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x28,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_permutation>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
test   %ebx,%ebx
je     1181 <is_permutation+0x61>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
movslq %edx,%rcx
addl   $0x1,0x30(%rsp,%rcx,4)
add    $0x9,%eax
cmp    $0x13,%eax
jae    1150 <is_permutation+0x30>
test   %r14d,%r14d
je     11c2 <is_permutation+0xa2>
cs nopw 0x0(%rax,%rax,1)
movslq %r14d,%rax
imul   $0x66666667,%rax,%r14
mov    %r14,%rcx
shr    $0x3f,%rcx
sar    $0x22,%r14
add    %ecx,%r14d
lea    (%r14,%r14,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
movslq %edx,%rcx
addl   $0x1,(%rsp,%rcx,4)
add    $0x9,%eax
cmp    $0x12,%eax
ja     1190 <is_permutation+0x70>
lea    0x30(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x28,%edx
call   1040 <memcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @is_permutation(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 eq i32 %0, 0
br i1 %11, label %12, label %14
12: ; preds = %14, %2
%13 = icmp eq i32 %1, 0
br i1 %13, label %34, label %24
14: ; preds = %2, %14
%15 = phi i32 [ %17, %14 ], [ %0, %2 ]
%16 = srem i32 %15, 10
%17 = sdiv i32 %15, 10
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
%22 = add i32 %15, 9
%23 = icmp ult i32 %22, 19
br i1 %23, label %12, label %14
24: ; preds = %12, %24
%25 = phi i32 [ %27, %24 ], [ %1, %12 ]
%26 = srem i32 %25, 10
%27 = sdiv i32 %25, 10
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = add i32 %25, 9
%33 = icmp ult i32 %32, 19
br i1 %33, label %34, label %24
34: ; preds = %24, %12
%35 = call i32 @memcmp(i32* %7, i32* %9, i32 40)
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
ret i32 %37
}