#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 */
typedef int /*<<< orphan*/ count2;
typedef int /*<<< orphan*/ count1;

/* Variables and functions */
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char str1[100], str2[100];
  printf("Enter 1st string\n");
  scanf("%s", str1);
  printf("Enter 2nd string\n");
  scanf("%s", str2);
  int count1[256], count2[256];
  memset(count1, 0, sizeof(count1));
  memset(count2, 0, sizeof(count2));
  if (strlen(str1) != strlen(str2)) {
    printf("The strings are not anagrams");
    return 0;
  }
  int i;
  for (i = 0; i < strlen(str1); i++) {
    count1[str1[i] - 'a']++;
    count2[str2[i] - 'a']++;
  }
  for (i = 0; i < 256; i++) {
    if (count1[i] != count2[i]) {
      printf("The strings are not anagrams");
      return 0;
    }
  }
  printf("The strings are anagrams");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1060 <scanf@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x4e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x8e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x8e8(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8e8(%rbp),%eax
cmp    %ecx,%eax
je     11f6 <main+0xb6>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f9 <main+0x1b9>
movl   $0x0,-0x8e4(%rbp)
mov    -0x8e4(%rbp),%eax
mov    %eax,-0x8ec(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8ec(%rbp),%eax
cmp    %ecx,%eax
jge    1280 <main+0x140>
movslq -0x8e4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
sub    $0x61,%eax
cltq
mov    -0x4e0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x4e0(%rbp,%rax,4)
movslq -0x8e4(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
sub    $0x61,%eax
cltq
mov    -0x8e0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x8e0(%rbp,%rax,4)
mov    -0x8e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8e4(%rbp)
jmp    1200 <main+0xc0>
movl   $0x0,-0x8e4(%rbp)
cmpl   $0x100,-0x8e4(%rbp)
jge    12ed <main+0x1ad>
movslq -0x8e4(%rbp),%rax
mov    -0x4e0(%rbp,%rax,4),%eax
movslq -0x8e4(%rbp),%rcx
cmp    -0x8e0(%rbp,%rcx,4),%eax
je     12d4 <main+0x194>
lea    0xd64(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f9 <main+0x1b9>
jmp    12d9 <main+0x199>
mov    -0x8e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8e4(%rbp)
jmp    128a <main+0x14a>
lea    0xd50(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x8e0,%rsp
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe91(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0x4e0(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    0xe0(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0xe29(%rip),%r14
cmp    %eax,%ebx
jne    128f <main+0x13f>
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    122e <main+0xde>
xor    %ebx,%ebx
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbq (%rsp,%rbx,1),%rax
addl   $0x1,0x35c(%rsp,%rax,4)
01
movsbq 0x70(%rsp,%rbx,1),%rax
addl   $0x1,-0xa4(%rsp,%rax,4)
01
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1200 <main+0xb0>
xor    %eax,%eax
lea    0xde9(%rip),%rcx
nopw   0x0(%rax,%rax,1)
mov    0x4e0(%rsp,%rax,4),%edx
cmp    0xe0(%rsp,%rax,4),%edx
jne    128f <main+0x13f>
mov    0x4e4(%rsp,%rax,4),%edx
cmp    0xe4(%rsp,%rax,4),%edx
jne    128f <main+0x13f>
mov    0x4e8(%rsp,%rax,4),%edx
cmp    0xe8(%rsp,%rax,4),%edx
jne    128f <main+0x13f>
mov    0x4ec(%rsp,%rax,4),%edx
cmp    0xec(%rsp,%rax,4),%edx
jne    128f <main+0x13f>
add    $0x4,%rax
cmp    $0x100,%rax
jne    1240 <main+0xf0>
mov    %rcx,%r14
mov    %r14,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter 1st string\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"Enter 2nd string\0A\00"
@.str.3 = [29 x i8] c"The strings are not anagrams\00"
@.str.4 = [25 x i8] c"The strings are anagrams\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [256 x i32]
%5 = alloca [256 x i32]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%14 = call i32 @memset(i32* %13, i32 0, i32 1024)
%15 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 0
%16 = call i32 @memset(i32* %15, i32 0, i32 1024)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %76
24: ; preds = %0
store i32 0, i32* %6
br label %25
25: ; preds = %51, %24
%26 = load i32, i32* %6
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %54
30: ; preds = %25
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 97
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 97
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
store i32 %50, i32* %48
br label %51
51: ; preds = %30
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %25
54: ; preds = %25
store i32 0, i32* %6
br label %55
55: ; preds = %71, %54
%56 = load i32, i32* %6
%57 = icmp slt i32 %56, 256
br i1 %57, label %58, label %74
58: ; preds = %55
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = icmp ne i32 %62, %66
br i1 %67, label %68, label %70
68: ; preds = %58
%69 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %76
70: ; preds = %58
br label %71
71: ; preds = %70
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %55
74: ; preds = %55
%75 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %76
76: ; preds = %74, %68, %22
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [29 x i8] c"The strings are not anagrams\00"
@.str.4 = [25 x i8] c"The strings are anagrams\00"
@str = [17 x i8] c"Enter 1st string\00"
@str.5 = [17 x i8] c"Enter 2nd string\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [256 x i32]
%4 = alloca [256 x i32]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = bitcast [256 x i32]* %3 to i8*
%12 = bitcast [256 x i32]* %4 to i8*
%13 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%14 = call i32 @memset(i32* %13, i32 0, i32 1024)
%15 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%16 = call i32 @memset(i32* %15, i32 0, i32 1024)
%17 = call i32 @strlen(i8* %5)
%18 = call i32 @strlen(i8* %6)
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %75
20: ; preds = %0
%21 = call i32 @strlen(i8* %5)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %43
23: ; preds = %20, %23
%24 = phi i64 [ %39, %23 ], [ 0, %20 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i64
%28 = add nsw i64 %27, -97
%29 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
%33 = load i8, i8* %32
%34 = sext i8 %33 to i64
%35 = add nsw i64 %34, -97
%36 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1
store i32 %38, i32* %36
%39 = add nuw nsw i64 %24, 1
%40 = call i32 @strlen(i8* %5)
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %23, label %43
43: ; preds = %23, %20
br label %68
44: ; preds = %68
%45 = or i64 %69, 1
%46 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %45
%49 = load i32, i32* %48
%50 = icmp eq i32 %47, %49
br i1 %50, label %51, label %75
51: ; preds = %44
%52 = or i64 %69, 2
%53 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %52
%56 = load i32, i32* %55
%57 = icmp eq i32 %54, %56
br i1 %57, label %58, label %75
58: ; preds = %51
%59 = or i64 %69, 3
%60 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %59
%63 = load i32, i32* %62
%64 = icmp eq i32 %61, %63
br i1 %64, label %65, label %75
65: ; preds = %58
%66 = add nuw nsw i64 %69, 4
%67 = icmp eq i64 %66, 256
br i1 %67, label %75, label %68
68: ; preds = %65, %43
%69 = phi i64 [ 0, %43 ], [ %66, %65 ]
%70 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %69
%73 = load i32, i32* %72
%74 = icmp eq i32 %71, %73
br i1 %74, label %44, label %75
75: ; preds = %68, %44, %51, %58, %65, %0
%76 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %68 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %44 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %51 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %58 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), %65 ]
%77 = call i32 @printf(i8* dereferenceable(1) %76)
ret i32 0
}