#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*/ MD5(unsigned char *, unsigned long, unsigned char *);
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ bytes_to_str(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned long snprintf(unsigned char *, int, char *, char *, int);
int /*<<< orphan*/ sscanf(unsigned char *, char *, int *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int i, test;
  unsigned long input_len;
  unsigned char input[64];
  unsigned char output[MD5_DIGEST_LENGTH];
  unsigned char output_str[32];
  if (argc < 2) {
    fprintf(stdout, "Usage: %s <input>\n", argv[0]);
    return 0;
  }
  for (i = 0; i < 0xFFFFFFFF; i++) {
    input_len = snprintf(input, 64, "%s%d", argv[1], i);
    if (input_len > 64) {
      fprintf(stdout, "Reached maximum length. Aborting.\n");
      return 1;
    }
    MD5(input, input_len, output);
    bytes_to_str(output_str, output, MD5_DIGEST_LENGTH);
    sscanf(output_str, "%6x", &test);
    if (test == 0) {
      fprintf(stdout, "The secret key is: %s\n", input);
      fprintf(stdout, "The MD5 hash is: %s\n", output_str);
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d6 <main+0x86>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x94(%rbp)
jmp    1308 <main+0x1b8>
movl   $0x0,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jae    12f7 <main+0x1a7>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x14(%rbp),%r8d
mov    $0x40,%esi
lea    0xe10(%rip),%rdx
call   1040 <snprintf@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x40,-0x20(%rbp)
jbe    1244 <main+0xf4>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x94(%rbp)
jmp    1308 <main+0x1b8>
mov    -0xa0(%rbp),%rdx
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <MD5@plt>
mov    -0xa0(%rbp),%rsi
lea    -0x90(%rbp),%rdi
mov    0x2d73(%rip),%rax
mov    (%rax),%edx
call   1030 <bytes_to_str@plt>
lea    -0x90(%rbp),%rdi
lea    0xdb9(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12e4 <main+0x194>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x94(%rbp)
jmp    1308 <main+0x1b8>
jmp    12e9 <main+0x199>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dd <main+0x8d>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x94(%rbp)
mov    -0x68(%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   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rsp,%rbx
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
cmp    $0x2,%edi
jge    11a8 <main+0x58>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe67(%rip),%rsi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12a9 <main+0x159>
mov    %rbx,-0x38(%rbp)
mov    0x8(%r14),%rcx
lea    0xe5c(%rip),%rdx
lea    -0xa0(%rbp),%rdi
mov    $0x40,%esi
xor    %r8d,%r8d
call   1040 <snprintf@plt>
cmp    $0x40,%rax
ja     124f <main+0xff>
mov    $0x1,%ebx
lea    -0xa0(%rbp),%r12
lea    -0x60(%rbp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1070 <MD5@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <bytes_to_str@plt>
mov    %r13,%rdi
lea    0xe1f(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <sscanf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     126e <main+0x11e>
mov    0x8(%r14),%rcx
mov    %r12,%rdi
mov    $0x40,%esi
lea    0xdd5(%rip),%rdx
mov    %ebx,%r8d
call   1040 <snprintf@plt>
add    $0x1,%ebx
cmp    $0x41,%rax
jb     11f0 <main+0xa0>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%r15d
jmp    12a5 <main+0x155>
mov    0x2d63(%rip),%r14
mov    (%r14),%edi
lea    0xdc0(%rip),%rsi
xor    %r15d,%r15d
lea    -0xa0(%rbp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xdbc(%rip),%rsi
lea    -0x60(%rbp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rsp
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@stdout = global i32 0
@.str = [19 x i8] c"Usage: %s <input>\0A\00"
@.str.1 = [5 x i8] c"%s%d\00"
@.str.2 = [35 x i8] c"Reached maximum length. Aborting.\0A\00"
@.str.3 = [4 x i8] c"%6x\00"
@.str.4 = [23 x i8] c"The secret key is: %s\0A\00"
@.str.5 = [21 x i8] c"The MD5 hash is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca [64 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca [32 x i8]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @MD5_DIGEST_LENGTH
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %10
%17 = alloca i8, i64 %15
store i64 %15, i64* %11
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* @stdout
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
store i32 1, i32* %13
br label %65
26: ; preds = %2
store i32 0, i32* %6
br label %27
27: ; preds = %61, %26
%28 = load i32, i32* %6
%29 = icmp ult i32 %28, -1
br i1 %29, label %30, label %64
30: ; preds = %27
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* %6
%36 = call i64 @snprintf(i8* %31, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %34, i32 %35)
store i64 %36, i64* %8
%37 = load i64, i64* %8
%38 = icmp ugt i64 %37, 64
br i1 %38, label %39, label %42
39: ; preds = %30
%40 = load i32, i32* @stdout
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %13
br label %65
42: ; preds = %30
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%44 = load i64, i64* %8
%45 = call i32 @MD5(i8* %43, i64 %44, i8* %17)
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%47 = load i32, i32* @MD5_DIGEST_LENGTH
%48 = call i32 @bytes_to_str(i8* %46, i8* %17, i32 %47)
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %42
%54 = load i32, i32* @stdout
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @stdout
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %58)
store i32 0, i32* %3
store i32 1, i32* %13
br label %65
60: ; preds = %42
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %27
64: ; preds = %27
store i32 0, i32* %3
store i32 1, i32* %13
br label %65
65: ; preds = %64, %53, %39, %20
%66 = load i8*, i8** %10
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@stdout = global i32 0
@.str = [19 x i8] c"Usage: %s <input>\0A\00"
@.str.1 = [5 x i8] c"%s%d\00"
@.str.2 = [35 x i8] c"Reached maximum length. Aborting.\0A\00"
@.str.3 = [4 x i8] c"%6x\00"
@.str.4 = [23 x i8] c"The secret key is: %s\0A\00"
@.str.5 = [21 x i8] c"The MD5 hash is: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = alloca [32 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @MD5_DIGEST_LENGTH
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = icmp slt i32 %0, 2
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 0)
%18 = icmp ugt i64 %17, 64
br i1 %18, label %27, label %30
19: ; preds = %2
%20 = load i32, i32* @stdout
%21 = load i8*, i8** %1
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %45
23: ; preds = %30
%24 = load i8*, i8** %15
%25 = call i64 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32 %39)
%26 = icmp ugt i64 %25, 64
br i1 %26, label %27, label %30
27: ; preds = %23, %14
%28 = load i32, i32* @stdout
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %45
30: ; preds = %14, %23
%31 = phi i64 [ %25, %23 ], [ %17, %14 ]
%32 = phi i32 [ %39, %23 ], [ 0, %14 ]
%33 = call i32 @MD5(i8* %7, i64 %31, i8* %11)
%34 = load i32, i32* @MD5_DIGEST_LENGTH
%35 = call i32 @bytes_to_str(i8* %12, i8* %11, i32 %34)
%36 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 0
%39 = add nuw nsw i32 %32, 1
br i1 %38, label %40, label %23
40: ; preds = %30
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%43 = load i32, i32* @stdout
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %12)
br label %45
45: ; preds = %40, %27, %19
%46 = phi i32 [ 0, %19 ], [ 1, %27 ], [ 0, %40 ]
ret i32 %46
}