#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*/ EXIT_FAILURE;
char *checkpassphrase(int);
scalar_t__ checksalt(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ optind;
int /*<<< orphan*/ passphrase_mask(int, char **, int);
int /*<<< orphan*/ start_aed(int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int ch, argc_mask, aed_type = -1;
  char *aed_passphrase = NULL;
  char *aed_salt = NULL;
  while ((ch = getopt(argc, argv, "dehp:s:")) != -1)
    switch (ch) {
    case 'd':
      aed_type = 0;
      break;
    case 'e':
      aed_type = 1;
      break;
    case 'h':
      usage();
      break;
    case 'p':
      aed_passphrase = optarg;
      argc_mask = optind - 1;
      break;
    case 's':
      aed_salt = optarg;
      break;
    case '?':
    default:
      usage();
      break;
    }
  if (checksalt(aed_salt)) {
    fprintf(
        stderr,
        "Invalid salt syntax: salt must be exactly 8 hexadecimal characters\n");
    exit(EXIT_FAILURE);
  }
  if (aed_type == -1)
    usage();
  if (aed_passphrase)
    passphrase_mask(argc, argv, argc_mask);
  else
    aed_passphrase = checkpassphrase(aed_type);
  start_aed(aed_type, aed_passphrase, aed_salt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf19(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     125f <main+0xdf>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x34,%eax
ja     1253 <main+0xd3>
mov    -0x38(%rbp),%rax
lea    0xe14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x1c(%rbp)
jmp    125a <main+0xda>
movl   $0x1,-0x1c(%rbp)
jmp    125a <main+0xda>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    125a <main+0xda>
mov    0x2dd8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <main+0xda>
mov    0x2db6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    125a <main+0xda>
jmp    1253 <main+0xd3>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11ad <main+0x2d>
mov    -0x30(%rbp),%rdi
call   1060 <checksalt@plt>
cmp    $0x0,%rax
je     1295 <main+0x115>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12a6 <main+0x126>
mov    $0x0,%al
call   1080 <usage@plt>
cmpq   $0x0,-0x28(%rbp)
je     12c5 <main+0x145>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <passphrase_mask@plt>
jmp    12d1 <main+0x151>
mov    -0x1c(%rbp),%edi
call   1030 <checkpassphrase@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <start_aed@plt>
xor    %eax,%eax
add    $0x40,%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,%rbx
mov    %edi,%ebp
mov    $0xffffffff,%r12d
lea    0xea0(%rip),%r14
lea    0xe59(%rip),%r15
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
jmp    11ca <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2e31(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    11ec <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     1236 <main+0xb6>
xor    %eax,%eax
call   1080 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
lea    -0x64(%rax),%ecx
cmp    $0xf,%ecx
ja     11e0 <main+0x60>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %r12d,%r12d
jmp    11ec <main+0x6c>
mov    $0x1,%r12d
jmp    11ec <main+0x6c>
mov    0x2dda(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    0x2db3(%rip),%rax
mov    (%rax),%r13d
add    $0xffffffff,%r13d
jmp    11ec <main+0x6c>
mov    0x10(%rsp),%r14
mov    %r14,%rdi
call   1060 <checksalt@plt>
test   %rax,%rax
jne    129d <main+0x11d>
cmp    $0xffffffff,%r12d
mov    0x8(%rsp),%r15
je     1267 <main+0xe7>
test   %r15,%r15
je     1273 <main+0xf3>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1040 <passphrase_mask@plt>
jmp    127e <main+0xfe>
xor    %eax,%eax
call   1080 <usage@plt>
test   %r15,%r15
jne    1258 <main+0xd8>
mov    %r12d,%edi
call   1030 <checkpassphrase@plt>
mov    %rax,%r15
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <start_aed@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"dehp:s:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [68 x i8] c"Invalid salt syntax: salt must be exactly 8 hexadecimal characters\0A\00"
@EXIT_FAILURE = global i32 0
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
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %8
store i8* null, i8** %9
store i8* null, i8** %10
br label %11
11: ; preds = %31, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %6
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %32
16: ; preds = %11
%17 = load i32, i32* %6
switch i32 %17, label %29 [
i32 100, label %18
i32 101, label %19
i32 104, label %20
i32 112, label %22
i32 115, label %26
i32 63, label %28
]
18: ; preds = %16
store i32 0, i32* %8
br label %31
19: ; preds = %16
store i32 1, i32* %8
br label %31
20: ; preds = %16
%21 = call i32 (...) @usage()
br label %31
22: ; preds = %16
%23 = load i8*, i8** @optarg
store i8* %23, i8** %9
%24 = load i32, i32* @optind
%25 = sub nsw i32 %24, 1
store i32 %25, i32* %7
br label %31
26: ; preds = %16
%27 = load i8*, i8** @optarg
store i8* %27, i8** %10
br label %31
28: ; preds = %16
br label %29
29: ; preds = %16, %28
%30 = call i32 (...) @usage()
br label %31
31: ; preds = %29, %26, %22, %20, %19, %18
br label %11
32: ; preds = %11
%33 = load i8*, i8** %10
%34 = call i64 @checksalt(i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %32
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (...) @usage()
br label %46
46: ; preds = %44, %41
%47 = load i8*, i8** %9
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* %4
%51 = load i8**, i8*** %5
%52 = load i32, i32* %7
%53 = call i32 @passphrase_mask(i32 %50, i8** %51, i32 %52)
br label %57
54: ; preds = %46
%55 = load i32, i32* %8
%56 = call i8* @checkpassphrase(i32 %55)
store i8* %56, i8** %9
br label %57
57: ; preds = %54, %49
%58 = load i32, i32* %8
%59 = load i8*, i8** %9
%60 = load i8*, i8** %10
%61 = call i32 @start_aed(i32 %58, i8* %59, i8* %60)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"dehp:s:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [68 x i8] c"Invalid salt syntax: salt must be exactly 8 hexadecimal characters\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %20, %2
%4 = phi i32 [ %23, %20 ], [ undef, %2 ]
%5 = phi i32 [ %9, %20 ], [ -1, %2 ]
%6 = phi i8* [ %21, %20 ], [ null, %2 ]
%7 = phi i8* [ %12, %20 ], [ null, %2 ]
br label %8
8: ; preds = %16, %3
%9 = phi i32 [ %5, %3 ], [ %17, %16 ]
%10 = phi i8* [ %7, %3 ], [ %12, %16 ]
br label %11
11: ; preds = %8, %24
%12 = phi i8* [ %10, %8 ], [ %25, %24 ]
br label %13
13: ; preds = %28, %11
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %14, label %26 [
i32 -1, label %29
i32 100, label %16
i32 101, label %15
i32 104, label %18
i32 112, label %20
i32 115, label %24
]
15: ; preds = %13
br label %16
16: ; preds = %13, %15
%17 = phi i32 [ 1, %15 ], [ 0, %13 ]
br label %8
18: ; preds = %13
%19 = tail call i32 (...) @usage()
br label %28
20: ; preds = %13
%21 = load i8*, i8** @optarg
%22 = load i32, i32* @optind
%23 = add nsw i32 %22, -1
br label %3
24: ; preds = %13
%25 = load i8*, i8** @optarg
br label %11
26: ; preds = %13
%27 = tail call i32 (...) @usage()
br label %28
28: ; preds = %26, %18
br label %13
29: ; preds = %13
%30 = tail call i64 @checksalt(i8* %12)
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %29
%38 = icmp eq i32 %9, -1
br i1 %38, label %39, label %41
39: ; preds = %37
%40 = tail call i32 (...) @usage()
br label %41
41: ; preds = %39, %37
%42 = icmp eq i8* %6, null
br i1 %42, label %45, label %43
43: ; preds = %41
%44 = tail call i32 @passphrase_mask(i32 %0, i8** %1, i32 %4)
br label %47
45: ; preds = %41
%46 = tail call i8* @checkpassphrase(i32 %9)
br label %47
47: ; preds = %45, %43
%48 = phi i8* [ %6, %43 ], [ %46, %45 ]
%49 = tail call i32 @start_aed(i32 %9, i8* %48, i8* %12)
ret i32 0
}