#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*/ swap(int *, int *);
unsigned int is_permutation(int first_number, int second_number) {
  int a1 = (first_number / 1) % 10;
  int a2 = (first_number / 10) % 10;
  int a3 = (first_number / 100) % 10;
  int a4 = (first_number / 1000) % 10;
  swap(&a1, &a2);
  swap(&a2, &a3);
  swap(&a1, &a2);
  swap(&a3, &a4);
  swap(&a2, &a3);
  swap(&a1, &a2);
  int b1 = (second_number / 1) % 10;
  int b2 = (second_number / 10) % 10;
  int b3 = (second_number / 100) % 10;
  int b4 = (second_number / 1000) % 10;
  swap(&b1, &b2);
  swap(&b2, &b3);
  swap(&b1, &b2);
  swap(&b3, &b4);
  swap(&b2, &b3);
  swap(&b1, &b2);
  return ((a1 == b1) && (a2 == b2) && (a3 == b3) && (a4 == b4));
}


x86 assembly (clang, -O0):
<is_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <swap@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <swap@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <swap@plt>
mov    -0x8(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <swap@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <swap@plt>
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x29(%rbp)
jne    12a9 <is_permutation+0x199>
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0x20(%rbp),%ecx
mov    %al,-0x29(%rbp)
jne    12a9 <is_permutation+0x199>
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x29(%rbp)
jne    12a9 <is_permutation+0x199>
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_permutation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
imul   $0x51eb851f,%rcx,%rsi
imul   $0x10624dd3,%rcx,%rdi
sub    %edx,%ecx
mov    %ecx,0x24(%rsp)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x25,%rsi
add    %eax,%esi
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x26,%rdi
add    %eax,%edi
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
lea    0x24(%rsp),%r15
lea    0x20(%rsp),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
lea    0x1c(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <swap@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
movslq %r14d,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
imul   $0x51eb851f,%rcx,%rsi
imul   $0x10624dd3,%rcx,%rdi
sub    %edx,%ecx
mov    %ecx,0x14(%rsp)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x25,%rsi
add    %eax,%esi
movslq %esi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x26,%rdi
add    %eax,%edi
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
lea    0x14(%rsp),%r14
lea    0x10(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
lea    0xc(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <swap@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <swap@plt>
mov    0x24(%rsp),%ecx
xor    %eax,%eax
cmp    0x14(%rsp),%ecx
jne    1350 <is_permutation+0x240>
mov    0x20(%rsp),%ecx
cmp    0x10(%rsp),%ecx
jne    1350 <is_permutation+0x240>
mov    0x1c(%rsp),%ecx
cmp    0xc(%rsp),%ecx
jne    1350 <is_permutation+0x240>
mov    0x18(%rsp),%ecx
xor    %eax,%eax
cmp    0x8(%rsp),%ecx
sete   %al
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_permutation(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 1
%15 = srem i32 %14, 10
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 10
%18 = srem i32 %17, 10
store i32 %18, i32* %6
%19 = load i32, i32* %3
%20 = sdiv i32 %19, 100
%21 = srem i32 %20, 10
store i32 %21, i32* %7
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 1000
%24 = srem i32 %23, 10
store i32 %24, i32* %8
%25 = call i32 @swap(i32* %5, i32* %6)
%26 = call i32 @swap(i32* %6, i32* %7)
%27 = call i32 @swap(i32* %5, i32* %6)
%28 = call i32 @swap(i32* %7, i32* %8)
%29 = call i32 @swap(i32* %6, i32* %7)
%30 = call i32 @swap(i32* %5, i32* %6)
%31 = load i32, i32* %4
%32 = sdiv i32 %31, 1
%33 = srem i32 %32, 10
store i32 %33, i32* %9
%34 = load i32, i32* %4
%35 = sdiv i32 %34, 10
%36 = srem i32 %35, 10
store i32 %36, i32* %10
%37 = load i32, i32* %4
%38 = sdiv i32 %37, 100
%39 = srem i32 %38, 10
store i32 %39, i32* %11
%40 = load i32, i32* %4
%41 = sdiv i32 %40, 1000
%42 = srem i32 %41, 10
store i32 %42, i32* %12
%43 = call i32 @swap(i32* %9, i32* %10)
%44 = call i32 @swap(i32* %10, i32* %11)
%45 = call i32 @swap(i32* %9, i32* %10)
%46 = call i32 @swap(i32* %11, i32* %12)
%47 = call i32 @swap(i32* %10, i32* %11)
%48 = call i32 @swap(i32* %9, i32* %10)
%49 = load i32, i32* %5
%50 = load i32, i32* %9
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %64
52: ; preds = %2
%53 = load i32, i32* %6
%54 = load i32, i32* %10
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %64
56: ; preds = %52
%57 = load i32, i32* %7
%58 = load i32, i32* %11
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i32, i32* %8
%62 = load i32, i32* %12
%63 = icmp eq i32 %61, %62
br label %64
64: ; preds = %60, %56, %52, %2
%65 = phi i1 [ false, %56 ], [ false, %52 ], [ false, %2 ], [ %63, %60 ]
%66 = zext i1 %65 to i32
ret i32 %66
}

LLVM IR (-O2):
define i32 @is_permutation(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %3 to i8*
%12 = srem i32 %0, 10
store i32 %12, i32* %3
%13 = bitcast i32* %4 to i8*
%14 = sdiv i32 %0, 10
%15 = srem i32 %14, 10
store i32 %15, i32* %4
%16 = bitcast i32* %5 to i8*
%17 = sdiv i32 %0, 100
%18 = srem i32 %17, 10
store i32 %18, i32* %5
%19 = bitcast i32* %6 to i8*
%20 = sdiv i32 %0, 1000
%21 = srem i32 %20, 10
store i32 %21, i32* %6
%22 = call i32 @swap(i32* %3, i32* %4)
%23 = call i32 @swap(i32* %4, i32* %5)
%24 = call i32 @swap(i32* %3, i32* %4)
%25 = call i32 @swap(i32* %5, i32* %6)
%26 = call i32 @swap(i32* %4, i32* %5)
%27 = call i32 @swap(i32* %3, i32* %4)
%28 = bitcast i32* %7 to i8*
%29 = srem i32 %1, 10
store i32 %29, i32* %7
%30 = bitcast i32* %8 to i8*
%31 = sdiv i32 %1, 10
%32 = srem i32 %31, 10
store i32 %32, i32* %8
%33 = bitcast i32* %9 to i8*
%34 = sdiv i32 %1, 100
%35 = srem i32 %34, 10
store i32 %35, i32* %9
%36 = bitcast i32* %10 to i8*
%37 = sdiv i32 %1, 1000
%38 = srem i32 %37, 10
store i32 %38, i32* %10
%39 = call i32 @swap(i32* %7, i32* %8)
%40 = call i32 @swap(i32* %8, i32* %9)
%41 = call i32 @swap(i32* %7, i32* %8)
%42 = call i32 @swap(i32* %9, i32* %10)
%43 = call i32 @swap(i32* %8, i32* %9)
%44 = call i32 @swap(i32* %7, i32* %8)
%45 = load i32, i32* %3
%46 = load i32, i32* %7
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %61
48: ; preds = %2
%49 = load i32, i32* %4
%50 = load i32, i32* %8
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = load i32, i32* %5
%54 = load i32, i32* %9
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i32, i32* %6
%58 = load i32, i32* %10
%59 = icmp eq i32 %57, %58
%60 = zext i1 %59 to i32
br label %61
61: ; preds = %56, %52, %48, %2
%62 = phi i32 [ 0, %52 ], [ 0, %48 ], [ 0, %2 ], [ %60, %56 ]
ret i32 %62
}