#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__ strncasecmp(char const *, char *, int);
scalar_t__ strncmp(char const *, char *, int);
int ngf_proplist_parse_boolean(const char *value, int *boolean_value) {
  if (value == NULL || boolean_value == NULL)
    return 0;
  if (strncmp(value, "1", 1) == 0 || strncasecmp(value, "true", 4) == 0) {
    *boolean_value = 1;
    return 1;
  } else if (strncmp(value, "0", 1) == 0 ||
             strncasecmp(value, "false", 5) == 0) {
    *boolean_value = 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ngf_proplist_parse_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <ngf_proplist_parse_boolean+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <ngf_proplist_parse_boolean+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1206 <ngf_proplist_parse_boolean+0xe6>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1190 <ngf_proplist_parse_boolean+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11a6 <ngf_proplist_parse_boolean+0x86>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1206 <ngf_proplist_parse_boolean+0xe6>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11e4 <ngf_proplist_parse_boolean+0xc4>
mov    -0x10(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11fa <ngf_proplist_parse_boolean+0xda>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1206 <ngf_proplist_parse_boolean+0xe6>
jmp    11ff <ngf_proplist_parse_boolean+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ngf_proplist_parse_boolean>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     11aa <ngf_proplist_parse_boolean+0x8a>
mov    %rsi,%r14
test   %rsi,%rsi
je     11aa <ngf_proplist_parse_boolean+0x8a>
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
mov    $0x1,%ebp
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a2 <ngf_proplist_parse_boolean+0x82>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     11a2 <ngf_proplist_parse_boolean+0x82>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a0 <ngf_proplist_parse_boolean+0x80>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11aa <ngf_proplist_parse_boolean+0x8a>
jmp    11a2 <ngf_proplist_parse_boolean+0x82>
xor    %ebp,%ebp
mov    %ebp,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [6 x i8] c"false\00"
define i32 @ngf_proplist_parse_boolean(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 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i32 0, i32* %3
br label %34
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i64 @strncasecmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16, %12
%21 = load i32*, i32** %5
store i32 1, i32* %21
store i32 1, i32* %3
br label %34
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = call i64 @strncasecmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26, %22
%31 = load i32*, i32** %5
store i32 0, i32* %31
store i32 1, i32* %3
br label %34
32: ; preds = %26
br label %33
33: ; preds = %32
store i32 0, i32* %3
br label %34
34: ; preds = %33, %30, %20, %11
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [6 x i8] c"false\00"
define i32 @ngf_proplist_parse_boolean(i8* %0, i32* writeonly %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i32* %1, null
%5 = or i1 %3, %4
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12, %15, %6, %9
%19 = phi i32 [ 1, %9 ], [ 1, %6 ], [ 0, %15 ], [ 0, %12 ]
store i32 %19, i32* %1
br label %20
20: ; preds = %18, %15, %2
%21 = phi i32 [ 0, %2 ], [ 0, %15 ], [ 1, %18 ]
ret i32 %21
}