#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 */
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
int atoi(char *);
char *search_store(struct hsearch_data *, char *);
scalar_t__ sysconf(int /*<<< orphan*/);
int check_workers(struct hsearch_data *store) {
  char *process = search_store(store, "Workers");
  int processors_int;
  if (process) {
    processors_int = atoi(process);
  } else {
    processors_int = (int)sysconf(_SC_NPROCESSORS_ONLN);
  }
  return processors_int;
}


x86 assembly (clang, -O0):
<check_workers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <search_store@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116c <check_workers+0x3c>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    117d <check_workers+0x4d>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_workers>:
push   %rax
lea    0xec8(%rip),%rsi
call   1030 <search_store@plt>
test   %rax,%rax
je     114b <check_workers+0x1b>
mov    %rax,%rdi
pop    %rax
jmp    1050 <atoi@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <sysconf@plt>

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

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