#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 */
typedef int /*<<< orphan*/ temp;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
char *get_option(const char *option, char **argv, int argc) {
  char temp[256];
  int a = 0;
  if (option == NULL || argv == NULL) {
    return NULL;
  }
  memset(temp, 0, sizeof(temp));
  strncpy(temp, "--", sizeof(temp) - 1);
  strncat(temp, option, sizeof(temp) - 1);
  strncat(temp, "=", sizeof(temp) - 1);
  for (a = 0; a < argc; a++) {
    if (strstr(argv[a], temp) == argv[a]) {
      return (&argv[a][0] + strlen(temp));
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x124(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1186 <get_option+0x36>
cmpq   $0x0,-0x18(%rbp)
jne    1193 <get_option+0x43>
movq   $0x0,-0x8(%rbp)
jmp    128f <get_option+0x13f>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xff,%edx
call   1060 <strncat@plt>
lea    -0x120(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0xff,%edx
call   1060 <strncat@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1287 <get_option+0x137>
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x120(%rbp),%rsi
call   1070 <strstr@plt>
mov    -0x18(%rbp),%rcx
movslq -0x124(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jne    126e <get_option+0x11e>
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x130(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    128f <get_option+0x13f>
jmp    1273 <get_option+0x123>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11f5 <get_option+0xa5>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
xor    %r14d,%r14d
test   %rdi,%rdi
je     1219 <get_option+0xc9>
mov    %rsi,%r12
test   %rsi,%rsi
je     1219 <get_option+0xc9>
mov    %edx,%r15d
mov    %rdi,%rbp
mov    %rsp,%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
mov    $0xff,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0xff,%edx
call   1070 <strncat@plt>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
mov    $0xff,%edx
call   1070 <strncat@plt>
test   %r15d,%r15d
jle    1219 <get_option+0xc9>
mov    %r15d,%r15d
xor    %r14d,%r14d
mov    %rsp,%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1209 <get_option+0xb9>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11e0 <get_option+0x90>
jmp    1219 <get_option+0xc9>
mov    %rsp,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%r14
mov    %r14,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_option(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 0, i32* %9
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i8**, i8*** %6
%14 = icmp eq i8** %13, null
br i1 %14, label %15, label %16
15: ; preds = %12, %3
store i8* null, i8** %4
br label %60
16: ; preds = %12
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 256)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%20 = call i32 @strncpy(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 255)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i32 @strncat(i8* %21, i8* %22, i32 255)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%25 = call i32 @strncat(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 255)
store i32 0, i32* %9
br label %26
26: ; preds = %56, %16
%27 = load i32, i32* %9
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %59
30: ; preds = %26
%31 = load i8**, i8*** %6
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%37 = call i8* @strstr(i8* %35, i8* %36)
%38 = load i8**, i8*** %6
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = icmp eq i8* %37, %42
br i1 %43, label %44, label %55
44: ; preds = %30
%45 = load i8**, i8*** %6
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
store i8* %54, i8** %4
br label %60
55: ; preds = %30
br label %56
56: ; preds = %55
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %26
59: ; preds = %26
store i8* null, i8** %4
br label %60
60: ; preds = %59, %44, %15
%61 = load i8*, i8** %4
ret i8* %61
}

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_option(i8* %0, i8** %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
%7 = icmp eq i8** %1, null
%8 = or i1 %6, %7
br i1 %8, label %31, label %9
9: ; preds = %3
%10 = call i32 @memset(i8* %5, i32 0, i32 256)
%11 = call i32 @strncpy(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 255)
%12 = call i32 @strncat(i8* %5, i8* %0, i32 255)
%13 = call i32 @strncat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 255)
%14 = icmp sgt i32 %2, 0
br i1 %14, label %15, label %31
15: ; preds = %9
%16 = zext i32 %2 to i64
br label %19
17: ; preds = %19
%18 = icmp eq i64 %26, %16
br i1 %18, label %31, label %19
19: ; preds = %15, %17
%20 = phi i64 [ 0, %15 ], [ %26, %17 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %5)
%24 = call i32 @strncmp(i8* %22, i8* %5, i64 %23)
%25 = icmp eq i32 %24, 0
%26 = add nuw nsw i64 %20, 1
br i1 %25, label %27, label %17
27: ; preds = %19
%28 = call i32 @strlen(i8* %5)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %22, i64 %29
br label %31
31: ; preds = %17, %9, %3, %27
%32 = phi i8* [ %30, %27 ], [ null, %3 ], [ null, %9 ], [ null, %17 ]
ret i8* %32
}