#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*/ check(char *, char *, char *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char const *);
void checkAllCombinations(char prefix[], int length, char salt[], char hash[],
                          const char charset[]) {
  if (length == 1) {
    for (int i = 0; i < strlen(charset); i++) {
      char thisChar[8] = "";
      memcpy(thisChar, &(charset[i]), 1);
      strcat(thisChar, prefix);
      check(thisChar, salt, hash);
    }
  } else {
    for (int i = 0; i < strlen(charset); i++) {
      char thisChar[8] = "";
      memcpy(thisChar, charset + i, 1);
      strcat(thisChar, prefix);
      checkAllCombinations(thisChar, length - 1, salt, hash, charset);
    }
  }
}


x86 assembly (clang, -O0):
<checkAllCombinations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1202 <checkAllCombinations+0xa2>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    11fd <checkAllCombinations+0x9d>
lea    -0x34(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x34(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    -0x34(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x34(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <check@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118c <checkAllCombinations+0x2c>
jmp    1289 <checkAllCombinations+0x129>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jge    1284 <checkAllCombinations+0x124>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x38(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1060 <checkAllCombinations@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1209 <checkAllCombinations+0xa9>
jmp    1289 <checkAllCombinations+0x129>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkAllCombinations>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r12
mov    %r8,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%ebp
jne    11d8 <checkAllCombinations+0x88>
test   %eax,%eax
jle    123d <checkAllCombinations+0xed>
xor    %ebp,%ebp
lea    0x10(%rsp),%r13
nopl   0x0(%rax,%rax,1)
movq   $0x0,0x10(%rsp)
lea    (%rbx,%rbp,1),%rsi
mov    %r13,%rdi
mov    $0x1,%edx
call   1040 <memcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <check@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1190 <checkAllCombinations+0x40>
jmp    123d <checkAllCombinations+0xed>
test   %eax,%eax
mov    %ebp,0xc(%rsp)
jle    123d <checkAllCombinations+0xed>
addl   $0xffffffff,0xc(%rsp)
xor    %r13d,%r13d
lea    0x10(%rsp),%rbp
nopl   (%rax)
movq   $0x0,0x10(%rsp)
lea    (%rbx,%r13,1),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1040 <memcpy@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
call   1050 <checkAllCombinations@plt>
add    $0x1,%r13
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r13
jl     11f0 <checkAllCombinations+0xa0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @checkAllCombinations(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca [8 x i8]
%13 = alloca i32
%14 = alloca [8 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %42
17: ; preds = %5
store i32 0, i32* %11
br label %18
18: ; preds = %38, %17
%19 = load i32, i32* %11
%20 = load i8*, i8** %10
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %41
23: ; preds = %18
%24 = bitcast [8 x i8]* %12 to i8*
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%26 = load i8*, i8** %10
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @memcpy(i8* %25, i8* %29, i32 1)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%32 = load i8*, i8** %6
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @check(i8* %34, i8* %35, i8* %36)
br label %38
38: ; preds = %23
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
store i32 %40, i32* %11
br label %18
41: ; preds = %18
br label %69
42: ; preds = %5
store i32 0, i32* %13
br label %43
43: ; preds = %65, %42
%44 = load i32, i32* %13
%45 = load i8*, i8** %10
%46 = call i32 @strlen(i8* %45)
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %68
48: ; preds = %43
%49 = bitcast [8 x i8]* %14 to i8*
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%51 = load i8*, i8** %10
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = call i32 @memcpy(i8* %50, i8* %54, i32 1)
%56 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%57 = load i8*, i8** %6
%58 = call i32 @strcat(i8* %56, i8* %57)
%59 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%60 = load i32, i32* %7
%61 = sub nsw i32 %60, 1
%62 = load i8*, i8** %8
%63 = load i8*, i8** %9
%64 = load i8*, i8** %10
br label %65
65: ; preds = %48
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 1
store i32 %67, i32* %13
br label %43
68: ; preds = %43
br label %69
69: ; preds = %68, %41
ret void
}

LLVM IR (-O2):
define void @checkAllCombinations(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = icmp eq i32 %1, 1
%9 = call i32 @strlen(i8* %4)
%10 = icmp sgt i32 %9, 0
br i1 %8, label %15, label %11
11: ; preds = %5
br i1 %10, label %12, label %37
12: ; preds = %11
%13 = bitcast i64* %7 to i8*
%14 = add nsw i32 %1, -1
br label %28
15: ; preds = %5
br i1 %10, label %16, label %37
16: ; preds = %15
%17 = bitcast i64* %6 to i8*
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %24, %18 ]
store i64 0, i64* %6
%20 = getelementptr inbounds i8, i8* %4, i64 %19
%21 = call i32 @memcpy(i8* %17, i8* %20, i32 1)
%22 = call i32 @strcat(i8* %17, i8* %0)
%23 = call i32 @check(i8* %17, i8* %2, i8* %3)
%24 = add nuw nsw i64 %19, 1
%25 = call i32 @strlen(i8* %4)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %18, label %37
28: ; preds = %12, %28
%29 = phi i64 [ 0, %12 ], [ %33, %28 ]
store i64 0, i64* %7
%30 = getelementptr inbounds i8, i8* %4, i64 %29
%31 = call i32 @memcpy(i8* %13, i8* %30, i32 1)
%32 = call i32 @strcat(i8* %13, i8* %0)
%33 = add nuw nsw i64 %29, 1
%34 = call i32 @strlen(i8* %4)
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %37
37: ; preds = %28, %18, %11, %15
ret void
}