#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 /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int get_bool_opt(char *argv, char *name, int *value) {
  int rv = -1;
  if (!strncmp(argv, "--no-", 5)) {
    rv = 0;
    argv += 5;
  }
  if (!strncmp(argv, "--", 2)) {
    rv = 1;
    argv += 2;
  }
  if (rv == -1)
    return -1;
  if (!strcmp(argv, name)) {
    *value = rv;
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<get_bool_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    116c <get_bool_opt+0x4c>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    119d <get_bool_opt+0x7d>
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    11b3 <get_bool_opt+0x93>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <get_bool_opt+0xc5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <get_bool_opt+0xbe>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11e5 <get_bool_opt+0xc5>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bool_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xec5(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
xor    %ecx,%ecx
test   %eax,%eax
setne  %bpl
sete   %cl
lea    (%rcx,%rcx,4),%rbx
add    %r12,%rbx
neg    %ebp
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
mov    $0x1,%r13d
cmovne %ebp,%r13d
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%r13d
je     11a4 <get_bool_opt+0x84>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rbx,%rcx,2),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11a4 <get_bool_opt+0x84>
mov    %r13d,(%r14)
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"--no-\00"
@.str.1 = [3 x i8] c"--\00"
define i32 @get_bool_opt(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 -1, i32* %8
%9 = load i8*, i8** %5
%10 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
store i32 0, i32* %8
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 5
store i8* %14, i8** %5
br label %15
15: ; preds = %12, %3
%16 = load i8*, i8** %5
%17 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
store i32 1, i32* %8
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8* %21, i8** %5
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 -1, i32* %4
br label %35
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = call i32 @strcmp(i8* %27, i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = load i32, i32* %8
%33 = load i32*, i32** %7
store i32 %32, i32* %33
store i32 0, i32* %4
br label %35
34: ; preds = %26
store i32 -1, i32* %4
br label %35
35: ; preds = %34, %31, %25
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [6 x i8] c"--no-\00"
@.str.1 = [3 x i8] c"--\00"
define i32 @get_bool_opt(i8* %0, i8* nocapture %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i64 5, i64 0
%7 = getelementptr i8, i8* %0, i64 %6
%8 = xor i1 %5, true
%9 = sext i1 %8 to i32
%10 = tail call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 1, i32 %9
%13 = icmp eq i32 %12, -1
br i1 %13, label %20, label %14
14: ; preds = %3
%15 = select i1 %11, i64 2, i64 0
%16 = getelementptr i8, i8* %7, i64 %15
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(1) %1)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 %12, i32* %2
br label %20
20: ; preds = %14, %3, %19
%21 = phi i32 [ 0, %19 ], [ -1, %3 ], [ -1, %14 ]
ret i32 %21
}