#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 /*<<< orphan*/ strcasecmp(char const *, char *);
int strtoul(char const *, char **, int /*<<< orphan*/);
int ezd_str_tof(const char *val) {
  char *end;
  int i;
  i = strtoul(val, &end, 0);
  if (end > val)
    return !!i;
  if (!strcasecmp(val, "yes") || !strcasecmp(val, "true") ||
      !strcasecmp(val, "on"))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<ezd_str_tof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    1164 <ezd_str_tof+0x44>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <ezd_str_tof+0xa2>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11af <ezd_str_tof+0x8f>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11af <ezd_str_tof+0x8f>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11bb <ezd_str_tof+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <ezd_str_tof+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ezd_str_tof>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
cmp    %rbx,(%rsp)
jbe    113e <ezd_str_tof+0x1e>
test   %eax,%eax
setne  %bpl
jmp    117c <ezd_str_tof+0x5c>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%bpl
test   %eax,%eax
je     117c <ezd_str_tof+0x5c>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     117c <ezd_str_tof+0x5c>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
sete   %bpl
movzbl %bpl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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