#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int int8_t;

/* Variables and functions */
scalar_t__ strcasecmp(int /*<<< orphan*/ *, char *);
int8_t parse_bool(uint8_t *text, void *buf) {
  if (strcasecmp(text, "TRUE") == 0) {
    *(uint32_t *)buf = 1;
    return 0;
  } else if (strcasecmp(text, "FALSE") == 0) {
    *(uint32_t *)buf = 0;
    return 0;
  } else {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1150 <parse_bool+0x40>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1187 <parse_bool+0x77>
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1180 <parse_bool+0x70>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1187 <parse_bool+0x77>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_bool>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     114b <parse_bool+0x3b>
lea    0xed3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1155 <parse_bool+0x45>
xor    %eax,%eax
jmp    1150 <parse_bool+0x40>
mov    $0x1,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"TRUE\00"
@.str.1 = [6 x i8] c"FALSE\00"
define i32 @parse_bool(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i32*, i32** %4
%7 = call i64 @strcasecmp(i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i32*
store i32 1, i32* %11
store i32 0, i32* %3
br label %20
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = call i64 @strcasecmp(i32* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = bitcast i8* %17 to i32*
store i32 0, i32* %18
store i32 0, i32* %3
br label %20
19: ; preds = %12
store i32 -1, i32* %3
br label %20
20: ; preds = %19, %16, %9
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [5 x i8] c"TRUE\00"
@.str.1 = [6 x i8] c"FALSE\00"
define i32 @parse_bool(i32* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i64 @strcasecmp(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i64 @strcasecmp(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5, %2
%9 = phi i32 [ 1, %2 ], [ 0, %5 ]
%10 = bitcast i8* %1 to i32*
store i32 %9, i32* %10
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ -1, %5 ], [ 0, %8 ]
ret i32 %12
}