#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 getCharPosition(char *, char);
int len(char *);
int isStringPermutationAnother(char *str1, char *str2) {
  int p;
  if (len(str1) != len(str2))
    return 0;
  for (int i = 0; i < len(str1); i++) {
    if ((p = getCharPosition(str2, str1[i])) == -1)
      return 0;
    str2[p] = '\n';
  }
  return 1;
}


x86 assembly (clang, -O0):
<isStringPermutationAnother>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <len@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <len@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
je     115e <isStringPermutationAnother+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11cf <isStringPermutationAnother+0xaf>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <len@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11c8 <isStringPermutationAnother+0xa8>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <getCharPosition@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    11ae <isStringPermutationAnother+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11cf <isStringPermutationAnother+0xaf>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <isStringPermutationAnother+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isStringPermutationAnother>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <len@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <len@plt>
xor    %r15d,%r15d
cmp    %eax,%ebp
jne    1190 <isStringPermutationAnother+0x70>
mov    %rbx,%rdi
call   1040 <len@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    1190 <isStringPermutationAnother+0x70>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1030 <getCharPosition@plt>
cmp    $0xffffffff,%eax
je     118d <isStringPermutationAnother+0x6d>
cltq
movb   $0xa,(%r14,%rax,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <len@plt>
cltq
cmp    %rax,%rbp
jl     1160 <isStringPermutationAnother+0x40>
jmp    1190 <isStringPermutationAnother+0x70>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isStringPermutationAnother(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @len(i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @len(i8* %10)
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %39
14: ; preds = %2
store i32 0, i32* %7
br label %15
15: ; preds = %35, %14
%16 = load i32, i32* %7
%17 = load i8*, i8** %4
%18 = call i32 @len(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %38
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8*, i8** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @getCharPosition(i8* %21, i8 signext %26)
store i32 %27, i32* %6
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %20
store i32 0, i32* %3
br label %39
30: ; preds = %20
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 10, i8* %34
br label %35
35: ; preds = %30
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %15
38: ; preds = %15
store i32 1, i32* %3
br label %39
39: ; preds = %38, %29, %13
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @isStringPermutationAnother(i8* %0, i8* %1) {
%3 = tail call i32 @len(i8* %0)
%4 = tail call i32 @len(i8* %1)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = tail call i32 @len(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6, %15
%10 = phi i64 [ %18, %15 ], [ 0, %6 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @getCharPosition(i8* %1, i8 signext %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %22, label %15
15: ; preds = %9
%16 = sext i32 %13 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 10, i8* %17
%18 = add nuw nsw i64 %10, 1
%19 = tail call i32 @len(i8* %0)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %9, label %22
22: ; preds = %9, %15, %6, %2
%23 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %9 ], [ 1, %15 ]
ret i32 %23
}