#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__ strcasecmp(char const *, char *);
int /*<<< orphan*/ warn(char *, char const *, unsigned int);
bool boolean_value(const char *value, const char *filename, unsigned linenum,
                   int *error) {
  if (strcasecmp(value, "true") == 0)
    return true;
  else if (strcasecmp(value, "false") == 0)
    return false;
  else {
    warn("Bad boolean value at %s:%d", filename, linenum);
    *error = -1;
  }
  return false;
}


x86 assembly (clang, -O0):
<boolean_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    115d <boolean_value+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    11ac <boolean_value+0x8c>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1183 <boolean_value+0x63>
movl   $0x0,-0x4(%rbp)
jmp    11ac <boolean_value+0x8c>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe7a(%rip),%rdi
call   1040 <warn@plt>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    11a5 <boolean_value+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boolean_value>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xec6(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1175 <boolean_value+0x55>
lea    0xeba(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     117a <boolean_value+0x5a>
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <warn@plt>
movl   $0xffffffff,(%r14)
jmp    117a <boolean_value+0x5a>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
@.str.2 = [27 x i8] c"Bad boolean value at %s:%d\00"
define i32 @boolean_value(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%10 = load i8*, i8** %6
%11 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 1, i32* %5
br label %26
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %5
br label %26
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32 %21)
%23 = load i32*, i32** %9
store i32 -1, i32* %23
br label %24
24: ; preds = %19
br label %25
25: ; preds = %24
store i32 0, i32* %5
br label %26
26: ; preds = %25, %18, %13
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
@.str.2 = [27 x i8] c"Bad boolean value at %s:%d\00"
define i32 @boolean_value(i8* nocapture %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %12
12: ; preds = %7, %4, %10
%13 = phi i32 [ 0, %10 ], [ 1, %4 ], [ 0, %7 ]
ret i32 %13
}