#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 */
scalar_t__ strlen(char *);
bool isPermutation(char *str1, char *str2) {
  int charactersFrequency[128] = {};
  if (strlen(str1) != strlen(str2)) {
    return false;
  }
  while (*str1) {
    charactersFrequency[(int)*str1]++;
    str1++;
  }
  while (*str2) {
    if (--charactersFrequency[(int)*str2] < 0) {
      return false;
    }
    str2++;
  }
  return true;
}


x86 assembly (clang, -O0):
<isPermutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x228(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x228(%rbp),%rax
cmp    %rcx,%rax
je     117e <isPermutation+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    1215 <isPermutation+0xf5>
jmp    1183 <isPermutation+0x63>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bb <isPermutation+0x9b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cltq
mov    -0x220(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x220(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1183 <isPermutation+0x63>
jmp    11c0 <isPermutation+0xa0>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     120e <isPermutation+0xee>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movslq %eax,%rcx
mov    -0x220(%rbp,%rcx,4),%eax
add    $0xffffffff,%eax
mov    %eax,-0x220(%rbp,%rcx,4)
cmp    $0x0,%eax
jge    11fd <isPermutation+0xdd>
movl   $0x0,-0x4(%rbp)
jmp    1215 <isPermutation+0xf5>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11c0 <isPermutation+0xa0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPermutation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsp,%rdi
xor    %r14d,%r14d
mov    $0x200,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r15
jne    11b2 <isPermutation+0x92>
mov    0x0(%rbp),%al
test   %al,%al
je     1184 <isPermutation+0x64>
add    $0x1,%rbp
nopl   0x0(%rax,%rax,1)
movsbq %al,%rax
addl   $0x1,(%rsp,%rax,4)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1170 <isPermutation+0x50>
mov    (%rbx),%al
test   %al,%al
je     11ac <isPermutation+0x8c>
add    $0x1,%rbx
xchg   %ax,%ax
movsbq %al,%rax
mov    (%rsp,%rax,4),%ecx
lea    -0x1(%rcx),%edx
mov    %edx,(%rsp,%rax,4)
test   %ecx,%ecx
jle    11b2 <isPermutation+0x92>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <isPermutation+0x70>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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