#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__ str_is_nonempty(char *);
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
bool str_is_true(char *s, bool def) {
  if (str_is_nonempty(s)) {
    if (strcmp(s, "0") == 0 || strcasecmp(s, "no") == 0) {
      return false;
    } else if (strcmp(s, "1") == 0 || strcasecmp(s, "yes") == 0) {
      return true;
    } else {
      return def;
    }
  } else {
    return def;
  }
}


x86 assembly (clang, -O0):
<str_is_true>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <str_is_nonempty@plt>
cmp    $0x0,%rax
je     11dd <str_is_true+0xad>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1186 <str_is_true+0x56>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1192 <str_is_true+0x62>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <str_is_true+0xb3>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11c6 <str_is_true+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11d2 <str_is_true+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <str_is_true+0xb3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <str_is_true+0xb3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_is_true>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1050 <str_is_nonempty@plt>
test   %rax,%rax
je     119d <str_is_true+0x6d>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a0 <str_is_true+0x70>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11a0 <str_is_true+0x70>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <str_is_true+0x77>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
mov    $0x1,%eax
cmove  %eax,%r14d
mov    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%ebp
jmp    11a0 <str_is_true+0x70>

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

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [4 x i8] c"yes\00"
define i32 @str_is_true(i8* %0, i32 %1) {
%3 = tail call i64 @str_is_nonempty(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 1, i32 %1
br label %18
18: ; preds = %14, %2, %11, %5, %8
%19 = phi i32 [ 0, %8 ], [ 0, %5 ], [ 1, %11 ], [ %1, %2 ], [ %17, %14 ]
ret i32 %19
}