#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*/ free(char *);
int /*<<< orphan*/
g_pointeur_fonction_generer_brute_rec(char *, int /*<<< orphan*/, int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
void generer_brute(int maxLen) {
  char *buf = malloc(maxLen + 1);
  for (int i = 1; i <= maxLen; ++i) {
    memset(buf, 0, maxLen + 1);
    g_pointeur_fonction_generer_brute_rec(buf, 0, i);
  }
  free(buf);
}


x86 assembly (clang, -O0):
<generer_brute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     119a <generer_brute+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1060 <g_pointeur_fonction_generer_brute_rec@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <generer_brute+0x21>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generer_brute>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
lea    0x1(%r15),%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
test   %r15d,%r15d
jle    119c <generer_brute+0x5c>
neg    %r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1060 <g_pointeur_fonction_generer_brute_rec@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <generer_brute+0x30>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @generer_brute(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 1
%7 = call i8* @malloc(i32 %6)
store i8* %7, i8** %3
store i32 1, i32* %4
br label %8
8: ; preds = %20, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
%16 = call i32 @memset(i8* %13, i32 0, i32 %15)
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @g_pointeur_fonction_generer_brute_rec(i8* %17, i32 0, i32 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load i8*, i8** %3
%25 = call i32 @free(i8* %24)
ret void
}

LLVM IR (-O2):
define void @generer_brute(i32 %0) {
%2 = add i32 %0, 1
%3 = tail call i8* @malloc(i32 %2)
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %7, %1
%6 = tail call i32 @free(i8* %3)
ret void
7: ; preds = %1, %7
%8 = phi i32 [ %11, %7 ], [ 1, %1 ]
%9 = tail call i32 @memset(i8* %3, i32 0, i32 %2)
%10 = tail call i32 @g_pointeur_fonction_generer_brute_rec(i8* %3, i32 0, i32 %8)
%11 = add nuw i32 %8, 1
%12 = icmp eq i32 %8, %0
br i1 %12, label %5, label %7
}