#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[0] == 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     118a <csv_boolean+0x7a>
mov    -0x10(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     118a <csv_boolean+0x7a>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     118a <csv_boolean+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    1196 <csv_boolean+0x86>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1196 <csv_boolean+0x86>
movl   $0x1,-0x4(%rbp)
jmp    1218 <csv_boolean+0x108>
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1205 <csv_boolean+0xf5>
mov    -0x10(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1205 <csv_boolean+0xf5>
mov    -0x10(%rbp),%rsi
lea    0xe3e(%rip),%rdi
call   1030 <sqlite3_stricmp@plt>
cmp    $0x0,%rax
je     1205 <csv_boolean+0xf5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1211 <csv_boolean+0x101>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1211 <csv_boolean+0x101>
movl   $0x0,-0x4(%rbp)
jmp    1218 <csv_boolean+0x108>
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     11a5 <csv_boolean+0x95>
lea    0xece(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11a5 <csv_boolean+0x95>
lea    0xebd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11a5 <csv_boolean+0x95>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a5 <csv_boolean+0x95>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11a5 <csv_boolean+0x95>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sqlite3_stricmp@plt>
test   %rax,%rax
je     11a5 <csv_boolean+0x95>
cmpb   $0x30,(%rbx)
jne    11a0 <csv_boolean+0x90>
cmpb   $0x0,0x1(%rbx)
je     11a5 <csv_boolean+0x95>
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 0
%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 %27, 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 %27, 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 %27, label %10
10: ; preds = %7
%11 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %10
%14 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %13
%17 = tail call i64 @sqlite3_stricmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = load i8, i8* %0
%21 = icmp eq i8 %20, 48
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %0, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22, %19
br label %27
27: ; preds = %10, %13, %16, %22, %1, %4, %7, %26
%28 = phi i32 [ -1, %26 ], [ 1, %7 ], [ 1, %4 ], [ 1, %1 ], [ 0, %22 ], [ 0, %16 ], [ 0, %13 ], [ 0, %10 ]
ret i32 %28
}