#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*/ strcasecmp(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int zstr_to_bool(char *s, int def) {
  if (!strcmp(s, "1") || !strcasecmp(s, "y") || !strcasecmp(s, "yes") ||
      !strcasecmp(s, "true"))
    return 1;
  if (!strcmp(s, "0") || !strcasecmp(s, "n") || !strcasecmp(s, "no") ||
      !strcasecmp(s, "false"))
    return 0;
  return def;
}


x86 assembly (clang, -O0):
<zstr_to_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1193 <zstr_to_bool+0x73>
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1193 <zstr_to_bool+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1193 <zstr_to_bool+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    119f <zstr_to_bool+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    1215 <zstr_to_bool+0xf5>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1203 <zstr_to_bool+0xe3>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1203 <zstr_to_bool+0xe3>
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1203 <zstr_to_bool+0xe3>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    120f <zstr_to_bool+0xef>
movl   $0x0,-0x4(%rbp)
jmp    1215 <zstr_to_bool+0xf5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zstr_to_bool>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11cf <zstr_to_bool+0xaf>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
cmove  %eax,%r14d
mov    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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