#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__ atoi(char *);
int /*<<< orphan*/ strcasecmp(char *, char *);
int /*<<< orphan*/ strcspn(char *, char *);
int _cfg_read_bool(char **buf, int *val) {
  char *ptr;
  ptr = *buf;
  *buf += strcspn(*buf, " \t\r\n");
  *((*buf)++) = 0;
  if (!strcasecmp(ptr, "yes")) {
    *val = 1;
  } else if (!strcasecmp(ptr, "true")) {
    *val = 1;
  } else if (!strcasecmp(ptr, "y")) {
    *val = 1;
  } else if (!strcasecmp(ptr, "t")) {
    *val = 1;
  } else if (!strcasecmp(ptr, "no")) {
    *val = 0;
  } else if (!strcasecmp(ptr, "false")) {
    *val = 0;
  } else if (!strcasecmp(ptr, "n")) {
    *val = 0;
  } else if (!strcasecmp(ptr, "f")) {
    *val = 0;
  } else {
    *val = (atoi(ptr) ? 1 : 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<_cfg_read_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11ac <_cfg_read_bool+0x7c>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1307 <_cfg_read_bool+0x1d7>
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11d4 <_cfg_read_bool+0xa4>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1302 <_cfg_read_bool+0x1d2>
mov    -0x18(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11fc <_cfg_read_bool+0xcc>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    12fd <_cfg_read_bool+0x1cd>
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1224 <_cfg_read_bool+0xf4>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    12f8 <_cfg_read_bool+0x1c8>
mov    -0x18(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    124c <_cfg_read_bool+0x11c>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    12f3 <_cfg_read_bool+0x1c3>
mov    -0x18(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1274 <_cfg_read_bool+0x144>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    12ee <_cfg_read_bool+0x1be>
mov    -0x18(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    129c <_cfg_read_bool+0x16c>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    12e9 <_cfg_read_bool+0x1b9>
mov    -0x18(%rbp),%rdi
lea    0xd76(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    12c4 <_cfg_read_bool+0x194>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    12e4 <_cfg_read_bool+0x1b4>
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,%rdx
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    $0x0,%rdx
cmovne %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    12e9 <_cfg_read_bool+0x1b9>
jmp    12ee <_cfg_read_bool+0x1be>
jmp    12f3 <_cfg_read_bool+0x1c3>
jmp    12f8 <_cfg_read_bool+0x1c8>
jmp    12fd <_cfg_read_bool+0x1cd>
jmp    1302 <_cfg_read_bool+0x1d2>
jmp    1307 <_cfg_read_bool+0x1d7>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cfg_read_bool>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%r15
lea    0xebb(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcspn@plt>
cltq
lea    (%r15,%rax,1),%rcx
add    $0x1,%rcx
mov    %rcx,(%rbx)
movb   $0x0,(%r15,%rax,1)
lea    0xe9f(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe87(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe75(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe64(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe53(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe41(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe34(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
lea    0xe23(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1216 <_cfg_read_bool+0xe6>
mov    %r15,%rdi
call   1050 <atoi@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %ebx,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"t\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [6 x i8] c"false\00"
@.str.7 = [2 x i8] c"n\00"
@.str.8 = [2 x i8] c"f\00"
define i32 @_cfg_read_bool(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i8*
store i8** %0, i8*** %3
store i32* %1, i32** %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
store i8* %7, i8** %5
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
%10 = call i32 @strcspn(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %11
%15 = load i8**, i8*** %3
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %15
store i8 0, i8* %16
%18 = load i8*, i8** %5
%19 = call i32 @strcasecmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %2
%22 = load i32*, i32** %4
store i32 1, i32* %22
br label %79
23: ; preds = %2
%24 = load i8*, i8** %5
%25 = call i32 @strcasecmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = load i32*, i32** %4
store i32 1, i32* %28
br label %78
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32 @strcasecmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = load i32*, i32** %4
store i32 1, i32* %34
br label %77
35: ; preds = %29
%36 = load i8*, i8** %5
%37 = call i32 @strcasecmp(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = load i32*, i32** %4
store i32 1, i32* %40
br label %76
41: ; preds = %35
%42 = load i8*, i8** %5
%43 = call i32 @strcasecmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = load i32*, i32** %4
store i32 0, i32* %46
br label %75
47: ; preds = %41
%48 = load i8*, i8** %5
%49 = call i32 @strcasecmp(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp ne i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %47
%52 = load i32*, i32** %4
store i32 0, i32* %52
br label %74
53: ; preds = %47
%54 = load i8*, i8** %5
%55 = call i32 @strcasecmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = load i32*, i32** %4
store i32 0, i32* %58
br label %73
59: ; preds = %53
%60 = load i8*, i8** %5
%61 = call i32 @strcasecmp(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = load i32*, i32** %4
store i32 0, i32* %64
br label %72
65: ; preds = %59
%66 = load i8*, i8** %5
%67 = call i64 @atoi(i8* %66)
%68 = icmp ne i64 %67, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i32 1, i32 0
%71 = load i32*, i32** %4
store i32 %70, i32* %71
br label %72
72: ; preds = %65, %63
br label %73
73: ; preds = %72, %57
br label %74
74: ; preds = %73, %51
br label %75
75: ; preds = %74, %45
br label %76
76: ; preds = %75, %39
br label %77
77: ; preds = %76, %33
br label %78
78: ; preds = %77, %27
br label %79
79: ; preds = %78, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"t\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [6 x i8] c"false\00"
@.str.7 = [2 x i8] c"n\00"
@.str.8 = [2 x i8] c"f\00"
define i32 @_cfg_read_bool(i8** nocapture %0, i32* nocapture writeonly %1) {
%3 = load i8*, i8** %0
%4 = tail call i32 @strcspn(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %3, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %7, i8** %0
store i8 0, i8* %6
%8 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %35, label %10
10: ; preds = %2
%11 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %35, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %35, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %35, label %22
22: ; preds = %19
%23 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %22
%26 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %25
%29 = tail call i32 @strcasecmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = tail call i64 @atoi(i8* %3)
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %28, %25, %22, %19, %16, %13, %10, %2, %31
%36 = phi i32 [ %34, %31 ], [ 1, %2 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ 0, %19 ], [ 0, %22 ], [ 0, %25 ], [ 0, %28 ]
store i32 %36, i32* %1
ret i32 0
}