#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 no_argument;
int optional_argument;
int required_argument;
size_t strlen(char *);
int hc_extract_argument(char *name) {
  size_t length = strlen(name);
  if (length > 1 && name[length - 1] == '=') {
    return required_argument;
  } else if (length > 2 && name[length - 2] == '=' && name[length - 1] == '?') {
    return optional_argument;
  } else {
    return no_argument;
  }
}


x86 assembly (clang, -O0):
<hc_extract_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
jbe    115e <hc_extract_argument+0x4e>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    115e <hc_extract_argument+0x4e>
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <hc_extract_argument+0xa8>
cmpq   $0x2,-0x18(%rbp)
jbe    11ac <hc_extract_argument+0x9c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    11ac <hc_extract_argument+0x9c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    11ac <hc_extract_argument+0x9c>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <hc_extract_argument+0xa8>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hc_extract_argument>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     114c <hc_extract_argument+0x3c>
mov    -0x1(%rax,%rbx,1),%cl
cmp    $0x3d,%cl
jne    1131 <hc_extract_argument+0x21>
mov    0x2eb1(%rip),%rax
jmp    1153 <hc_extract_argument+0x43>
cmp    $0x3,%rax
jb     114c <hc_extract_argument+0x3c>
cmpb   $0x3d,-0x2(%rax,%rbx,1)
jne    114c <hc_extract_argument+0x3c>
cmp    $0x3f,%cl
jne    114c <hc_extract_argument+0x3c>
mov    0x2e9e(%rip),%rax
jmp    1153 <hc_extract_argument+0x43>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@required_argument = global i32 0
@optional_argument = global i32 0
@no_argument = global i32 0
define i32 @hc_extract_argument(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = icmp ugt i64 %7, 1
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i64, i64* %4
%12 = sub i64 %11, 1
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 61
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = load i32, i32* @required_argument
store i32 %18, i32* %2
br label %42
19: ; preds = %9, %1
%20 = load i64, i64* %4
%21 = icmp ugt i64 %20, 2
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i64, i64* %4
%25 = sub i64 %24, 2
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 61
br i1 %29, label %30, label %40
30: ; preds = %22
%31 = load i8*, i8** %3
%32 = load i64, i64* %4
%33 = sub i64 %32, 1
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 63
br i1 %37, label %38, label %40
38: ; preds = %30
%39 = load i32, i32* @optional_argument
store i32 %39, i32* %2
br label %42
40: ; preds = %30, %22, %19
%41 = load i32, i32* @no_argument
store i32 %41, i32* %2
br label %42
42: ; preds = %40, %38, %17
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@required_argument = global i32 0
@optional_argument = global i32 0
@no_argument = global i32 0
define i32 @hc_extract_argument(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp ugt i64 %2, 1
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = add i64 %2, -1
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 61
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = icmp ugt i64 %2, 2
br i1 %10, label %11, label %18
11: ; preds = %9
%12 = add i64 %2, -2
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 61
%16 = icmp eq i8 %7, 63
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %19, label %18
18: ; preds = %1, %11, %9
br label %19
19: ; preds = %11, %4, %18
%20 = phi i32* [ @no_argument, %18 ], [ @required_argument, %4 ], [ @optional_argument, %11 ]
%21 = load i32, i32* %20
ret i32 %21
}