#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 strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int cfg_boolean(char *s) {
  int n = strlen(s);
  if (!strncmp("ON", s, n) || !strncmp("TRUE", s, n) || !strncmp("YES", s, n) ||
      !strncmp("on", s, n) || !strncmp("true", s, n) || !strncmp("yes", s, n) ||
      !strncmp("1", s, n))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<cfg_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xeba(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xea1(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe8a(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe72(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe59(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe42(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11fc <cfg_boolean+0xdc>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe2a(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1208 <cfg_boolean+0xe8>
movl   $0x1,-0x4(%rbp)
jmp    120f <cfg_boolean+0xef>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_boolean>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x1,%r14d
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <cfg_boolean+0xb0>
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
sete   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"ON\00"
@.str.1 = [5 x i8] c"TRUE\00"
@.str.2 = [4 x i8] c"YES\00"
@.str.3 = [3 x i8] c"on\00"
@.str.4 = [5 x i8] c"true\00"
@.str.5 = [4 x i8] c"yes\00"
@.str.6 = [2 x i8] c"1\00"
define i32 @cfg_boolean(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %24, label %5
5: ; preds = %1
%6 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %5
%9 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %8
%12 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 %2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %14
%18 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %2)
%19 = icmp eq i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %2)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %20, %1, %5, %8, %11, %14, %17
%25 = phi i32 [ 1, %17 ], [ 1, %14 ], [ 1, %11 ], [ 1, %8 ], [ 1, %5 ], [ 1, %1 ], [ %23, %20 ]
ret i32 %25
}