#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 */
scalar_t__ sqlite3_stricmp(char *, char const *);
int csv_boolean(const char *z) {
  if (sqlite3_stricmp("yes", z) == 0 || sqlite3_stricmp("on", z) == 0 ||
      sqlite3_stricmp("true", z) == 0 || (z[0] == '1' && z[1] == 0)) {
    return 1;
  }
  if (sqlite3_stricmp("no", z) == 0 || sqlite3_stricmp("off", z) == 0 ||
      sqlite3_stricmp("false", z) == 0 || (z[0] == '0' && z[1] == 0)) {
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<csv_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     118b <csv_boolean+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     118b <csv_boolean+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     118b <csv_boolean+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    1197 <csv_boolean+0x87>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1197 <csv_boolean+0x87>
movl   $0x1,-0x4(%rbp)
jmp    1219 <csv_boolean+0x109>
mov    -0x10(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1206 <csv_boolean+0xf6>
mov    -0x10(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1206 <csv_boolean+0xf6>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1206 <csv_boolean+0xf6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1212 <csv_boolean+0x102>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1212 <csv_boolean+0x102>
movl   $0x0,-0x4(%rbp)
jmp    1219 <csv_boolean+0x109>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csv_boolean>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
lea    0xeca(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
cmpb   $0x31,(%rbx)
jne    1166 <csv_boolean+0x56>
cmpb   $0x0,0x1(%rbx)
je     11b4 <csv_boolean+0xa4>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11b4 <csv_boolean+0xa4>
cmpb   $0x30,(%rbx)
jne    11af <csv_boolean+0x9f>
cmpb   $0x0,0x1(%rbx)
je     11b4 <csv_boolean+0xa4>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [4 x i8] c"off\00"
@.str.5 = [6 x i8] c"false\00"
define i32 @csv_boolean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 49
br i1 %20, label %21, label %28
21: ; preds = %15
%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, 0
br i1 %26, label %27, label %28
27: ; preds = %21, %11, %7, %1
store i32 1, i32* %2
br label %54
28: ; preds = %21, %15
%29 = load i8*, i8** %3
%30 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %52, label %32
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %52, label %36
36: ; preds = %32
%37 = load i8*, i8** %3
%38 = call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %52, label %40
40: ; preds = %36
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 48
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %46, %36, %32, %28
store i32 0, i32* %2
br label %54
53: ; preds = %46, %40
store i32 -1, i32* %2
br label %54
54: ; preds = %53, %52, %27
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [4 x i8] c"off\00"
@.str.5 = [6 x i8] c"false\00"
define i32 @csv_boolean(i8* %0) {
%2 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %1
%5 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %34, label %7
7: ; preds = %4
%8 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %7
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 49
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %34, label %17
17: ; preds = %13, %10
%18 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %34, label %20
20: ; preds = %17
%21 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %20
%24 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %23
%27 = load i8, i8* %0
%28 = icmp eq i8 %27, 48
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = getelementptr inbounds i8, i8* %0, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29, %26
br label %34
34: ; preds = %17, %20, %23, %29, %1, %4, %7, %13, %33
%35 = phi i32 [ -1, %33 ], [ 1, %13 ], [ 1, %7 ], [ 1, %4 ], [ 1, %1 ], [ 0, %29 ], [ 0, %23 ], [ 0, %20 ], [ 0, %17 ]
ret i32 %35
}