#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 */
char *calloc(int, int);
int /*<<< orphan*/ faire_combi(char *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int length(char *);
void display_anagrams(char *s1) {
  int len = length(s1);
  char *tmp = calloc(len + 1, sizeof(char));
  char *util = calloc(len + 1, sizeof(char));
  int i;
  for (i = 0; i < len; i++)
    util[i] = s1[i];
  faire_combi(util, tmp, len, 0);
  free(tmp);
  free(util);
}


x86 assembly (clang, -O0):
<display_anagrams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <length@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <display_anagrams+0x77>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <display_anagrams+0x47>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %ecx,%ecx
call   1060 <faire_combi@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_anagrams>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <length@plt>
mov    %eax,%ebx
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
jle    1194 <display_anagrams+0x44>
mov    %ebx,%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <memcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1070 <faire_combi@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @display_anagrams(i8* %0) {
%2 = tail call i32 @length(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @calloc(i32 %3, i32 1)
%5 = tail call i8* @calloc(i32 %3, i32 1)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %1
%10 = tail call i32 @faire_combi(i8* %5, i8* %4, i32 %2, i32 0)
%11 = tail call i32 @free(i8* %4)
%12 = tail call i32 @free(i8* %5)
ret void
}