#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 */
scalar_t__ compareOccurrences(int *, int *);
scalar_t__ countCharacters(char *, int *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int main(void) {
  char string1[1024], string2[1024];
  int count1[256], count2[256];
  memset(count1, 0, sizeof(count1));
  memset(count2, 0, sizeof(count2));
  fgets(string1, 1024, stdin);
  printf("\nenter string2\n");
  fgets(string2, 1024, stdin);
  if (strlen(string1) != strlen(string2)) {
    printf("\nNot permutations\n");
    return 0;
  }
  if (0 != countCharacters(string1, count1)) {
    printf("\nERROR: exited abnormally \n");
    return 1;
  }
  if (0 != countCharacters(string2, count2)) {
    printf("\nERROR: exited abnormally \n");
    return 1;
  }
  if (0 == compareOccurrences(count1, count2)) {
    printf("\nstrings are permutations\n");
  } else {
    printf("\nStrings are not permutations\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc10(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x1018(%rbp)
lea    -0x810(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x1018(%rbp),%rax
cmp    %rcx,%rax
je     1222 <main+0xc2>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d9 <main+0x179>
lea    -0x410(%rbp),%rdi
lea    -0xc10(%rbp),%rsi
call   1080 <countCharacters@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     125b <main+0xfb>
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d9 <main+0x179>
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1080 <countCharacters@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1294 <main+0x134>
lea    0xda0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d9 <main+0x179>
lea    -0xc10(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1060 <compareOccurrences@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12c6 <main+0x166>
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
jmp    12d2 <main+0x172>
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x1008,%rsp
lea    0x400(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    0x2e55(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xc00(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edx
lea    0x800(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x400,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jne    1249 <main+0xe9>
lea    0xc00(%rsp),%rdi
lea    0x400(%rsp),%rsi
call   1080 <countCharacters@plt>
mov    $0x1,%ebp
lea    0xe3f(%rip),%rbx
test   %rax,%rax
jne    1252 <main+0xf2>
lea    0x800(%rsp),%rdi
mov    %rsp,%rsi
call   1080 <countCharacters@plt>
test   %rax,%rax
jne    1252 <main+0xf2>
lea    0x400(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <compareOccurrences@plt>
test   %rax,%rax
lea    0xdf1(%rip),%rax
lea    0xdcc(%rip),%rbx
cmove  %rax,%rbx
jmp    1250 <main+0xf0>
lea    0xe12(%rip),%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [16 x i8] c"\0Aenter string2\0A\00"
@.str.1 = [19 x i8] c"\0ANot permutations\0A\00"
@.str.2 = [28 x i8] c"\0AERROR: exited abnormally \0A\00"
@.str.3 = [27 x i8] c"\0Astrings are permutations\0A\00"
@.str.4 = [31 x i8] c"\0AStrings are not permutations\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [256 x i32]
%5 = alloca [256 x i32]
store i32 0, i32* %1
%6 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%7 = call i32 @memset(i32* %6, i32 0, i32 1024)
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 0
%9 = call i32 @memset(i32* %8, i32 0, i32 1024)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 1024, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 1024, i32 %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = icmp ne i64 %18, %20
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %48
24: ; preds = %0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%26 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%27 = call i64 @countCharacters(i8* %25, i32* %26)
%28 = icmp ne i64 0, %27
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %48
31: ; preds = %24
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 0
%34 = call i64 @countCharacters(i8* %32, i32* %33)
%35 = icmp ne i64 0, %34
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %48
38: ; preds = %31
%39 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%40 = getelementptr inbounds [256 x i32], [256 x i32]* %5, i64 0, i64 0
%41 = call i64 @compareOccurrences(i32* %39, i32* %40)
%42 = icmp eq i64 0, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %47
45: ; preds = %38
%46 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
store i32 0, i32* %1
br label %48
48: ; preds = %47, %36, %29, %22
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [15 x i8] c"\0Aenter string2\00"
@str.5 = [30 x i8] c"\0AStrings are not permutations\00"
@str.6 = [26 x i8] c"\0Astrings are permutations\00"
@str.8 = [27 x i8] c"\0AERROR: exited abnormally \00"
@str.9 = [18 x i8] c"\0ANot permutations\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [256 x i32]
%4 = alloca [256 x i32]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = bitcast [256 x i32]* %3 to i8*
%8 = bitcast [256 x i32]* %4 to i8*
%9 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 1024)
%11 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%12 = call i32 @memset(i32* %11, i32 0, i32 1024)
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %5, i32 1024, i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %6, i32 1024, i32 %16)
%18 = call i64 @strlen(i8* %5)
%19 = call i64 @strlen(i8* %6)
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %0
%22 = call i64 @countCharacters(i8* %5, i32* %9)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = call i64 @countCharacters(i8* %6, i32* %11)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = call i64 @compareOccurrences(i32* %9, i32* %11)
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0)
br label %31
31: ; preds = %27, %24, %21, %0
%32 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0), %0 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0), %21 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0), %24 ], [ %30, %27 ]
%33 = phi i32 [ 0, %0 ], [ 1, %21 ], [ 1, %24 ], [ 0, %27 ]
%34 = call i32 @puts(i8* dereferenceable(1) %32)
ret i32 %33
}