#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 /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ DESBruteForceEncrypt(int /*<<< orphan*/ *, int, int, int,
                                        int);
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ stderr;
int sysconf(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
  int test_size = 102400000;
  if (argc > 1)
    test_size = atoi(argv[1]);
  if (argc > 2)
    num_threads = atoi(argv[2]);
  uint64_t *output = malloc(test_size * sizeof(uint64_t));
  if (output == NULL) {
    fprintf(stderr, "Out of memory.\n");
  }
  DESBruteForceEncrypt(output, test_size, 0xA000000000, 0xFFFFFFFF,
                       num_threads);
}


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)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
mov    %eax,-0x14(%rbp)
movl   $0x61a8000,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1198 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11b2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e5 <main+0x95>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%r8d
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1030 <DESBruteForceEncrypt@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
mov    %eax,%r14d
mov    $0x61a8000,%ebx
cmp    $0x2,%ebp
jl     1193 <main+0x43>
mov    0x8(%r15),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
je     1193 <main+0x43>
mov    0x10(%r15),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%rbx,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11bc <main+0x6c>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
mov    %r14d,%r8d
call   1030 <DESBruteForceEncrypt@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_SC_NPROCESSORS_ONLN = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\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 i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @_SC_NPROCESSORS_ONLN
%10 = call i32 @sysconf(i32 %9)
store i32 %10, i32* %6
store i32 102400000, i32* %7
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %7
br label %18
18: ; preds = %13, %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
br label %26
26: ; preds = %21, %18
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 4
%30 = trunc i64 %29 to i32
%31 = call i32* @malloc(i32 %30)
store i32* %31, i32** %8
%32 = load i32*, i32** %8
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34, %26
%38 = load i32*, i32** %8
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = call i32 @DESBruteForceEncrypt(i32* %38, i32 %39, i32 0, i32 -1, i32 %40)
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@_SC_NPROCESSORS_ONLN = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @_SC_NPROCESSORS_ONLN
%4 = tail call i32 @sysconf(i32 %3)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp eq i32 %0, 2
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %15
15: ; preds = %2, %11, %6
%16 = phi i32 [ %9, %11 ], [ %9, %6 ], [ 102400000, %2 ]
%17 = phi i32 [ %14, %11 ], [ %4, %6 ], [ %4, %2 ]
%18 = shl i32 %16, 2
%19 = tail call i32* @malloc(i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %15
%25 = tail call i32 @DESBruteForceEncrypt(i32* %19, i32 %16, i32 0, i32 -1, i32 %17)
ret i32 0
}