#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 str_indexof(char *, char *);
int /*<<< orphan*/ str_starts_with(char *, char *);
char *get_arg_assignment(char *arg) {
  if (!str_starts_with(arg, "--")) {
    return NULL;
  }
  int eq_index = str_indexof(arg, "=");
  if (eq_index == -1) {
    return NULL;
  }
  for (int i = 0; i < eq_index; i++) {
    if (arg[i] == '\'' || arg[i] == '"') {
      return NULL;
    }
  }
  return &arg[eq_index];
}


x86 assembly (clang, -O0):
<get_arg_assignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <str_starts_with@plt>
cmp    $0x0,%eax
jne    1152 <get_arg_assignment+0x32>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <get_arg_assignment+0xc8>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <str_indexof@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    117c <get_arg_assignment+0x5c>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <get_arg_assignment+0xc8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d9 <get_arg_assignment+0xb9>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
je     11b9 <get_arg_assignment+0x99>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11c6 <get_arg_assignment+0xa6>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <get_arg_assignment+0xc8>
jmp    11cb <get_arg_assignment+0xab>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1183 <get_arg_assignment+0x63>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arg_assignment>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1030 <str_starts_with@plt>
test   %eax,%eax
je     116e <get_arg_assignment+0x4e>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <str_indexof@plt>
cmp    $0xffffffff,%eax
je     116e <get_arg_assignment+0x4e>
test   %eax,%eax
jle    1167 <get_arg_assignment+0x47>
mov    %eax,%esi
xor    %edx,%edx
movzbl (%rbx,%rdx,1),%ecx
cmp    $0x22,%cl
je     116e <get_arg_assignment+0x4e>
cmp    $0x27,%cl
je     116e <get_arg_assignment+0x4e>
add    $0x1,%rdx
cmp    %rdx,%rsi
jne    1150 <get_arg_assignment+0x30>
cltq
add    %rax,%rbx
jmp    1170 <get_arg_assignment+0x50>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_arg_assignment(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @str_starts_with(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %47
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @str_indexof(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %10
store i8* null, i8** %2
br label %47
16: ; preds = %10
store i32 0, i32* %5
br label %17
17: ; preds = %39, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 39
br i1 %28, label %37, label %29
29: ; preds = %21
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 34
br i1 %36, label %37, label %38
37: ; preds = %29, %21
store i8* null, i8** %2
br label %47
38: ; preds = %29
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %17
42: ; preds = %17
%43 = load i8*, i8** %3
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8* %46, i8** %2
br label %47
47: ; preds = %42, %37, %15, %9
%48 = load i8*, i8** %2
ret i8* %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_arg_assignment(i8* %0) {
%2 = tail call i32 @str_starts_with(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = tail call i32 @str_indexof(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, -1
br i1 %6, label %21, label %7
7: ; preds = %4
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %18
9: ; preds = %7
%10 = zext i32 %5 to i64
br label %11
11: ; preds = %9, %15
%12 = phi i64 [ 0, %9 ], [ %16, %15 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 39, label %21
i8 34, label %21
]
15: ; preds = %11
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %15, %7
%19 = sext i32 %5 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
br label %21
21: ; preds = %11, %11, %18, %4, %1
%22 = phi i8* [ null, %1 ], [ %20, %18 ], [ null, %4 ], [ null, %11 ], [ null, %11 ]
ret i8* %22
}