#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 */
char *quicksort(char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int isPermutation(char *s1, char *s2) {
  int len = strlen(s1);
  char *newS1 = quicksort(s1, 0, len - 1);
  char *newS2 = quicksort(s2, 0, len - 1);
  if (len != (int)strlen(s2)) {
    return 0;
  }
  if (strcmp(newS1, newS2) != 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isPermutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <quicksort@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <quicksort@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
je     119e <isPermutation+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <isPermutation+0x98>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c1 <isPermutation+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <isPermutation+0x98>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPermutation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r13d
lea    -0x1(%r13),%ebp
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <quicksort@plt>
mov    %rax,%rbx
mov    %r12,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <quicksort@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r13d
jne    1190 <isPermutation+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = call i8* @quicksort(i8* %11, i32 0, i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 1
%18 = call i8* @quicksort(i8* %15, i32 0, i32 %17)
store i8* %18, i8** %8
%19 = load i32, i32* %6
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %2
store i32 0, i32* %3
br label %31
24: ; preds = %2
%25 = load i8*, i8** %7
%26 = load i8*, i8** %8
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %3
br label %31
30: ; preds = %24
store i32 1, i32* %3
br label %31
31: ; preds = %30, %29, %23
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @isPermutation(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, -1
%5 = tail call i8* @quicksort(i8* %0, i32 0, i32 %4)
%6 = tail call i8* @quicksort(i8* %1, i32 0, i32 %4)
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp eq i32 %3, %7
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = tail call i64 @strcmp(i8* %5, i8* %6)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ 0, %2 ], [ %12, %9 ]
ret i32 %14
}