#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void BruteForce(char *str, int idx, int max_depth, char *alpha,
                int alpha_size) {
  int64_t x;
  for (x = 0; x < alpha_size; ++x) {
    str[idx] = alpha[x];
    if (idx == max_depth - 1)
      printf("%s\n", str);
    else
      BruteForce(str, idx + 1, max_depth, alpha, alpha_size);
  }
}


x86 assembly (clang, -O0):
<BruteForce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b6 <BruteForce+0x96>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1189 <BruteForce+0x69>
mov    -0x8(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <BruteForce+0x83>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <BruteForce@plt>
jmp    11a8 <BruteForce+0x88>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <BruteForce+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BruteForce>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %r8d,0x8(%rsp)
test   %r8d,%r8d
jle    11b2 <BruteForce+0x92>
mov    %rcx,%rbx
mov    %rdi,%rbp
movslq %esi,%r13
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r14d
lea    0x1(%r13),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rsp),%r15d
xor    %r12d,%r12d
jmp    1192 <BruteForce+0x72>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
mov    0x8(%rsp),%r8d
call   1040 <BruteForce@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     11b2 <BruteForce+0x92>
movzbl (%rbx,%r12,1),%eax
mov    %al,0x0(%rbp,%r13,1)
cmp    %r13d,%r14d
jne    1170 <BruteForce+0x50>
lea    0xe58(%rip),%rdi
mov    %rbp,%rsi
call   1030 <printf@plt>
jmp    1189 <BruteForce+0x69>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @BruteForce(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %41, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
%17 = load i8*, i8** %9
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 1
%29 = icmp eq i32 %26, %28
br i1 %29, label %30, label %33
30: ; preds = %16
%31 = load i8*, i8** %6
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %40
33: ; preds = %16
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
%37 = load i32, i32* %8
%38 = load i8*, i8** %9
%39 = load i32, i32* %10
br label %40
40: ; preds = %33, %30
br label %41
41: ; preds = %40
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %12
44: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @BruteForce(i8* %0, i32 %1, i32 %2, i8* nocapture %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %24
7: ; preds = %5
%8 = sext i32 %1 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = add nsw i32 %2, -1
%11 = icmp eq i32 %10, %1
%12 = add nsw i32 %1, 1
%13 = zext i32 %4 to i64
br label %14
14: ; preds = %7, %21
%15 = phi i64 [ 0, %7 ], [ %22, %21 ]
%16 = getelementptr inbounds i8, i8* %3, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %9
br i1 %11, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %21
20: ; preds = %14
tail call void @BruteForce(i8* %0, i32 %12, i32 %2, i8* %3, i32 %4)
br label %21
21: ; preds = %18, %20
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %13
br i1 %23, label %24, label %14
24: ; preds = %21, %5
ret void
}