#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*/ doHelp();
scalar_t__ isValidKey(char const);
int strlen(char const *);
char getOptionKey(const char *argument) {
  if (strlen(argument) == 2) {
    if (argument[0] == '-') {
      if (isValidKey(argument[1])) {
        return argument[1];
      }
    }
  }
  doHelp();
}


x86 assembly (clang, -O0):
<getOptionKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    118e <getOptionKey+0x5e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1189 <getOptionKey+0x59>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <isValidKey@plt>
cmp    $0x0,%rax
je     1184 <getOptionKey+0x54>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1(%rbp)
jmp    1195 <getOptionKey+0x65>
jmp    1189 <getOptionKey+0x59>
jmp    118e <getOptionKey+0x5e>
mov    $0x0,%al
call   1050 <doHelp@plt>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOptionKey>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    1156 <getOptionKey+0x26>
cmpb   $0x2d,(%rbx)
jne    1156 <getOptionKey+0x26>
movsbl 0x1(%rbx),%edi
call   1040 <isValidKey@plt>
test   %rax,%rax
je     1156 <getOptionKey+0x26>
mov    0x1(%rbx),%al
pop    %rbx
ret
xor    %eax,%eax
call   1050 <doHelp@plt>
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @getOptionKey(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strlen(i8* %4)
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 45
br i1 %12, label %13, label %24
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = call i64 @isValidKey(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
store i8 %22, i8* %2
br label %27
23: ; preds = %13
br label %24
24: ; preds = %23, %7
br label %25
25: ; preds = %24, %1
%26 = call i32 (...) @doHelp()
br label %27
27: ; preds = %25, %19
%28 = load i8, i8* %2
ret i8 %28
}

LLVM IR (-O2):
define signext i8 @getOptionKey(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 2
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 45
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call i64 @isValidKey(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = load i8, i8* %8
br label %16
14: ; preds = %4, %7, %1
%15 = tail call i32 (...) @doHelp()
br label %16
16: ; preds = %14, %12
%17 = phi i8 [ %13, %12 ], [ undef, %14 ]
ret i8 %17
}