#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 */
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *get_boolean_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);
  for (a = 0; a < argc; a++) {
    if (strcmp(argv[a], temp) == 0) {
      return (argv[a] + strlen(temp));
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_boolean_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_boolean_option+0x41>
movq   $0x0,-0x8(%rbp)
jmp    1245 <get_boolean_option+0xf5>
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>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123d <get_boolean_option+0xed>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x130(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <get_boolean_option+0xda>
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    1245 <get_boolean_option+0xf5>
jmp    122f <get_boolean_option+0xdf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c5 <get_boolean_option+0x75>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_boolean_option>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%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     121c <get_boolean_option+0xdc>
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe32(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xfe,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0xfe,%edx
call   1050 <strncat@plt>
test   %r14d,%r14d
jle    121c <get_boolean_option+0xdc>
mov    %r14d,%ebp
xor    %r14d,%r14d
mov    %rsp,%r15
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1221 <get_boolean_option+0xe1>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <get_boolean_option+0xc0>
jmp    1233 <get_boolean_option+0xf3>
xor    %r14d,%r14d
jmp    1233 <get_boolean_option+0xf3>
mov    (%r12,%rbx,8),%rbx
mov    %rsp,%rdi
call   1040 <strlen@plt>
movslq %eax,%r14
add    %rbx,%r14
mov    %r14,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
define i8* @get_boolean_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 %48
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)
store i32 0, i32* %8
br label %20
20: ; preds = %44, %14
%21 = load i32, i32* %8
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %47
24: ; preds = %20
%25 = load i8**, i8*** %7
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %24
%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 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8* %42, i8** %4
br label %48
43: ; preds = %24
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %20
47: ; preds = %20
store i8* null, i8** %4
br label %48
48: ; preds = %47, %33, %13
%49 = load i8*, i8** %4
ret i8* %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
define i8* @get_boolean_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 %29, 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 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %26
%14 = phi i64 [ 0, %11 ], [ %27, %26 ]
%15 = getelementptr inbounds i8*, i8** %2, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = and i64 %14, 4294967295
%21 = getelementptr inbounds i8*, i8** %2, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %5)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
br label %29
26: ; preds = %13
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, %12
br i1 %28, label %29, label %13
29: ; preds = %26, %7, %3, %19
%30 = phi i8* [ %25, %19 ], [ null, %3 ], [ null, %7 ], [ null, %26 ]
ret i8* %30
}