#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 */
char *findStringCfgValue(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ stricmp(char *, char *);
int GetBoolCfgFlag(char *str, long *flagfield, long flag) {
  char *valstr;
  int boolvalue;
  if ((valstr = findStringCfgValue(str)) == NULL) {
    return 0;
  }
  if (stricmp(valstr, "YES") == 0 || stricmp(valstr, "JA") == 0) {
    boolvalue = 1;
  } else if (stricmp(valstr, "NO") == 0 || stricmp(valstr, "NEJ") == 0) {
    boolvalue = 0;
  } else {
    printf("Invalid config line, invalid boolean value: %s\n", str);
    return 0;
  }
  if (boolvalue) {
    *flagfield |= flag;
  } else {
    *flagfield &= ~flag;
  }
  return 1;
}


x86 assembly (clang, -O0):
<GetBoolCfgFlag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <findStringCfgValue@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1167 <GetBoolCfgFlag+0x37>
movl   $0x0,-0x4(%rbp)
jmp    123e <GetBoolCfgFlag+0x10e>
mov    -0x28(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
je     119b <GetBoolCfgFlag+0x6b>
mov    -0x28(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
jne    11a7 <GetBoolCfgFlag+0x77>
movl   $0x1,-0x2c(%rbp)
jmp    1208 <GetBoolCfgFlag+0xd8>
mov    -0x28(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
je     11db <GetBoolCfgFlag+0xab>
mov    -0x28(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
jne    11e7 <GetBoolCfgFlag+0xb7>
movl   $0x0,-0x2c(%rbp)
jmp    1203 <GetBoolCfgFlag+0xd3>
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <GetBoolCfgFlag+0x10e>
jmp    1208 <GetBoolCfgFlag+0xd8>
cmpl   $0x0,-0x2c(%rbp)
je     1225 <GetBoolCfgFlag+0xf5>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
jmp    1237 <GetBoolCfgFlag+0x107>
mov    -0x20(%rbp),%rcx
xor    $0xffffffffffffffff,%rcx
mov    -0x18(%rbp),%rax
and    (%rax),%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetBoolCfgFlag>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <findStringCfgValue@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     11c6 <GetBoolCfgFlag+0x96>
mov    %rax,%rbp
lea    0xea8(%rip),%rsi
mov    %rax,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11b2 <GetBoolCfgFlag+0x82>
lea    0xe98(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11b2 <GetBoolCfgFlag+0x82>
lea    0xe87(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11b7 <GetBoolCfgFlag+0x87>
lea    0xe76(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11b7 <GetBoolCfgFlag+0x87>
lea    0xe66(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
jmp    11c6 <GetBoolCfgFlag+0x96>
or     (%r14),%rbx
jmp    11bd <GetBoolCfgFlag+0x8d>
not    %rbx
and    (%r14),%rbx
mov    %rbx,(%r14)
mov    $0x1,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"YES\00"
@.str.1 = [3 x i8] c"JA\00"
@.str.2 = [3 x i8] c"NO\00"
@.str.3 = [4 x i8] c"NEJ\00"
@.str.4 = [48 x i8] c"Invalid config line, invalid boolean value: %s\0A\00"
define i32 @GetBoolCfgFlag(i8* %0, i64* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64 %2, i64* %7
%10 = load i8*, i8** %5
%11 = call i8* @findStringCfgValue(i8* %10)
store i8* %11, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %51
14: ; preds = %3
%15 = load i8*, i8** %8
%16 = call i64 @stricmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8*, i8** %8
%20 = call i64 @stricmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %14
store i32 1, i32* %9
br label %36
23: ; preds = %18
%24 = load i8*, i8** %8
%25 = call i64 @stricmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8*, i8** %8
%29 = call i64 @stricmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27, %23
store i32 0, i32* %9
br label %35
32: ; preds = %27
%33 = load i8*, i8** %5
%34 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %33)
store i32 0, i32* %4
br label %51
35: ; preds = %31
br label %36
36: ; preds = %35, %22
%37 = load i32, i32* %9
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i64, i64* %7
%41 = load i64*, i64** %6
%42 = load i64, i64* %41
%43 = or i64 %42, %40
store i64 %43, i64* %41
br label %50
44: ; preds = %36
%45 = load i64, i64* %7
%46 = xor i64 %45, -1
%47 = load i64*, i64** %6
%48 = load i64, i64* %47
%49 = and i64 %48, %46
store i64 %49, i64* %47
br label %50
50: ; preds = %44, %39
store i32 1, i32* %4
br label %51
51: ; preds = %50, %32, %13
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [4 x i8] c"YES\00"
@.str.1 = [3 x i8] c"JA\00"
@.str.2 = [3 x i8] c"NO\00"
@.str.3 = [4 x i8] c"NEJ\00"
@.str.4 = [48 x i8] c"Invalid config line, invalid boolean value: %s\0A\00"
define i32 @GetBoolCfgFlag(i8* %0, i64* nocapture %1, i64 %2) {
%4 = tail call i8* @findStringCfgValue(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %29, label %6
6: ; preds = %3
%7 = tail call i64 @stricmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = tail call i64 @stricmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = tail call i64 @stricmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = tail call i64 @stricmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %29
20: ; preds = %6, %9
%21 = load i64, i64* %1
%22 = or i64 %21, %2
br label %27
23: ; preds = %15, %12
%24 = xor i64 %2, -1
%25 = load i64, i64* %1
%26 = and i64 %25, %24
br label %27
27: ; preds = %23, %20
%28 = phi i64 [ %26, %23 ], [ %22, %20 ]
store i64 %28, i64* %1
br label %29
29: ; preds = %3, %27, %18
%30 = phi i32 [ 1, %27 ], [ 0, %18 ], [ 0, %3 ]
ret i32 %30
}