#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*/ cBuffer;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncpyz(char *, char *, int);
int /*<<< orphan*/ strtrim(char *, int);
int isBoolean(char *pcSrc, int *pbValue) {
  char cBuffer[4096];
  if (pcSrc && *pcSrc) {
    strncpyz(cBuffer, pcSrc, sizeof(cBuffer) - 1);
    strtrim(cBuffer, (3 | 64));
    if (!strcmp(cBuffer, "true")) {
      if (pbValue) {
        *pbValue = 1;
      }
      return 1;
    }
    if (!strcmp(cBuffer, "false")) {
      if (pbValue) {
        *pbValue = 0;
      }
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<isBoolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1203 <isBoolean+0xd3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1203 <isBoolean+0xd3>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xfff,%edx
call   1030 <strncpyz@plt>
lea    -0x1020(%rbp),%rdi
mov    $0x43,%esi
call   1050 <strtrim@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <isBoolean+0x91>
cmpq   $0x0,-0x18(%rbp)
je     11b5 <isBoolean+0x85>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120a <isBoolean+0xda>
lea    -0x1020(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fe <isBoolean+0xce>
cmpq   $0x0,-0x18(%rbp)
je     11f2 <isBoolean+0xc2>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120a <isBoolean+0xda>
jmp    1203 <isBoolean+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBoolean>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     119b <isBoolean+0x7b>
mov    %rsi,%r14
mov    %rdi,%rsi
cmpb   $0x0,(%rdi)
je     119b <isBoolean+0x7b>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xfff,%edx
call   1030 <strncpyz@plt>
mov    %r15,%rdi
mov    $0x43,%esi
call   1040 <strtrim@plt>
mov    $0x65757274,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     1189 <isBoolean+0x69>
mov    $0x736c6166,%eax
xor    (%rsp),%eax
movzwl 0x4(%rsp),%ecx
xor    $0x65,%ecx
or     %eax,%ecx
jne    119b <isBoolean+0x7b>
xor    %ebx,%ebx
test   %r14,%r14
jne    1193 <isBoolean+0x73>
jmp    1196 <isBoolean+0x76>
mov    $0x1,%ebx
test   %r14,%r14
je     119b <isBoolean+0x7b>
mov    %ebx,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
define i32 @isBoolean(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [4096 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %40
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %40
14: ; preds = %9
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = call i32 @strncpyz(i8* %15, i8* %16, i32 4095)
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%19 = call i32 @strtrim(i8* %18, i32 67)
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %14
%24 = load i32*, i32** %5
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32*, i32** %5
store i32 1, i32* %27
br label %28
28: ; preds = %26, %23
store i32 1, i32* %3
br label %41
29: ; preds = %14
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %29
%34 = load i32*, i32** %5
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = load i32*, i32** %5
store i32 0, i32* %37
br label %38
38: ; preds = %36, %33
store i32 1, i32* %3
br label %41
39: ; preds = %29
br label %40
40: ; preds = %39, %9, %2
store i32 0, i32* %3
br label %41
41: ; preds = %40, %38, %28
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
define i32 @isBoolean(i8* %0, i32* writeonly %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %0, null
br i1 %5, label %23, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %6
%10 = call i32 @strncpyz(i8* %4, i8* %0, i32 4095)
%11 = call i32 @strtrim(i8* %4, i32 67)
%12 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = icmp eq i32* %1, null
br i1 %15, label %23, label %21
16: ; preds = %9
%17 = call i32 @bcmp(i8* dereferenceable(6) %4, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 6)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = icmp eq i32* %1, null
br i1 %20, label %23, label %21
21: ; preds = %19, %14
%22 = phi i32 [ 1, %14 ], [ 0, %19 ]
store i32 %22, i32* %1
br label %23
23: ; preds = %21, %2, %6, %16, %19, %14
%24 = phi i32 [ 1, %14 ], [ 1, %19 ], [ 0, %16 ], [ 0, %6 ], [ 0, %2 ], [ 1, %21 ]
ret i32 %24
}