#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 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, const int argc, char **argv) {
  int a;
  char temp[255] = "";
  if (option == NULL) {
    return NULL;
  }
  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] + strlen(temp));
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1191 <get_option+0x41>
movq   $0x0,-0x8(%rbp)
jmp    1265 <get_option+0x115>
lea    -0x130(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0xfe,%edx
call   1030 <strncpy@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xfe,%edx
call   1060 <strncat@plt>
lea    -0x130(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0xfe,%edx
call   1060 <strncat@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125d <get_option+0x10d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x130(%rbp),%rsi
call   1070 <strstr@plt>
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jne    124a <get_option+0xfa>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x138(%rbp)
lea    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x138(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1265 <get_option+0x115>
jmp    124f <get_option+0xff>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11dd <get_option+0x8d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%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
xorps  %xmm0,%xmm0
movups %xmm0,0xef(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
test   %rdi,%rdi
je     1249 <get_option+0x109>
mov    %rdx,%r15
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe2c(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xfe,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0xfe,%edx
call   1060 <strncat@plt>
lea    0xe08(%rip),%rsi
mov    %rbx,%rdi
mov    $0xfe,%edx
call   1060 <strncat@plt>
test   %r14d,%r14d
jle    1249 <get_option+0x109>
mov    %r14d,%r12d
xor    %r14d,%r14d
mov    %rsp,%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r15,%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     124e <get_option+0x10e>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1220 <get_option+0xe0>
jmp    125e <get_option+0x11e>
xor    %r14d,%r14d
jmp    125e <get_option+0x11e>
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, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca [255 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%10 = bitcast [255 x i8]* %9 to i8*
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i8* null, i8** %4
br label %55
14: ; preds = %3
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%16 = call i32 @strncpy(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 254)
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @strncat(i8* %17, i8* %18, i32 254)
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%21 = call i32 @strncat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 254)
store i32 0, i32* %8
br label %22
22: ; preds = %51, %14
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %54
26: ; preds = %22
%27 = load i8**, i8*** %7
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%33 = call i8* @strstr(i8* %31, i8* %32)
%34 = load i8**, i8*** %7
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = icmp eq i8* %33, %38
br i1 %39, label %40, label %50
40: ; preds = %26
%41 = load i8**, i8*** %7
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
store i8* %49, i8** %4
br label %55
50: ; preds = %26
br label %51
51: ; preds = %50
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %22
54: ; preds = %22
store i8* null, i8** %4
br label %55
55: ; preds = %54, %40, %13
%56 = load i8*, i8** %4
ret i8* %56
}

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