#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 string_to_bool(char *str) {
  if (!strcmp(str, "y") || !strcmp(str, "yes"))
    return 1;
  if (!strcmp(str, "n") || !strcmp(str, "no"))
    return 0;
  if (!strcmp(str, "on"))
    return 1;
  if (!strcmp(str, "off"))
    return 0;
  if (!strcmp(str, "+"))
    return 1;
  if (!strcmp(str, "-"))
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<string_to_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     114e <string_to_bool+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    115a <string_to_bool+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     118c <string_to_bool+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1198 <string_to_bool+0x88>
movl   $0x0,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11bd <string_to_bool+0xad>
movl   $0x1,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11e2 <string_to_bool+0xd2>
movl   $0x0,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
mov    -0x10(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1207 <string_to_bool+0xf7>
movl   $0x1,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
mov    -0x10(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    122c <string_to_bool+0x11c>
movl   $0x0,-0x4(%rbp)
jmp    1233 <string_to_bool+0x123>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_to_bool>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b8 <string_to_bool+0xa8>
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b8 <string_to_bool+0xa8>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11bd <string_to_bool+0xad>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bd <string_to_bool+0xad>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b8 <string_to_bool+0xa8>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bd <string_to_bool+0xad>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11bd <string_to_bool+0xad>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
neg    %eax
sbb    %ebp,%ebp
jmp    11bd <string_to_bool+0xad>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"y\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [2 x i8] c"n\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [3 x i8] c"on\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [2 x i8] c"+\00"
@.str.7 = [2 x i8] c"-\00"
define i32 @string_to_bool(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
%25 = sext i1 %24 to i32
br label %26
26: ; preds = %22, %19, %16, %13, %7, %10, %1, %4
%27 = phi i32 [ 1, %4 ], [ 1, %1 ], [ 0, %10 ], [ 0, %7 ], [ 1, %13 ], [ 0, %16 ], [ 1, %19 ], [ %25, %22 ]
ret i32 %27
}