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

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
int strcspn(char *, char *);
int /*<<< orphan*/ strncpyz(char *, char *, int);
int /*<<< orphan*/ strtrim(char *, int);
int _jsonIsBoolean(char *pcSrc, char **ppcNext) {
  char cValue[16];
  int iValLen;
  iValLen = strcspn(pcSrc, ",");
  if (iValLen < sizeof(cValue)) {
    strncpyz(cValue, pcSrc, iValLen);
    strtrim(cValue, 3);
    if (!strcmp(cValue, "true") || !strcmp(cValue, "false")) {
      *ppcNext = pcSrc + iValLen;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<_jsonIsBoolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x10,%rax
jae    11e4 <_jsonIsBoolean+0xa4>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1030 <strncpyz@plt>
lea    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1060 <strtrim@plt>
lea    -0x30(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11c1 <_jsonIsBoolean+0x81>
lea    -0x30(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11df <_jsonIsBoolean+0x9f>
mov    -0x10(%rbp),%rcx
movslq -0x34(%rbp),%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11eb <_jsonIsBoolean+0xab>
jmp    11e4 <_jsonIsBoolean+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_jsonIsBoolean>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb7(%rip),%rsi
call   1040 <strcspn@plt>
xor    %r15d,%r15d
cmp    $0xf,%eax
ja     11a9 <_jsonIsBoolean+0x79>
mov    %eax,%ebp
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpyz@plt>
mov    %r12,%rdi
mov    $0x3,%esi
call   1050 <strtrim@plt>
mov    $0x65757274,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     119a <_jsonIsBoolean+0x6a>
mov    $0x736c6166,%eax
xor    (%rsp),%eax
movzwl 0x4(%rsp),%ecx
xor    $0x65,%ecx
or     %eax,%ecx
jne    11a9 <_jsonIsBoolean+0x79>
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [6 x i8] c"false\00"
define i32 @_jsonIsBoolean(i8* %0, i8** nocapture writeonly %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = icmp ult i32 %5, 16
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = call i32 @strncpyz(i8* %4, i8* %0, i32 %5)
%10 = call i32 @strtrim(i8* %4, i32 3)
%11 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = call i32 @bcmp(i8* dereferenceable(6) %4, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %8
%17 = getelementptr inbounds i8, i8* %0, i64 %6
store i8* %17, i8** %1
br label %18
18: ; preds = %2, %13, %16
%19 = phi i32 [ 1, %16 ], [ 0, %13 ], [ 0, %2 ]
ret i32 %19
}