#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*/ strupr(char *);
int parse_boolean(char *token) {
  if (token == NULL)
    return +1;
  strupr(token);
  switch (token[0]) {
  case 'O':
    if (token[1] == 'N')
      return +1;
    else if (token[1] == 'F')
      return -1;
    else
      return 0;
  case 'T':
  case 'Y':
  case 'E':
  case '1':
    return +1;
  case 'F':
  case 'N':
  case 'D':
  case '0':
    return -1;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<parse_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <parse_boolean+0x23>
movl   $0x1,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
mov    -0x10(%rbp),%rdi
call   1030 <strupr@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x30,%eax
je     122e <parse_boolean+0x11e>
jmp    1154 <parse_boolean+0x44>
mov    -0x14(%rbp),%eax
sub    $0x31,%eax
je     1222 <parse_boolean+0x112>
jmp    1165 <parse_boolean+0x55>
mov    -0x14(%rbp),%eax
sub    $0x44,%eax
je     122e <parse_boolean+0x11e>
jmp    1176 <parse_boolean+0x66>
mov    -0x14(%rbp),%eax
sub    $0x45,%eax
je     1222 <parse_boolean+0x112>
jmp    1187 <parse_boolean+0x77>
mov    -0x14(%rbp),%eax
sub    $0x46,%eax
je     122e <parse_boolean+0x11e>
jmp    1198 <parse_boolean+0x88>
mov    -0x14(%rbp),%eax
sub    $0x4e,%eax
je     122e <parse_boolean+0x11e>
jmp    11a9 <parse_boolean+0x99>
mov    -0x14(%rbp),%eax
sub    $0x4f,%eax
je     11dc <parse_boolean+0xcc>
jmp    11ba <parse_boolean+0xaa>
mov    -0x14(%rbp),%eax
sub    $0x54,%eax
je     1222 <parse_boolean+0x112>
jmp    11cb <parse_boolean+0xbb>
mov    -0x14(%rbp),%eax
sub    $0x59,%eax
je     1222 <parse_boolean+0x112>
jmp    123a <parse_boolean+0x12a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x4e,%eax
jne    11f9 <parse_boolean+0xe9>
movl   $0x1,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x46,%eax
jne    1216 <parse_boolean+0x106>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
movl   $0x0,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
movl   $0x1,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <parse_boolean+0x131>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_boolean>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
test   %rdi,%rdi
je     1172 <parse_boolean+0x62>
mov    %rdi,%rbx
call   1030 <strupr@plt>
movsbl (%rbx),%eax
add    $0xffffffd0,%eax
cmp    $0x29,%eax
ja     1170 <parse_boolean+0x60>
mov    $0x40500001,%ecx
bt     %rax,%rcx
jb     1169 <parse_boolean+0x59>
movabs $0x21000200002,%rcx
bt     %rax,%rcx
jb     1172 <parse_boolean+0x62>
cmp    $0x1f,%rax
jne    1170 <parse_boolean+0x60>
mov    0x1(%rbx),%al
xor    %ecx,%ecx
cmp    $0x46,%al
sete   %cl
neg    %ecx
cmp    $0x4e,%al
mov    $0x1,%ebp
cmovne %ecx,%ebp
jmp    1172 <parse_boolean+0x62>
mov    $0xffffffff,%ebp
jmp    1172 <parse_boolean+0x62>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_boolean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %32
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strupr(i8* %8)
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %31 [
i32 79, label %14
i32 84, label %29
i32 89, label %29
i32 69, label %29
i32 49, label %29
i32 70, label %30
i32 78, label %30
i32 68, label %30
i32 48, label %30
]
14: ; preds = %7
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 78
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 1, i32* %2
br label %32
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 70
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 -1, i32* %2
br label %32
28: ; preds = %21
store i32 0, i32* %2
br label %32
29: ; preds = %7, %7, %7, %7
store i32 1, i32* %2
br label %32
30: ; preds = %7, %7, %7, %7
store i32 -1, i32* %2
br label %32
31: ; preds = %7
store i32 0, i32* %2
br label %32
32: ; preds = %31, %30, %29, %28, %27, %20, %6
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @parse_boolean(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i32 @strupr(i8* %0)
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
switch i32 %6, label %15 [
i32 79, label %7
i32 84, label %16
i32 89, label %16
i32 69, label %16
i32 49, label %16
i32 70, label %14
i32 78, label %14
i32 68, label %14
i32 48, label %14
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 70
%11 = sext i1 %10 to i32
%12 = icmp eq i8 %9, 78
%13 = select i1 %12, i32 1, i32 %11
br label %16
14: ; preds = %3, %3, %3, %3
br label %16
15: ; preds = %3
br label %16
16: ; preds = %7, %3, %3, %3, %3, %1, %15, %14
%17 = phi i32 [ 0, %15 ], [ -1, %14 ], [ 1, %1 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ 1, %3 ], [ %13, %7 ]
ret i32 %17
}