#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*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char const *, char const *);
int get_boolean(const char *arg) {
  int i;
  static const struct _bool_table {
    const char *on;
    const char *off;
  } bool_table[] = {{"on", "off"},
                    {"1", "0"},
                    {"true", "false"},
                    {"yes", "no"},
                    {.on = NULL}};
  for (i = 0; bool_table[i].on; ++i) {
    if (!strcasecmp(arg, bool_table[i].on))
      return 1;
    else if (!strcasecmp(arg, bool_table[i].off))
      return 0;
  }
  fprintf(stderr, "\"%s\" is not a boolean value: <", arg);
  for (i = 0; bool_table[i].on; ++i) {
    fprintf(stderr, "%s|%s%s", bool_table[i].on, bool_table[i].off,
            (bool_table[i + 1].off ? "|" : ">\n"));
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2c82(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     11ce <get_boolean+0xae>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2c62(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1182 <get_boolean+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1294 <get_boolean+0x174>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2c2f(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11b6 <get_boolean+0x96>
movl   $0x0,-0x4(%rbp)
jmp    1294 <get_boolean+0x174>
jmp    11bb <get_boolean+0x9b>
jmp    11c0 <get_boolean+0xa0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <get_boolean+0x13>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2bc5(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     128d <get_boolean+0x16d>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rcx
lea    0x2ba0(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdx
movslq -0x14(%rbp),%rcx
lea    0x2b8b(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rcx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rsi
lea    0x2b70(%rip),%rax
shl    $0x4,%rsi
add    %rsi,%rax
mov    0x8(%rax),%rsi
lea    0xde4(%rip),%r8
lea    0xddb(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%r8
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f0 <get_boolean+0xd0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_boolean>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed2(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     1294 <get_boolean+0x174>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1292 <get_boolean+0x172>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1294 <get_boolean+0x174>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1292 <get_boolean+0x172>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1294 <get_boolean+0x174>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1292 <get_boolean+0x172>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1294 <get_boolean+0x174>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x0,%ebp
test   %eax,%eax
je     1294 <get_boolean+0x174>
mov    0x2df3(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe26(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe31(%rip),%rbx
lea    0xdee(%rip),%rdx
lea    0xdea(%rip),%rcx
lea    0xe24(%rip),%r14
mov    %rbx,%rsi
mov    %r14,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdd0(%rip),%rdx
lea    0xdcb(%rip),%rcx
mov    %rbx,%rsi
mov    %r14,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdb6(%rip),%rdx
lea    0xdb4(%rip),%rcx
mov    %rbx,%rsi
mov    %r14,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xda3(%rip),%rdx
lea    0xda0(%rip),%rcx
lea    0xdc5(%rip),%r8
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1294 <get_boolean+0x174>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct._bool_table = type { i8*, i8* }
@get_boolean.bool_table = internal constant [5 x %struct._bool_table] [%struct._bool_table { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0) }, %struct._bool_table { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0) }, %struct._bool_table { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0) }, %struct._bool_table { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0) }, %struct._bool_table zeroinitializer]
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [5 x i8] c"true\00"
@.str.5 = [6 x i8] c"false\00"
@.str.6 = [4 x i8] c"yes\00"
@.str.7 = [3 x i8] c"no\00"
@stderr = global i32 0
@.str.8 = [31 x i8] c"\22%s\22 is not a boolean value: <\00"
@.str.9 = [8 x i8] c"%s|%s%s\00"
@.str.10 = [2 x i8] c"|\00"
@.str.11 = [3 x i8] c">\0A\00"
define i32 @get_boolean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %34, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %7
%9 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %37
12: ; preds = %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %15
%17 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @strcasecmp(i8* %13, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %12
store i32 1, i32* %2
br label %74
22: ; preds = %12
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %25
%27 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = call i32 @strcasecmp(i8* %23, i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %22
store i32 0, i32* %2
br label %74
32: ; preds = %22
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %5
37: ; preds = %5
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %3
%40 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %39)
store i32 0, i32* %4
br label %41
41: ; preds = %70, %37
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %43
%45 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %44, i32 0, i32 0
%46 = load i8*, i8** %45
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %73
48: ; preds = %41
%49 = load i32, i32* @stderr
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %51
%53 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %52, i32 0, i32 0
%54 = load i8*, i8** %53
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %56
%58 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %57, i32 0, i32 1
%59 = load i8*, i8** %58
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [5 x %struct._bool_table], [5 x %struct._bool_table]* @get_boolean.bool_table, i64 0, i64 %62
%64 = getelementptr inbounds %struct._bool_table, %struct._bool_table* %63, i32 0, i32 1
%65 = load i8*, i8** %64
%66 = icmp ne i8* %65, null
%67 = zext i1 %66 to i64
%68 = select i1 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0)
%69 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %54, i8* %59, i8* %68)
br label %70
70: ; preds = %48
%71 = load i32, i32* %4
%72 = add nsw i32 %71, 1
store i32 %72, i32* %4
br label %41
73: ; preds = %41
store i32 -1, i32* %2
br label %74
74: ; preds = %73, %31, %21
%75 = load i32, i32* %2
ret i32 %75
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [5 x i8] c"true\00"
@.str.5 = [6 x i8] c"false\00"
@.str.6 = [4 x i8] c"yes\00"
@.str.7 = [3 x i8] c"no\00"
@stderr = global i32 0
@.str.8 = [31 x i8] c"\22%s\22 is not a boolean value: <\00"
@.str.9 = [8 x i8] c"%s|%s%s\00"
@.str.10 = [2 x i8] c"|\00"
@.str.11 = [3 x i8] c">\0A\00"
define i32 @get_boolean(i8* %0) {
%2 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %36, label %33
4: ; preds = %33
%5 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %36, label %7
7: ; preds = %4
%8 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %36, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %36, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %36, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %36, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %36
33: ; preds = %1
%34 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %4
36: ; preds = %33, %1, %4, %7, %10, %13, %16, %19, %22
%37 = phi i32 [ -1, %22 ], [ 1, %1 ], [ 0, %33 ], [ 1, %4 ], [ 0, %7 ], [ 1, %10 ], [ 0, %13 ], [ 1, %16 ], [ 0, %19 ]
ret i32 %37
}