#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 */
scalar_t__ strlen(char *);
int veces_letra(char, char *);
int son_anagrams(char *pal_1, char *pal_2) {
  int veces_en_1;
  int veces_en_2;
  int k = 0;
  char letra = pal_1[k];
  if (strlen(pal_1) != strlen(pal_2)) {
    return 0;
  }
  while (letra != '\0') {
    veces_en_1 = veces_letra(letra, pal_1);
    veces_en_2 = veces_letra(letra, pal_2);
    if (veces_en_1 == veces_en_2) {
      k++;
      letra = pal_1[k];
    } else {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<son_anagrams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1177 <son_anagrams+0x57>
movl   $0x0,-0x4(%rbp)
jmp    11ed <son_anagrams+0xcd>
jmp    117c <son_anagrams+0x5c>
movsbl -0x25(%rbp),%eax
cmp    $0x0,%eax
je     11e6 <son_anagrams+0xc6>
mov    -0x25(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <veces_letra@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x25(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <veces_letra@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11d5 <son_anagrams+0xb5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
jmp    11e1 <son_anagrams+0xc1>
movl   $0x0,-0x4(%rbp)
jmp    11ed <son_anagrams+0xcd>
jmp    117c <son_anagrams+0x5c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<son_anagrams>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %r15d,%r15d
cmp    %rax,%rbp
jne    1190 <son_anagrams+0x70>
mov    (%r12),%al
test   %al,%al
je     118a <son_anagrams+0x6a>
lea    0x1(%r12),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1040 <veces_letra@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <veces_letra@plt>
cmp    %eax,%r13d
jne    1190 <son_anagrams+0x70>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <son_anagrams+0x40>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @son_anagrams(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %6, %15
%10 = phi i64 [ %16, %15 ], [ 0, %6 ]
%11 = phi i8 [ %18, %15 ], [ %7, %6 ]
%12 = tail call i32 @veces_letra(i8 signext %11, i8* %0)
%13 = tail call i32 @veces_letra(i8 signext %11, i8* %1)
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = add nuw i64 %10, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %9
20: ; preds = %9, %15, %6, %2
%21 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %9 ], [ 1, %15 ]
ret i32 %21
}