#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*/ *PBEWithMD5AndDES_decrypt(char *, unsigned char *, size_t,
                                             unsigned char **, size_t *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, size_t);
int usage(char *);
int main(int argc, char *argv[]) {
  char *input = NULL;
  char *password = NULL;
  unsigned char *decrypt;
  size_t i, len;
  if (argc != 3) {
    return usage(argv[0]);
  }
  for (i = 1; i < 3; i++) {
    if (!strncmp(argv[i], "input=", strlen("input="))) {
      input = &(argv[i][strlen("input=")]);
    }
    if (!strncmp(argv[i], "password=", strlen("password="))) {
      password = &(argv[i][strlen("password=")]);
    }
  }
  if ((input == NULL) || (password == NULL)) {
    return usage(argv[0]);
  }
  printf("\n----ARGUMENTS-------------------\n\n");
  printf("input: %s\npassword: %s\n\n\n", input, password);
  if (PBEWithMD5AndDES_decrypt(input, (unsigned char *)password,
                               strlen(password), &decrypt, &len) != NULL) {
    printf("\n----OUTPUT----------------------\n\n");
    printf("%s\n\n\n", decrypt);
  } else {
    printf("PBEWithMD5AndDES_decrypt() returns error.\n");
    return -1;
  }
  free(decrypt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1369 <main+0x209>
movq   $0x1,-0x30(%rbp)
cmpq   $0x3,-0x30(%rbp)
jae    1291 <main+0x131>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
lea    0xe32(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xe1f(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1219 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
lea    0xdfa(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
lea    0xdd7(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xdc4(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    127b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x58(%rbp)
lea    0xd9f(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1280 <main+0x120>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11ac <main+0x4c>
cmpq   $0x0,-0x18(%rbp)
je     12a7 <main+0x147>
cmpq   $0x0,-0x20(%rbp)
jne    12bb <main+0x15b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1369 <main+0x209>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
lea    -0x28(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1050 <PBEWithMD5AndDES_decrypt@plt>
cmp    $0x0,%rax
je     133f <main+0x1df>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1359 <main+0x1f9>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <main+0x209>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1287 <main+0x117>
mov    0x8(%r14),%r15
lea    0xe6b(%rip),%r13
mov    $0x6,%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strncmp@plt>
lea    0x6(%r15),%rbp
xor    %ebx,%ebx
test   %eax,%eax
cmovne %rbx,%rbp
lea    0xe4f(%rip),%r12
mov    $0x9,%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strncmp@plt>
add    $0x9,%r15
test   %eax,%eax
cmovne %rbx,%r15
mov    0x10(%r14),%rbx
mov    $0x6,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strncmp@plt>
lea    0x6(%rbx),%r13
test   %eax,%eax
cmovne %rbp,%r13
mov    $0x9,%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strncmp@plt>
add    $0x9,%rbx
test   %eax,%eax
cmovne %r15,%rbx
test   %r13,%r13
je     1287 <main+0x117>
test   %rbx,%rbx
je     1287 <main+0x117>
lea    0xe10(%rip),%rdi
call   1060 <puts@plt>
lea    0xdea(%rip),%rdi
xor    %r14d,%r14d
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <PBEWithMD5AndDES_decrypt@plt>
test   %rax,%rax
je     129d <main+0x12d>
lea    0xe15(%rip),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%rsi
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    12af <main+0x13f>
mov    (%r14),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <usage@plt>
lea    0xdaa(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"input=\00"
@.str.1 = [10 x i8] c"password=\00"
@.str.2 = [36 x i8] c"\0A----ARGUMENTS-------------------\0A\0A\00"
@.str.3 = [26 x i8] c"input: %s\0Apassword: %s\0A\0A\0A\00"
@.str.4 = [36 x i8] c"\0A----OUTPUT----------------------\0A\0A\00"
@.str.5 = [6 x i8] c"%s\0A\0A\0A\00"
@.str.6 = [43 x i8] c"PBEWithMD5AndDES_decrypt() returns error.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @usage(i8* %16)
store i32 %17, i32* %3
br label %87
18: ; preds = %2
store i64 1, i64* %9
br label %19
19: ; preds = %53, %18
%20 = load i64, i64* %9
%21 = icmp ult i64 %20, 3
br i1 %21, label %22, label %56
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = load i64, i64* %9
%25 = getelementptr inbounds i8*, i8** %23, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @strncmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %22
%31 = load i8**, i8*** %5
%32 = load i64, i64* %9
%33 = getelementptr inbounds i8*, i8** %31, i64 %32
%34 = load i8*, i8** %33
%35 = call i64 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %6
br label %37
37: ; preds = %30, %22
%38 = load i8**, i8*** %5
%39 = load i64, i64* %9
%40 = getelementptr inbounds i8*, i8** %38, i64 %39
%41 = load i8*, i8** %40
%42 = call i64 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @strncmp(i8* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %52, label %45
45: ; preds = %37
%46 = load i8**, i8*** %5
%47 = load i64, i64* %9
%48 = getelementptr inbounds i8*, i8** %46, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %7
br label %52
52: ; preds = %45, %37
br label %53
53: ; preds = %52
%54 = load i64, i64* %9
%55 = add i64 %54, 1
store i64 %55, i64* %9
br label %19
56: ; preds = %19
%57 = load i8*, i8** %6
%58 = icmp eq i8* %57, null
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i8*, i8** %7
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %67
62: ; preds = %59, %56
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = call i32 @usage(i8* %65)
store i32 %66, i32* %3
br label %87
67: ; preds = %59
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%69 = load i8*, i8** %6
%70 = load i8*, i8** %7
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %69, i8* %70)
%72 = load i8*, i8** %6
%73 = load i8*, i8** %7
%74 = load i8*, i8** %7
%75 = call i64 @strlen(i8* %74)
%76 = call i32* @PBEWithMD5AndDES_decrypt(i8* %72, i8* %73, i64 %75, i8** %8, i64* %10)
%77 = icmp ne i32* %76, null
br i1 %77, label %78, label %82
78: ; preds = %67
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%80 = load i8*, i8** %8
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %80)
br label %84
82: ; preds = %67
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %87
84: ; preds = %78
%85 = load i8*, i8** %8
%86 = call i32 @free(i8* %85)
store i32 0, i32* %3
br label %87
87: ; preds = %84, %82, %62, %13
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [7 x i8] c"input=\00"
@.str.1 = [10 x i8] c"password=\00"
@.str.3 = [26 x i8] c"input: %s\0Apassword: %s\0A\0A\0A\00"
@.str.5 = [6 x i8] c"%s\0A\0A\0A\00"
@str = [35 x i8] c"\0A----ARGUMENTS-------------------\0A\00"
@str.7 = [42 x i8] c"PBEWithMD5AndDES_decrypt() returns error.\00"
@str.8 = [35 x i8] c"\0A----OUTPUT----------------------\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %32
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strncmp(i8* dereferenceable(1) %10, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6)
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8, i8* %10, i64 6
%14 = select i1 %12, i8* %13, i8* null
%15 = tail call i32 @strncmp(i8* dereferenceable(1) %10, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 9)
%16 = icmp eq i32 %15, 0
%17 = getelementptr inbounds i8, i8* %10, i64 9
%18 = select i1 %16, i8* %17, i8* null
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @strncmp(i8* dereferenceable(1) %20, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6)
%22 = icmp eq i32 %21, 0
%23 = getelementptr inbounds i8, i8* %20, i64 6
%24 = select i1 %22, i8* %23, i8* %14
%25 = tail call i32 @strncmp(i8* dereferenceable(1) %20, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 9)
%26 = icmp eq i32 %25, 0
%27 = getelementptr inbounds i8, i8* %20, i64 9
%28 = select i1 %26, i8* %27, i8* %18
%29 = icmp eq i8* %24, null
%30 = icmp eq i8* %28, null
%31 = select i1 %29, i1 true, i1 %30
br i1 %31, label %35, label %38
32: ; preds = %2
%33 = load i8*, i8** %1
%34 = tail call i32 @usage(i8* %33)
br label %52
35: ; preds = %8
%36 = load i8*, i8** %1
%37 = tail call i32 @usage(i8* %36)
br label %52
38: ; preds = %8
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %28)
%41 = tail call i64 @strlen(i8* dereferenceable(1) %28)
%42 = call i32* @PBEWithMD5AndDES_decrypt(i8* %24, i8* %28, i64 %41, i8** %3, i64* %4)
%43 = icmp eq i32* %42, null
br i1 %43, label %50, label %44
44: ; preds = %38
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
%46 = load i8*, i8** %3
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %3
%49 = call i32 @free(i8* %48)
br label %52
50: ; preds = %38
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
br label %52
52: ; preds = %44, %50, %35, %32
%53 = phi i32 [ %34, %32 ], [ %37, %35 ], [ 0, %44 ], [ -1, %50 ]
ret i32 %53
}