#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 *, int, char *);
scalar_t__ stricmp(char *, char *);
int GetBoolCfgFlag(char *str, long *flagfield, long flag, int lineCnt) {
  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 %d, invalid boolean value: %s\n", lineCnt, str);
    return 0;
  }
  if (boolvalue) {
    *flagfield |= flag;
  } else {
    *flagfield &= ~flag;
  }
  return 1;
}


x86 assembly (clang, -O0):
<GetBoolCfgFlag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <FindStringCfgValue@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    116a <GetBoolCfgFlag+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1244 <GetBoolCfgFlag+0x114>
mov    -0x30(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
je     119e <GetBoolCfgFlag+0x6e>
mov    -0x30(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
jne    11aa <GetBoolCfgFlag+0x7a>
movl   $0x1,-0x34(%rbp)
jmp    120e <GetBoolCfgFlag+0xde>
mov    -0x30(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
je     11de <GetBoolCfgFlag+0xae>
mov    -0x30(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1030 <stricmp@plt>
cmp    $0x0,%rax
jne    11ea <GetBoolCfgFlag+0xba>
movl   $0x0,-0x34(%rbp)
jmp    1209 <GetBoolCfgFlag+0xd9>
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1244 <GetBoolCfgFlag+0x114>
jmp    120e <GetBoolCfgFlag+0xde>
cmpl   $0x0,-0x34(%rbp)
je     122b <GetBoolCfgFlag+0xfb>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
jmp    123d <GetBoolCfgFlag+0x10d>
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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetBoolCfgFlag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <FindStringCfgValue@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     11cf <GetBoolCfgFlag+0x9f>
mov    %rax,%rbp
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11bb <GetBoolCfgFlag+0x8b>
lea    0xe92(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11bb <GetBoolCfgFlag+0x8b>
lea    0xe81(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11c0 <GetBoolCfgFlag+0x90>
lea    0xe70(%rip),%rsi
mov    %rbp,%rdi
call   1030 <stricmp@plt>
test   %rax,%rax
je     11c0 <GetBoolCfgFlag+0x90>
lea    0xe60(%rip),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1040 <printf@plt>
jmp    11cf <GetBoolCfgFlag+0x9f>
or     (%r14),%rbx
jmp    11c6 <GetBoolCfgFlag+0x96>
not    %rbx
and    (%r14),%rbx
mov    %rbx,(%r14)
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [51 x i8] c"Invalid config line %d, invalid boolean value: %s\0A\00"
define i32 @GetBoolCfgFlag(i8* %0, i64* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%12 = load i8*, i8** %6
%13 = call i8* @FindStringCfgValue(i8* %12)
store i8* %13, i8** %10
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 0, i32* %5
br label %54
16: ; preds = %4
%17 = load i8*, i8** %10
%18 = call i64 @stricmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i8*, i8** %10
%22 = call i64 @stricmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20, %16
store i32 1, i32* %11
br label %39
25: ; preds = %20
%26 = load i8*, i8** %10
%27 = call i64 @stricmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8*, i8** %10
%31 = call i64 @stricmp(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29, %25
store i32 0, i32* %11
br label %38
34: ; preds = %29
%35 = load i32, i32* %9
%36 = load i8*, i8** %6
%37 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %35, i8* %36)
store i32 0, i32* %5
br label %54
38: ; preds = %33
br label %39
39: ; preds = %38, %24
%40 = load i32, i32* %11
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i64, i64* %8
%44 = load i64*, i64** %7
%45 = load i64, i64* %44
%46 = or i64 %45, %43
store i64 %46, i64* %44
br label %53
47: ; preds = %39
%48 = load i64, i64* %8
%49 = xor i64 %48, -1
%50 = load i64*, i64** %7
%51 = load i64, i64* %50
%52 = and i64 %51, %49
store i64 %52, i64* %50
br label %53
53: ; preds = %47, %42
store i32 1, i32* %5
br label %54
54: ; preds = %53, %34, %15
%55 = load i32, i32* %5
ret i32 %55
}

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