#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 brute_force(char *, char *);
int check_dict(char *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: ./crack hash\n");
    return 1;
  }
  char *hash = argv[1];
  char salt[2];
  memcpy(salt, hash, 2);
  int success = check_dict(hash, salt);
  if (!success) {
    return 0;
  }
  success = brute_force(hash, salt);
  return success;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1060 <check_dict@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11bc <main+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <main+0x92>
mov    -0x18(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <brute_force@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1180 <main+0x40>
mov    0x8(%rsi),%rbx
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <check_dict@plt>
test   %eax,%eax
je     1193 <main+0x53>
lea    0x6(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <brute_force@plt>
jmp    1195 <main+0x55>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1195 <main+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Usage: ./crack hash\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [2 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %31
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 2)
%20 = load i8*, i8** %6
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%22 = call i32 @check_dict(i8* %20, i8* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %13
store i32 0, i32* %3
br label %31
26: ; preds = %13
%27 = load i8*, i8** %6
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%29 = call i32 @brute_force(i8* %27, i8* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
store i32 %30, i32* %3
br label %31
31: ; preds = %26, %25, %11
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@str = [20 x i8] c"Usage: ./crack hash\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 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 ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%11 = call i32 @memcpy(i8* %10, i8* %9, i32 2)
%12 = call i32 @check_dict(i8* %9, i8* %10)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %7
%15 = call i32 @brute_force(i8* %9, i8* %10)
br label %16
16: ; preds = %7, %14
%17 = phi i32 [ %15, %14 ], [ 0, %7 ]
br label %18
18: ; preds = %16, %5
%19 = phi i32 [ 1, %5 ], [ %17, %16 ]
ret i32 %19
}