#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 *config_get(char const *, char const *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int config_get_boolean_ondemand(const char *section, const char *name,
                                int value) {
  char *s;
  if (value == 2)
    s = "on demand";
  else if (value == 0)
    s = "no";
  else
    s = "yes";
  s = config_get(section, name, s);
  if (!s)
    return value;
  if (!strcmp(s, "yes"))
    return 1;
  else if (!strcmp(s, "no"))
    return 0;
  else if (!strcmp(s, "on demand"))
    return 2;
  return value;
}


x86 assembly (clang, -O0):
<config_get_boolean_ondemand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jne    114d <config_get_boolean_ondemand+0x2d>
lea    0xebc(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1177 <config_get_boolean_ondemand+0x57>
cmpl   $0x0,-0x1c(%rbp)
jne    1167 <config_get_boolean_ondemand+0x47>
lea    0xeac(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1172 <config_get_boolean_ondemand+0x52>
lea    0xe9f(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1177 <config_get_boolean_ondemand+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <config_get@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a2 <config_get_boolean_ondemand+0x82>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <config_get_boolean_ondemand+0x101>
mov    -0x28(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <config_get_boolean_ondemand+0xa7>
movl   $0x1,-0x4(%rbp)
jmp    1221 <config_get_boolean_ondemand+0x101>
mov    -0x28(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ec <config_get_boolean_ondemand+0xcc>
movl   $0x0,-0x4(%rbp)
jmp    1221 <config_get_boolean_ondemand+0x101>
mov    -0x28(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1211 <config_get_boolean_ondemand+0xf1>
movl   $0x2,-0x4(%rbp)
jmp    1221 <config_get_boolean_ondemand+0x101>
jmp    1216 <config_get_boolean_ondemand+0xf6>
jmp    121b <config_get_boolean_ondemand+0xfb>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_get_boolean_ondemand>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
test   %edx,%edx
lea    0xedc(%rip),%rax
lea    0xed8(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x2,%edx
lea    0xebd(%rip),%rdx
cmovne %rcx,%rdx
call   1030 <config_get@plt>
test   %rax,%rax
je     119e <config_get_boolean_ondemand+0x7e>
mov    %rax,%rbx
lea    0xeb2(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1195 <config_get_boolean_ondemand+0x75>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     119c <config_get_boolean_ondemand+0x7c>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
mov    $0x2,%eax
cmove  %eax,%ebp
jmp    119e <config_get_boolean_ondemand+0x7e>
mov    $0x1,%ebp
jmp    119e <config_get_boolean_ondemand+0x7e>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"on demand\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [4 x i8] c"yes\00"
define i32 @config_get_boolean_ondemand(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %8
br label %18
12: ; preds = %3
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %17
16: ; preds = %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %17
17: ; preds = %16, %15
br label %18
18: ; preds = %17, %11
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %8
%22 = call i8* @config_get(i8* %19, i8* %20, i8* %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = icmp ne i8* %23, null
br i1 %24, label %27, label %25
25: ; preds = %18
%26 = load i32, i32* %7
store i32 %26, i32* %4
br label %46
27: ; preds = %18
%28 = load i8*, i8** %8
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27
store i32 1, i32* %4
br label %46
32: ; preds = %27
%33 = load i8*, i8** %8
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i32 0, i32* %4
br label %46
37: ; preds = %32
%38 = load i8*, i8** %8
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i32 2, i32* %4
br label %46
42: ; preds = %37
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43
%45 = load i32, i32* %7
store i32 %45, i32* %4
br label %46
46: ; preds = %44, %41, %36, %31, %25
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
@.str = [10 x i8] c"on demand\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [4 x i8] c"yes\00"
define i32 @config_get_boolean_ondemand(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%6 = icmp eq i32 %2, 2
%7 = select i1 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5
%8 = tail call i8* @config_get(i8* %0, i8* %1, i8* %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %20, label %10
10: ; preds = %3
%11 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 2, i32 %2
br label %20
20: ; preds = %16, %13, %10, %3
%21 = phi i32 [ %2, %3 ], [ 1, %10 ], [ 0, %13 ], [ %19, %16 ]
ret i32 %21
}