#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*/ markSeen(char *, int *);
int strlen(char *);
int isAnagram(char *str1, char *str2) {
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  if (len1 != len2) {
    return 0;
  } else {
    int hasSeen1[256] = {0};
    int hasSeen2[256] = {0};
    markSeen(str1, hasSeen1);
    markSeen(str2, hasSeen2);
    for (int i = 0; i < len1; i++) {
      if (hasSeen1[i] != hasSeen2[i]) {
        return 0;
      }
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<isAnagram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1173 <isAnagram+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1220 <isAnagram+0xf0>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1040 <markSeen@plt>
mov    -0x18(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1040 <markSeen@plt>
movl   $0x0,-0x824(%rbp)
mov    -0x824(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1219 <isAnagram+0xe9>
movslq -0x824(%rbp),%rax
mov    -0x420(%rbp,%rax,4),%eax
movslq -0x824(%rbp),%rcx
cmp    -0x820(%rbp,%rcx,4),%eax
je     1200 <isAnagram+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    1220 <isAnagram+0xf0>
jmp    1205 <isAnagram+0xd5>
mov    -0x824(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x824(%rbp)
jmp    11c3 <isAnagram+0x93>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAnagram>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r15
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
cmp    %eax,%r14d
jne    11e7 <isAnagram+0xb7>
lea    0x400(%rsp),%r12
xor    %ebx,%ebx
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%r13
mov    $0x400,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <markSeen@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <markSeen@plt>
test   %r14d,%r14d
jle    11e2 <isAnagram+0xb2>
mov    0x400(%rsp),%eax
cmp    (%rsp),%eax
jne    11e7 <isAnagram+0xb7>
mov    %r14d,%eax
mov    $0x1,%edx
nopl   0x0(%rax)
mov    %rdx,%rcx
cmp    %rdx,%rax
je     11d8 <isAnagram+0xa8>
mov    0x400(%rsp,%rcx,4),%esi
lea    0x1(%rcx),%rdx
cmp    (%rsp,%rcx,4),%esi
je     11c0 <isAnagram+0x90>
xor    %ebx,%ebx
cmp    %rax,%rcx
setae  %bl
jmp    11e7 <isAnagram+0xb7>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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