#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
bool getbool(char *from) {
  struct valmap {
    char *name;
    bool val;
  } boolnames[] =
      {
          {"yes", true}, {"on", true},  {"1", true},
          {"t", true},   {"no", false}, {"off", false},
          {"0", false},  {"f", false},  {NULL, false},
      },
    *sp;
  for (sp = boolnames; sp->name; sp++)
    if (strcmp(sp->name, from) == 0)
      return sp->val;
  (void)fprintf(stderr, "giftool: %s is not a valid boolean argument.\n",
                sp->name);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<getbool>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0x2c23(%rip),%rsi
mov    $0x90,%edx
call   1050 <memcpy@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d2 <getbool+0x92>
mov    -0xa8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b6 <getbool+0x76>
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%eax
add    $0xb0,%rsp
pop    %rbp
ret
jmp    11bb <getbool+0x7b>
mov    -0xa8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0xa8(%rbp)
jmp    1175 <getbool+0x35>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe28(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<getbool>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
lea    0x2c2c(%rip),%rsi
mov    %rsp,%rdi
mov    $0x90,%edx
call   1050 <memcpy@plt>
lea    0x10(%rsp),%rbx
lea    0xe93(%rip),%rdi
nopl   (%rax)
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ae <getbool+0x6e>
mov    (%rbx),%rdi
add    $0x10,%rbx
test   %rdi,%rdi
jne    1170 <getbool+0x30>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
xor    %edx,%edx
call   1040 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbx),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.valmap = type { i8*, i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"t\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [2 x i8] c"0\00"
@.str.7 = [2 x i8] c"f\00"
@__const.getbool.boolnames = [9 x %struct.valmap] [%struct.valmap { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i32 0 }, %struct.valmap zeroinitializer]
@stderr = global i32 0
@.str.8 = [46 x i8] c"giftool: %s is not a valid boolean argument.\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @getbool(i8* %0) {
%2 = alloca i8*
%3 = alloca [9 x %struct.valmap]
%4 = alloca %struct.valmap*
store i8* %0, i8** %2
%5 = bitcast [9 x %struct.valmap]* %3 to i8*
%6 = getelementptr inbounds [9 x %struct.valmap], [9 x %struct.valmap]* %3, i64 0, i64 0
store %struct.valmap* %6, %struct.valmap** %4
br label %7
7: ; preds = %24, %1
%8 = load %struct.valmap*, %struct.valmap** %4
%9 = getelementptr inbounds %struct.valmap, %struct.valmap* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %27
12: ; preds = %7
%13 = load %struct.valmap*, %struct.valmap** %4
%14 = getelementptr inbounds %struct.valmap, %struct.valmap* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = load i8*, i8** %2
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load %struct.valmap*, %struct.valmap** %4
%21 = getelementptr inbounds %struct.valmap, %struct.valmap* %20, i32 0, i32 1
%22 = load i32, i32* %21
ret i32 %22
23: ; preds = %12
br label %24
24: ; preds = %23
%25 = load %struct.valmap*, %struct.valmap** %4
%26 = getelementptr inbounds %struct.valmap, %struct.valmap* %25, i32 1
store %struct.valmap* %26, %struct.valmap** %4
br label %7
27: ; preds = %7
%28 = load i32, i32* @stderr
%29 = load %struct.valmap*, %struct.valmap** %4
%30 = getelementptr inbounds %struct.valmap, %struct.valmap* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
}

LLVM IR (-O2):
%struct.valmap = type { i8*, i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"t\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [2 x i8] c"0\00"
@.str.7 = [2 x i8] c"f\00"
@__const.getbool.boolnames = [9 x %struct.valmap] [%struct.valmap { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i32 1 }, %struct.valmap { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i32 0 }, %struct.valmap { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i32 0 }, %struct.valmap zeroinitializer]
@stderr = global i32 0
@.str.8 = [46 x i8] c"giftool: %s is not a valid boolean argument.\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @getbool(i8* %0) {
%2 = alloca [9 x %struct.valmap]
%3 = bitcast [9 x %struct.valmap]* %2 to i8*
%4 = getelementptr inbounds [9 x %struct.valmap], [9 x %struct.valmap]* %2, i64 0, i64 0
br label %5
5: ; preds = %1, %13
%6 = phi i8* [ %16, %13 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ]
%7 = phi %struct.valmap* [ %14, %13 ], [ %4, %1 ]
%8 = tail call i64 @strcmp(i8* %6, i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = getelementptr inbounds %struct.valmap, %struct.valmap* %7, i64 0, i32 1
%12 = load i32, i32* %11
ret i32 %12
13: ; preds = %5
%14 = getelementptr inbounds %struct.valmap, %struct.valmap* %7, i64 1
%15 = getelementptr inbounds %struct.valmap, %struct.valmap* %14, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %5
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i8* null)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
}