#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 */
struct hsearch_data {
  int dummy;
};

/* Variables and functions */
char *search_store(struct hsearch_data *, char *);
scalar_t__ strcmp(char *, char *);
bool check_boolean_setting(struct hsearch_data *store, char *setting_name) {
  char *setting = search_store(store, setting_name);
  if (!setting) {
    return false;
  }
  if (strcmp(setting, "true") == 0) {
    return true;
  } else {
    return false;
  }
}


x86 assembly (clang, -O0):
<check_boolean_setting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <search_store@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1158 <check_boolean_setting+0x38>
movl   $0x0,-0x4(%rbp)
jmp    1185 <check_boolean_setting+0x65>
mov    -0x20(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117e <check_boolean_setting+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    1185 <check_boolean_setting+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_boolean_setting>:
push   %rax
call   1030 <search_store@plt>
test   %rax,%rax
je     1147 <check_boolean_setting+0x27>
lea    0xece(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.hsearch_data = type { i32 }
@.str = [5 x i8] c"true\00"
define i32 @check_boolean_setting(%struct.hsearch_data* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.hsearch_data*
%5 = alloca i8*
%6 = alloca i8*
store %struct.hsearch_data* %0, %struct.hsearch_data** %4
store i8* %1, i8** %5
%7 = load %struct.hsearch_data*, %struct.hsearch_data** %4
%8 = load i8*, i8** %5
%9 = call i8* @search_store(%struct.hsearch_data* %7, i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i32 0, i32* %3
br label %19
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %3
br label %19
18: ; preds = %13
store i32 0, i32* %3
br label %19
19: ; preds = %18, %17, %12
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.hsearch_data = type { i32 }
@.str = [5 x i8] c"true\00"
define i32 @check_boolean_setting(%struct.hsearch_data* %0, i8* %1) {
%3 = tail call i8* @search_store(%struct.hsearch_data* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ 0, %2 ], [ %8, %5 ]
ret i32 %10
}