#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *get_postfix_substring(char const *, size_t *);
int /*<<< orphan*/ stderr;
scalar_t__ strstr(char *, char *);
int extract_yesno_param(const char *buff, bool *val) {
  if (buff == NULL) {
    fputs("extract_yesno_param: buff cannot be null\n", stderr);
    return -1;
  } else if (val == NULL) {
    fputs("extract_yesno_param: val cannot be null\n", stderr);
    return -1;
  }
  size_t str_len = 0;
  char *sub_str = get_postfix_substring(buff, &str_len);
  if (sub_str == NULL) {
    fputs("extract_yesno_param: failed to parse stime string\n", stderr);
    return -1;
  }
  int tristate = -1;
  if (strstr(sub_str, "yes") || strstr(sub_str, "YES")) {
    tristate = 1;
  } else if (strstr(sub_str, "no") || strstr(sub_str, "NO")) {
    tristate = 0;
  }
  if (tristate == -1) {
    fputs("extract_yesno_param: ", stderr);
    return -1;
  }
  *val = (tristate) ? true : false;
  free(sub_str);
  return 0;
}


x86 assembly (clang, -O0):
<extract_yesno_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <extract_yesno_param+0x3c>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ca <extract_yesno_param+0x18a>
cmpq   $0x0,-0x18(%rbp)
jne    11a8 <extract_yesno_param+0x68>
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe93(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ca <extract_yesno_param+0x18a>
jmp    11ad <extract_yesno_param+0x6d>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <get_postfix_substring@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f2 <extract_yesno_param+0xb2>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ca <extract_yesno_param+0x18a>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    122d <extract_yesno_param+0xed>
mov    -0x28(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1239 <extract_yesno_param+0xf9>
movl   $0x1,-0x2c(%rbp)
jmp    1279 <extract_yesno_param+0x139>
mov    -0x28(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    126d <extract_yesno_param+0x12d>
mov    -0x28(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1274 <extract_yesno_param+0x134>
movl   $0x0,-0x2c(%rbp)
jmp    1279 <extract_yesno_param+0x139>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    12a4 <extract_yesno_param+0x164>
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
lea    0xe01(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ca <extract_yesno_param+0x18a>
mov    -0x2c(%rbp),%edx
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    $0x0,%edx
cmovne %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_yesno_param>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11e1 <extract_yesno_param+0xa1>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11f3 <extract_yesno_param+0xb3>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
call   1040 <get_postfix_substring@plt>
test   %rax,%rax
je     1205 <extract_yesno_param+0xc5>
mov    %rax,%r14
lea    0xf03(%rip),%rsi
mov    %rax,%rdi
call   1060 <strstr@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11d3 <extract_yesno_param+0x93>
lea    0xeee(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11d3 <extract_yesno_param+0x93>
lea    0xede(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11d3 <extract_yesno_param+0x93>
lea    0xecb(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1228 <extract_yesno_param+0xe8>
mov    %ebp,(%rbx)
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    121f <extract_yesno_param+0xdf>
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
lea    0xe0f(%rip),%rdi
jmp    1215 <extract_yesno_param+0xd5>
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
lea    0xe27(%rip),%rdi
jmp    1215 <extract_yesno_param+0xd5>
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1050 <fputs@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
lea    0xe5c(%rip),%rdi
jmp    1215 <extract_yesno_param+0xd5>

LLVM IR (-O0):
@.str = [42 x i8] c"extract_yesno_param: buff cannot be null\0A\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"extract_yesno_param: val cannot be null\0A\00"
@.str.2 = [51 x i8] c"extract_yesno_param: failed to parse stime string\0A\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [4 x i8] c"YES\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [3 x i8] c"NO\00"
@.str.7 = [22 x i8] c"extract_yesno_param: \00"
define i32 @extract_yesno_param(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 -1, i32* %3
br label %62
14: ; preds = %2
%15 = load i32*, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %18)
store i32 -1, i32* %3
br label %62
20: ; preds = %14
br label %21
21: ; preds = %20
store i64 0, i64* %6
%22 = load i8*, i8** %4
%23 = call i8* @get_postfix_substring(i8* %22, i64* %6)
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = call i32 @fputs(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %27)
store i32 -1, i32* %3
br label %62
29: ; preds = %21
store i32 -1, i32* %8
%30 = load i8*, i8** %7
%31 = call i64 @strstr(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8*, i8** %7
%35 = call i64 @strstr(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33, %29
store i32 1, i32* %8
br label %48
38: ; preds = %33
%39 = load i8*, i8** %7
%40 = call i64 @strstr(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8*, i8** %7
%44 = call i64 @strstr(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42, %38
store i32 0, i32* %8
br label %47
47: ; preds = %46, %42
br label %48
48: ; preds = %47, %37
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %52)
store i32 -1, i32* %3
br label %62
54: ; preds = %48
%55 = load i32, i32* %8
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 1, i32 0
%59 = load i32*, i32** %5
store i32 %58, i32* %59
%60 = load i8*, i8** %7
%61 = call i32 @free(i8* %60)
store i32 0, i32* %3
br label %62
62: ; preds = %54, %51, %26, %17, %11
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [42 x i8] c"extract_yesno_param: buff cannot be null\0A\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"extract_yesno_param: val cannot be null\0A\00"
@.str.2 = [51 x i8] c"extract_yesno_param: failed to parse stime string\0A\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [4 x i8] c"YES\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [3 x i8] c"NO\00"
@.str.7 = [22 x i8] c"extract_yesno_param: \00"
define i32 @extract_yesno_param(i8* %0, i32* writeonly %1) {
%3 = alloca i64
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %40
8: ; preds = %2
%9 = icmp eq i32* %1, null
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = load i32, i32* @stderr
%12 = tail call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %40
13: ; preds = %8
%14 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%15 = call i8* @get_postfix_substring(i8* %0, i64* %3)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %38
20: ; preds = %13
%21 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %26, %29, %23, %20
%36 = phi i32 [ 1, %20 ], [ 1, %23 ], [ 0, %29 ], [ 0, %26 ]
store i32 %36, i32* %1
%37 = call i32 @free(i8* %15)
br label %38
38: ; preds = %32, %35, %17
%39 = phi i32 [ -1, %17 ], [ -1, %32 ], [ 0, %35 ]
br label %40
40: ; preds = %38, %10, %5
%41 = phi i32 [ -1, %5 ], [ -1, %10 ], [ %39, %38 ]
ret i32 %41
}