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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strstr(char *, char *);
char *get_option(const char *option, char *default_value, const int argc,
                 char **argv) {
  static char retval[8192];
  int a;
  char temp[8192] = "";
  memset(temp, 0, sizeof(temp));
  temp[0] = '-';
  temp[1] = '-';
  strncpy(&temp[2], option, sizeof(temp) - 1);
  for (a = 0; a < argc; a++) {
    if (strcmp(argv[a], temp) == 0) {
      return "1";
    }
  }
  strncat(temp, "=", sizeof(temp) - 1);
  for (a = 0; a < argc; a++) {
    if (strstr(argv[a], temp) == argv[a]) {
      return argv[a] + strlen(temp);
    }
  }
  memset(retval, 0, sizeof(retval));
  if (default_value != NULL) {
    strncpy(retval, default_value, sizeof(retval) - 1);
  } else {
    return NULL;
  }
  return retval;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1050 <memset@plt>
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1050 <memset@plt>
movb   $0x2d,-0x2030(%rbp)
movb   $0x2d,-0x202f(%rbp)
lea    -0x2030(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1fff,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    121f <get_option+0xbf>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x2030(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <get_option+0xac>
lea    0xdfd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130e <get_option+0x1ae>
jmp    1211 <get_option+0xb1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ce <get_option+0x6e>
lea    -0x2030(%rbp),%rdi
lea    0xdd5(%rip),%rsi
mov    $0x1fff,%edx
call   1060 <strncat@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12be <get_option+0x15e>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x2030(%rbp),%rsi
call   1080 <strstr@plt>
mov    -0x28(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jne    12ab <get_option+0x14b>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x2038(%rbp)
lea    -0x2030(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    130e <get_option+0x1ae>
jmp    12b0 <get_option+0x150>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123e <get_option+0xde>
lea    0x2d9b(%rip),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1050 <memset@plt>
cmpq   $0x0,-0x18(%rbp)
je     12f6 <get_option+0x196>
mov    -0x18(%rbp),%rsi
lea    0x2d79(%rip),%rdi
mov    $0x1fff,%edx
call   1030 <strncpy@plt>
jmp    1303 <get_option+0x1a3>
movq   $0x0,-0x8(%rbp)
jmp    130e <get_option+0x1ae>
lea    0x2d56(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x10(%rsp),%rbp
mov    $0x2000,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1060 <memset@plt>
movw   $0x2d2d,0x10(%rsp)
lea    0x12(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x1fff,%edx
call   1030 <strncpy@plt>
test   %r12d,%r12d
jle    1259 <get_option+0xf9>
mov    %r13,0x8(%rsp)
mov    %r12d,%r14d
xor    %ebp,%ebp
lea    0x10(%rsp),%r13
lea    0xe28(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12af <get_option+0x14f>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11e0 <get_option+0x80>
lea    0xdfd(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x1fff,%edx
call   1070 <strncat@plt>
test   %r12d,%r12d
mov    0x8(%rsp),%r13
jle    126f <get_option+0x10f>
xor    %ebp,%ebp
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,8),%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
test   %eax,%eax
je     12a0 <get_option+0x140>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1230 <get_option+0xd0>
jmp    126f <get_option+0x10f>
lea    0xda2(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x1fff,%edx
call   1070 <strncat@plt>
lea    0x2dea(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1060 <memset@plt>
test   %r13,%r13
je     129c <get_option+0x13c>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1fff,%edx
call   1030 <strncpy@plt>
jmp    12af <get_option+0x14f>
xor    %ebx,%ebx
jmp    12af <get_option+0x14f>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_option.retval = internal global [8192 x i8] zeroinitializer
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_option(i8* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca [8192 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
%12 = bitcast [8192 x i8]* %11 to i8*
%13 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 8192)
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
store i8 45, i8* %15
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 1
store i8 45, i8* %16
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 2
%18 = load i8*, i8** %6
%19 = call i32 @strncpy(i8* %17, i8* %18, i32 8191)
store i32 0, i32* %10
br label %20
20: ; preds = %35, %4
%21 = load i32, i32* %10
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i8**, i8*** %9
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %24
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5
br label %82
34: ; preds = %24
br label %35
35: ; preds = %34
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %20
38: ; preds = %20
%39 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%40 = call i32 @strncat(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 8191)
store i32 0, i32* %10
br label %41
41: ; preds = %70, %38
%42 = load i32, i32* %10
%43 = load i32, i32* %8
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %73
45: ; preds = %41
%46 = load i8**, i8*** %9
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%52 = call i8* @strstr(i8* %50, i8* %51)
%53 = load i8**, i8*** %9
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = icmp eq i8* %52, %57
br i1 %58, label %59, label %69
59: ; preds = %45
%60 = load i8**, i8*** %9
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%66 = call i32 @strlen(i8* %65)
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
store i8* %68, i8** %5
br label %82
69: ; preds = %45
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %41
73: ; preds = %41
%74 = call i32 @memset(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), i32 0, i32 8192)
%75 = load i8*, i8** %7
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = load i8*, i8** %7
%79 = call i32 @strncpy(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), i8* %78, i32 8191)
br label %81
80: ; preds = %73
store i8* null, i8** %5
br label %82
81: ; preds = %77
store i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), i8** %5
br label %82
82: ; preds = %81, %80, %59, %33
%83 = load i8*, i8** %5
ret i8* %83
}

LLVM IR (-O2):
@get_option.retval = internal global [8192 x i8] zeroinitializer
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @get_option(i8* %0, i8* %1, i32 %2, i8** nocapture %3) {
%5 = alloca [8192 x i8]
%6 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 8192)
store i8 45, i8* %6
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 1
store i8 45, i8* %8
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 2
%10 = call i32 @strncpy(i8* %9, i8* %0, i32 8191)
%11 = icmp sgt i32 %2, 0
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 8191)
br label %43
14: ; preds = %4
%15 = zext i32 %2 to i64
br label %18
16: ; preds = %18
%17 = icmp eq i64 %24, %15
br i1 %17, label %25, label %18
18: ; preds = %14, %16
%19 = phi i64 [ 0, %14 ], [ %24, %16 ]
%20 = getelementptr inbounds i8*, i8** %3, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* %6)
%23 = icmp eq i64 %22, 0
%24 = add nuw nsw i64 %19, 1
br i1 %23, label %48, label %16
25: ; preds = %16
%26 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 8191)
br i1 %11, label %27, label %43
27: ; preds = %25
%28 = zext i32 %2 to i64
br label %31
29: ; preds = %31
%30 = icmp eq i64 %38, %28
br i1 %30, label %43, label %31
31: ; preds = %27, %29
%32 = phi i64 [ 0, %27 ], [ %38, %29 ]
%33 = getelementptr inbounds i8*, i8** %3, i64 %32
%34 = load i8*, i8** %33
%35 = call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %6)
%36 = call i32 @strncmp(i8* %34, i8* %6, i64 %35)
%37 = icmp eq i32 %36, 0
%38 = add nuw nsw i64 %32, 1
br i1 %37, label %39, label %29
39: ; preds = %31
%40 = call i32 @strlen(i8* %6)
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %34, i64 %41
br label %48
43: ; preds = %29, %12, %25
%44 = call i32 @memset(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), i32 0, i32 8192)
%45 = icmp eq i8* %1, null
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @strncpy(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), i8* %1, i32 8191)
br label %48
48: ; preds = %18, %43, %46, %39
%49 = phi i8* [ %42, %39 ], [ getelementptr inbounds ([8192 x i8], [8192 x i8]* @get_option.retval, i64 0, i64 0), %46 ], [ null, %43 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %18 ]
ret i8* %49
}