#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*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ help(char *);
scalar_t__ opterr;
int optind;
int /*<<< orphan*/ stderr;
int parse_input(int argc, char *argv[], char **password, int *operation) {
  *password = NULL;
  *operation = -1;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "hed")) != -1) {
    switch (c) {
    case 'h':
      help(argv[0]);
      return 1;
      break;
    case 'e':
      if (*operation != -1) {
        fprintf(stderr, "ERROR: -e and -d flags are mutually exclusive\n");
        return -1;
      }
      *operation = 1;
      break;
    case 'd':
      if (*operation != -1) {
        fprintf(stderr, "ERROR: -e and -d flags are mutually exclusive\n");
        return -1;
      }
      *operation = 0;
      break;
    }
  }
  if (optind >= argc) {
    fprintf(stderr, "ERROR: Expected exactly 1 positional argument.\n");
    return -1;
  }
  *password = argv[optind++];
  if (optind != argc) {
    fprintf(stderr, "ERROR: Extra arguments found.\n");
    return -1;
  }
  if (*password == NULL) {
    fprintf(stderr, "ERROR: Password not set.\n");
    return -1;
  }
  if (*operation == -1) {
    fprintf(stderr, "ERROR: Operation not set.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    0x2e6d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1251 <parse_input+0x121>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x64,%eax
je     1214 <parse_input+0xe4>
jmp    119d <parse_input+0x6d>
mov    -0x28(%rbp),%eax
sub    $0x65,%eax
je     11d7 <parse_input+0xa7>
jmp    11ae <parse_input+0x7e>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
jne    124c <parse_input+0x11c>
jmp    11bf <parse_input+0x8f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
je     1205 <parse_input+0xd5>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    124c <parse_input+0x11c>
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
je     1242 <parse_input+0x112>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    116a <parse_input+0x3a>
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1284 <parse_input+0x154>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x10(%rbp),%rax
mov    0x2d59(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d4b(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     12e0 <parse_input+0x1b0>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    130f <parse_input+0x1df>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    133d <parse_input+0x20d>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
lea    0xd70(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1344 <parse_input+0x214>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_input>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
movq   $0x0,(%rdx)
movl   $0xffffffff,(%rcx)
mov    0x2e79(%rip),%rax
movq   $0x0,(%rax)
lea    0xe9b(%rip),%r12
jmp    1170 <parse_input+0x40>
cmp    $0x68,%eax
je     11f6 <parse_input+0xc6>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <getopt@plt>
cmp    $0x64,%eax
jg     1190 <parse_input+0x60>
jne    11a3 <parse_input+0x73>
xor    %eax,%eax
cmpl   $0xffffffff,(%rbx)
je     119f <parse_input+0x6f>
jmp    11e4 <parse_input+0xb4>
nopl   (%rax)
cmp    $0x65,%eax
jne    1167 <parse_input+0x37>
mov    $0x1,%eax
cmpl   $0xffffffff,(%rbx)
jne    11e4 <parse_input+0xb4>
mov    %eax,(%rbx)
jmp    1170 <parse_input+0x40>
cmp    $0xffffffff,%eax
jne    1170 <parse_input+0x40>
mov    0x2e39(%rip),%rax
movslq (%rax),%rcx
cmp    %ebp,%ecx
jge    1205 <parse_input+0xd5>
lea    0x1(%rcx),%edx
mov    %edx,(%rax)
mov    (%r15,%rcx,8),%rax
mov    %rax,(%r14)
cmp    %ebp,%edx
jne    1217 <parse_input+0xe7>
test   %rax,%rax
je     1229 <parse_input+0xf9>
xor    %eax,%eax
cmpl   $0xffffffff,(%rbx)
jne    1243 <parse_input+0x113>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
jmp    1239 <parse_input+0x109>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
jmp    1239 <parse_input+0x109>
mov    (%r15),%rdi
call   1050 <help@plt>
mov    $0x1,%eax
jmp    1243 <parse_input+0x113>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
jmp    1239 <parse_input+0x109>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
jmp    1239 <parse_input+0x109>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [4 x i8] c"hed\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"ERROR: -e and -d flags are mutually exclusive\0A\00"
@optind = global i32 0
@.str.2 = [48 x i8] c"ERROR: Expected exactly 1 positional argument.\0A\00"
@.str.3 = [31 x i8] c"ERROR: Extra arguments found.\0A\00"
@.str.4 = [26 x i8] c"ERROR: Password not set.\0A\00"
@.str.5 = [27 x i8] c"ERROR: Operation not set.\0A\00"
define i32 @parse_input(i32 %0, i8** %1, i8** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
%11 = load i8**, i8*** %8
store i8* null, i8** %11
%12 = load i32*, i32** %9
store i32 -1, i32* %12
store i64 0, i64* @opterr
br label %13
13: ; preds = %43, %4
%14 = load i32, i32* %6
%15 = load i8**, i8*** %7
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %44
18: ; preds = %13
%19 = load i32, i32* %10
switch i32 %19, label %43 [
i32 104, label %20
i32 101, label %25
i32 100, label %34
]
20: ; preds = %18
%21 = load i8**, i8*** %7
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @help(i8* %23)
store i32 1, i32* %5
br label %80
25: ; preds = %18
%26 = load i32*, i32** %9
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
32: ; preds = %25
%33 = load i32*, i32** %9
store i32 1, i32* %33
br label %43
34: ; preds = %18
%35 = load i32*, i32** %9
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
41: ; preds = %34
%42 = load i32*, i32** %9
store i32 0, i32* %42
br label %43
43: ; preds = %18, %41, %32
br label %13
44: ; preds = %13
%45 = load i32, i32* @optind
%46 = load i32, i32* %6
%47 = icmp sge i32 %45, %46
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
51: ; preds = %44
%52 = load i8**, i8*** %7
%53 = load i32, i32* @optind
%54 = add nsw i32 %53, 1
store i32 %54, i32* @optind
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8*, i8** %52, i64 %55
%57 = load i8*, i8** %56
%58 = load i8**, i8*** %8
store i8* %57, i8** %58
%59 = load i32, i32* @optind
%60 = load i32, i32* %6
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %65
62: ; preds = %51
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
65: ; preds = %51
%66 = load i8**, i8*** %8
%67 = load i8*, i8** %66
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
72: ; preds = %65
%73 = load i32*, i32** %9
%74 = load i32, i32* %73
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %5
br label %80
79: ; preds = %72
store i32 0, i32* %5
br label %80
80: ; preds = %79, %76, %69, %62, %48, %38, %29, %20
%81 = load i32, i32* %5
ret i32 %81
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [4 x i8] c"hed\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"ERROR: -e and -d flags are mutually exclusive\0A\00"
@optind = global i32 0
@.str.2 = [48 x i8] c"ERROR: Expected exactly 1 positional argument.\0A\00"
@.str.3 = [31 x i8] c"ERROR: Extra arguments found.\0A\00"
@.str.4 = [26 x i8] c"ERROR: Password not set.\0A\00"
@.str.5 = [27 x i8] c"ERROR: Operation not set.\0A\00"
define i32 @parse_input(i32 %0, i8** %1, i8** nocapture writeonly %2, i32* nocapture %3) {
store i8* null, i8** %2
store i32 -1, i32* %3
store i64 0, i64* @opterr
br label %5
5: ; preds = %24, %4
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %24 [
i32 -1, label %25
i32 104, label %7
i32 101, label %10
i32 100, label %16
]
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = tail call i32 @help(i8* %8)
br label %51
10: ; preds = %5
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, -1
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %51
16: ; preds = %5
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, -1
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %51
22: ; preds = %16, %10
%23 = phi i32 [ 1, %10 ], [ 0, %16 ]
store i32 %23, i32* %3
br label %24
24: ; preds = %22, %5
br label %5
25: ; preds = %5
%26 = load i32, i32* @optind
%27 = icmp slt i32 %26, %0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %51
31: ; preds = %25
%32 = add nsw i32 %26, 1
store i32 %32, i32* @optind
%33 = sext i32 %26 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
store i8* %35, i8** %2
%36 = icmp eq i32 %32, %0
br i1 %36, label %40, label %37
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %51
40: ; preds = %31
%41 = icmp eq i8* %35, null
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = load i32, i32* @stderr
%44 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %51
45: ; preds = %40
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %51
51: ; preds = %45, %48, %42, %37, %28, %19, %13, %7
%52 = phi i32 [ -1, %19 ], [ -1, %13 ], [ 1, %7 ], [ -1, %28 ], [ -1, %37 ], [ -1, %42 ], [ -1, %48 ], [ 0, %45 ]
ret i32 %52
}