#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 *crack(char *, int, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Not enough arguments\n");
    return 1;
  }
  char salt[3];
  strncpy(salt, argv[1], 2);
  salt[2] = '\0';
  int keySize = 8;
  char buf[keySize];
  for (int length = 1; length <= keySize; length++) {
    char *key = crack(argv[1], length, salt, buf, 0);
    if (key != NULL) {
      printf("%s\n", key);
      return 0;
    }
  }
  printf("No solution found.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1242 <main+0x112>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x13(%rbp),%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x11(%rbp)
movl   $0x8,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1226 <main+0xf6>
mov    -0x48(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x13(%rbp),%rdx
xor    %r8d,%r8d
call   1050 <crack@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1213 <main+0xe3>
mov    -0x38(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    123b <main+0x10b>
jmp    1218 <main+0xe8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b8 <main+0x88>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1283 <main+0x143>
mov    %rsi,%r14
mov    0x8(%rsi),%rsi
lea    -0x23(%rbp),%r15
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    %rsp,%r12
movb   $0x0,-0x21(%rbp)
mov    %rsp,%rbx
add    $0xfffffffffffffff0,%rbx
mov    %rbx,%rsp
mov    0x8(%r14),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x2,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x3,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x4,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x5,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x6,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x7,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
jne    1274 <main+0x134>
mov    0x8(%r14),%rdi
lea    -0x23(%rbp),%rdx
mov    $0x8,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <crack@plt>
test   %rax,%rax
je     12a1 <main+0x161>
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %r12,%rsp
xor    %eax,%eax
jmp    1294 <main+0x154>
lea    0xd89(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    127c <main+0x13c>

LLVM IR (-O0):
@.str = [22 x i8] c"Not enough arguments\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [19 x i8] c"No solution found.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %53
17: ; preds = %2
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strncpy(i8* %18, i8* %21, i32 2)
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 2
store i8 0, i8* %23
store i32 8, i32* %7
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %8
%27 = alloca i8, i64 %25
store i64 %25, i64* %9
store i32 1, i32* %10
br label %28
28: ; preds = %45, %17
%29 = load i32, i32* %10
%30 = load i32, i32* %7
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %48
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* %10
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%38 = call i8* @crack(i8* %35, i32 %36, i8* %37, i8* %27, i32 0)
store i8* %38, i8** %11
%39 = load i8*, i8** %11
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i8*, i8** %11
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
store i32 0, i32* %3
store i32 1, i32* %12
br label %50
44: ; preds = %32
br label %45
45: ; preds = %44
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %28
48: ; preds = %28
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %12
br label %50
50: ; preds = %48, %41
%51 = load i8*, i8** %8
%52 = load i32, i32* %12
switch i32 %52, label %55 [
i32 0, label %53
i32 1, label %53
]
53: ; preds = %15, %50, %50
%54 = load i32, i32* %3
ret i32 %54
55: ; preds = %50
unreachable
}

LLVM IR (-O2):
@.str.2 = [19 x i8] c"No solution found.\00"
@str = [21 x i8] c"Not enough arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %53
7: ; preds = %2
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strncpy(i8* %8, i8* %10, i32 2)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %12
%13 = call i8* @llvm.stacksave()
%14 = alloca [8 x i8]
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%16 = load i8*, i8** %9
%17 = call i8* @crack(i8* %16, i32 1, i8* %8, i8* %15, i32 0)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %49
19: ; preds = %7
%20 = load i8*, i8** %9
%21 = call i8* @crack(i8* %20, i32 2, i8* %8, i8* %15, i32 0)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %49
23: ; preds = %19
%24 = load i8*, i8** %9
%25 = call i8* @crack(i8* %24, i32 3, i8* %8, i8* %15, i32 0)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %49
27: ; preds = %23
%28 = load i8*, i8** %9
%29 = call i8* @crack(i8* %28, i32 4, i8* %8, i8* %15, i32 0)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load i8*, i8** %9
%33 = call i8* @crack(i8* %32, i32 5, i8* %8, i8* %15, i32 0)
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = load i8*, i8** %9
%37 = call i8* @crack(i8* %36, i32 6, i8* %8, i8* %15, i32 0)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i8*, i8** %9
%41 = call i8* @crack(i8* %40, i32 7, i8* %8, i8* %15, i32 0)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i8*, i8** %9
%45 = call i8* @crack(i8* %44, i32 8, i8* %8, i8* %15, i32 0)
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %52
49: ; preds = %43, %39, %35, %31, %27, %23, %19, %7
%50 = phi i8* [ %17, %7 ], [ %21, %19 ], [ %25, %23 ], [ %29, %27 ], [ %33, %31 ], [ %37, %35 ], [ %41, %39 ], [ %45, %43 ]
%51 = call i32 @puts(i8* %50)
br label %52
52: ; preds = %49, %47
br label %53
53: ; preds = %52, %5
%54 = phi i32 [ 1, %5 ], [ 0, %52 ]
ret i32 %54
}