#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 Data {
  int dummy;
};

/* Variables and functions */
struct Data *getMonitorValuesForAll(int);
struct Data *getMonitorValuesForHost(int, char *);
struct Data *getMonitorValuesForHostAndAdapter(int, char *, char *);
int /*<<< orphan*/ logMsg(int, char *, char *);
struct Data *getMonitorValues(int ts, char *hs, char *ad) {
  int selectByAdapter = (ad == NULL ? 0 : 1);
  int selectByHost = (hs == NULL ? 0 : 1);
  struct Data *result;
  if (selectByAdapter == 1) {
    if (selectByHost == 1) {
      result = getMonitorValuesForHostAndAdapter(ts, hs, ad);
    } else {
      logMsg(3,
             "getMonitorValues called with null 'hs' but a non-null 'ad' of %s",
             ad);
      result = NULL;
    }
  } else {
    if (selectByHost == 1) {
      result = getMonitorValuesForHost(ts, hs);
    } else {
      result = getMonitorValuesForAll(ts);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<getMonitorValues>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11cc <getMonitorValues+0x8c>
cmpl   $0x1,-0x20(%rbp)
jne    11aa <getMonitorValues+0x6a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <getMonitorValuesForHostAndAdapter@plt>
mov    %rax,-0x28(%rbp)
jmp    11c7 <getMonitorValues+0x87>
mov    -0x18(%rbp),%rdx
mov    $0x3,%edi
lea    0xe46(%rip),%rsi
call   1040 <logMsg@plt>
movq   $0x0,-0x28(%rbp)
jmp    11fc <getMonitorValues+0xbc>
cmpl   $0x1,-0x20(%rbp)
jne    11eb <getMonitorValues+0xab>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <getMonitorValuesForHost@plt>
mov    %rax,-0x28(%rbp)
jmp    11f7 <getMonitorValues+0xb7>
mov    -0x4(%rbp),%edi
call   1030 <getMonitorValuesForAll@plt>
mov    %rax,-0x28(%rbp)
jmp    11fc <getMonitorValues+0xbc>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMonitorValues>:
test   %rdx,%rdx
je     114f <getMonitorValues+0xf>
test   %rsi,%rsi
je     1159 <getMonitorValues+0x19>
jmp    1060 <getMonitorValuesForHostAndAdapter@plt>
test   %rsi,%rsi
je     116f <getMonitorValues+0x2f>
jmp    1050 <getMonitorValuesForHost@plt>
push   %rax
lea    0xe9f(%rip),%rsi
mov    $0x3,%edi
call   1040 <logMsg@plt>
xor    %eax,%eax
pop    %rcx
ret
jmp    1030 <getMonitorValuesForAll@plt>

LLVM IR (-O0):
%struct.Data = type { i32 }
@.str = [65 x i8] c"getMonitorValues called with null 'hs' but a non-null 'ad' of %s\00"
define %struct.Data* @getMonitorValues(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.Data*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 0, i32 1
store i32 %13, i32* %7
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 0, i32 1
store i32 %17, i32* %8
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %32
20: ; preds = %3
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = call %struct.Data* @getMonitorValuesForHostAndAdapter(i32 %24, i8* %25, i8* %26)
store %struct.Data* %27, %struct.Data** %9
br label %31
28: ; preds = %20
%29 = load i8*, i8** %6
%30 = call i32 @logMsg(i32 3, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %29)
store %struct.Data* null, %struct.Data** %9
br label %31
31: ; preds = %28, %23
br label %43
32: ; preds = %3
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* %4
%37 = load i8*, i8** %5
%38 = call %struct.Data* @getMonitorValuesForHost(i32 %36, i8* %37)
store %struct.Data* %38, %struct.Data** %9
br label %42
39: ; preds = %32
%40 = load i32, i32* %4
%41 = call %struct.Data* @getMonitorValuesForAll(i32 %40)
store %struct.Data* %41, %struct.Data** %9
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42, %31
%44 = load %struct.Data*, %struct.Data** %9
ret %struct.Data* %44
}

LLVM IR (-O2):
%struct.Data = type { i32 }
@.str = [65 x i8] c"getMonitorValues called with null 'hs' but a non-null 'ad' of %s\00"
define %struct.Data* @getMonitorValues(i32 %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = icmp eq i8* %1, null
br i1 %4, label %11, label %6
6: ; preds = %3
br i1 %5, label %9, label %7
7: ; preds = %6
%8 = tail call %struct.Data* @getMonitorValuesForHostAndAdapter(i32 %0, i8* %1, i8* %2)
br label %16
9: ; preds = %6
%10 = tail call i32 @logMsg(i32 3, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %16
11: ; preds = %3
br i1 %5, label %14, label %12
12: ; preds = %11
%13 = tail call %struct.Data* @getMonitorValuesForHost(i32 %0, i8* %1)
br label %16
14: ; preds = %11
%15 = tail call %struct.Data* @getMonitorValuesForAll(i32 %0)
br label %16
16: ; preds = %12, %14, %7, %9
%17 = phi %struct.Data* [ %8, %7 ], [ null, %9 ], [ %13, %12 ], [ %15, %14 ]
ret %struct.Data* %17
}