#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 /*<<< orphan*/ g_pointeur_fonction_crack(char *);
int /*<<< orphan*/ swap(char *, int, int);
void generer_swap(char *p_chaine, int p_taille, int p_curs) {
  int i;
  if (p_taille - p_curs <= 1)
    g_pointeur_fonction_crack(p_chaine);
  else {
    for (i = p_curs; i < p_taille; i++) {
      swap(p_chaine, i, p_curs);
      generer_swap(p_chaine, p_taille, p_curs + 1);
      swap(p_chaine, i, p_curs);
    }
  }
}


x86 assembly (clang, -O0):
<generer_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
cmp    $0x1,%eax
jg     115f <generer_swap+0x2f>
mov    -0x8(%rbp),%rdi
call   1040 <g_pointeur_fonction_crack@plt>
jmp    11b4 <generer_swap+0x84>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <generer_swap+0x7f>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <generer_swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <swap@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <generer_swap+0x35>
jmp    11b4 <generer_swap+0x84>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generer_swap>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    %esi,%eax
sub    %edx,%eax
cmp    $0x2,%eax
jge    1154 <generer_swap+0x24>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <g_pointeur_fonction_crack@plt>
mov    %edx,%r14d
mov    %esi,%r12d
cmp    %edx,%esi
jle    11a0 <generer_swap+0x70>
lea    0x1(%r14),%r15d
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <swap@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <generer_swap@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <swap@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1170 <generer_swap+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @generer_swap(i8* %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %1, %2
%5 = icmp slt i32 %4, 2
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = icmp sgt i32 %1, %2
br i1 %7, label %8, label %18
8: ; preds = %6
%9 = add nsw i32 %2, 1
br label %12
10: ; preds = %3
%11 = tail call i32 @g_pointeur_fonction_crack(i8* %0)
br label %18
12: ; preds = %8, %12
%13 = phi i32 [ %2, %8 ], [ %16, %12 ]
%14 = tail call i32 @swap(i8* %0, i32 %13, i32 %2)
tail call void @generer_swap(i8* %0, i32 %1, i32 %9)
%15 = tail call i32 @swap(i8* %0, i32 %13, i32 %2)
%16 = add i32 %13, 1
%17 = icmp eq i32 %16, %1
br i1 %17, label %18, label %12
18: ; preds = %12, %6, %10
ret void
}