#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*/ printf(char *, char *, char *);
int /*<<< orphan*/ sort(char *, int /*<<< orphan*/, int);
int str_length(char *);
int is_anagram(char *a, char *b) {
  int len1, len2;
  int i;
  len1 = str_length(a);
  len2 = str_length(b);
  sort(a, 0, len1 - 1);
  sort(b, 0, len2 - 1);
  printf("\nAfter sort a = %s, b = %s", a, b);
  if (len1 != len2)
    return 0;
  else {
    for (i = 0; i < len1; i++) {
      if (a[i] == b[i])
        ;
      else
        return 0;
    }
  }
  if (i == len2)
    return 1;
}


x86 assembly (clang, -O0):
<is_anagram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <str_length@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <str_length@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <sort@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <sort@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11a6 <is_anagram+0x76>
movl   $0x0,-0x4(%rbp)
jmp    1215 <is_anagram+0xe5>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11fd <is_anagram+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11de <is_anagram+0xae>
jmp    11ea <is_anagram+0xba>
movl   $0x0,-0x4(%rbp)
jmp    1215 <is_anagram+0xe5>
jmp    11ef <is_anagram+0xbf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ad <is_anagram+0x7d>
jmp    1202 <is_anagram+0xd2>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1215 <is_anagram+0xe5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_anagram>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <str_length@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1050 <str_length@plt>
mov    %eax,%ebp
lea    -0x1(%r12),%edx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <sort@plt>
lea    -0x1(%rbp),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <sort@plt>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
cmp    %ebp,%r12d
jne    11b8 <is_anagram+0x88>
mov    $0x1,%r15d
test   %r12d,%r12d
jle    11b8 <is_anagram+0x88>
mov    %r12d,%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx,%rcx,1),%edx
cmp    (%r14,%rcx,1),%dl
jne    11b5 <is_anagram+0x85>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11a0 <is_anagram+0x70>
jmp    11b8 <is_anagram+0x88>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"\0AAfter sort a = %s, b = %s\00"
define i32 @is_anagram(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @str_length(i8* %9)
store i32 %10, i32* %6
%11 = load i8*, i8** %5
%12 = call i32 @str_length(i8* %11)
store i32 %12, i32* %7
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 1
%16 = call i32 @sort(i8* %13, i32 0, i32 %15)
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 1
%20 = call i32 @sort(i8* %17, i32 0, i32 %19)
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %2
store i32 0, i32* %3
br label %59
28: ; preds = %2
store i32 0, i32* %8
br label %29
29: ; preds = %50, %28
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %53
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i8*, i8** %5
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %39, %45
br i1 %46, label %47, label %48
47: ; preds = %33
br label %49
48: ; preds = %33
store i32 0, i32* %3
br label %59
49: ; preds = %47
br label %50
50: ; preds = %49
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %29
53: ; preds = %29
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = load i32, i32* %7
%57 = icmp eq i32 %55, %56
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 1, i32* %3
br label %59
59: ; preds = %27, %48, %58, %54
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@.str = [27 x i8] c"\0AAfter sort a = %s, b = %s\00"
define i32 @is_anagram(i8* %0, i8* %1) {
%3 = tail call i32 @str_length(i8* %0)
%4 = tail call i32 @str_length(i8* %1)
%5 = add nsw i32 %3, -1
%6 = tail call i32 @sort(i8* %0, i32 0, i32 %5)
%7 = add nsw i32 %4, -1
%8 = tail call i32 @sort(i8* %1, i32 0, i32 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%10 = icmp eq i32 %3, %4
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = icmp sgt i32 %3, 0
br i1 %12, label %13, label %25
13: ; preds = %11
%14 = zext i32 %3 to i64
br label %17
15: ; preds = %17
%16 = icmp eq i64 %24, %14
br i1 %16, label %25, label %17
17: ; preds = %13, %15
%18 = phi i64 [ 0, %13 ], [ %24, %15 ]
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %1, i64 %18
%22 = load i8, i8* %21
%23 = icmp eq i8 %20, %22
%24 = add nuw nsw i64 %18, 1
br i1 %23, label %15, label %25
25: ; preds = %17, %15, %11, %2
%26 = phi i32 [ 0, %2 ], [ 1, %11 ], [ 0, %17 ], [ 1, %15 ]
ret i32 %26
}