#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 sscanf(char const *, char *, int *);
int /*<<< orphan*/ strcasecmp(char const *, char *);
int isAffirmative(const char *value) {
  int n;
  if (!strcasecmp(value, "on"))
    return 1;
  if (!strcasecmp(value, "yes"))
    return 1;
  if (!strcasecmp(value, "true"))
    return 1;
  if (!strcasecmp(value, "enabled"))
    return 1;
  if (sscanf(value, "%d", &n) == 1) {
    if (n != 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isAffirmative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1151 <isAffirmative+0x31>
movl   $0x1,-0x4(%rbp)
jmp    11ff <isAffirmative+0xdf>
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1176 <isAffirmative+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11ff <isAffirmative+0xdf>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    119b <isAffirmative+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    11ff <isAffirmative+0xdf>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11c0 <isAffirmative+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11ff <isAffirmative+0xdf>
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11f8 <isAffirmative+0xd8>
cmpl   $0x0,-0x14(%rbp)
je     11f3 <isAffirmative+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    11ff <isAffirmative+0xdf>
jmp    11f8 <isAffirmative+0xd8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAffirmative>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     119b <isAffirmative+0x7b>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     119b <isAffirmative+0x7b>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     119b <isAffirmative+0x7b>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     119b <isAffirmative+0x7b>
lea    0xe99(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
sete   %al
cmpl   $0x0,0x4(%rsp)
setne  %cl
and    %al,%cl
movzbl %cl,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [8 x i8] c"enabled\00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @isAffirmative(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %1
%7 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %6
%10 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%17 = icmp eq i32 %16, 1
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
%20 = select i1 %17, i1 %19, i1 false
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %15, %12, %9, %6, %1
%23 = phi i32 [ 1, %1 ], [ 1, %6 ], [ 1, %9 ], [ 1, %12 ], [ %21, %15 ]
ret i32 %23
}