#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 */
int /*<<< orphan*/ free(char *);
char *getenv(char const *);
char *loggerStrDup(char const *);
scalar_t__ strstr(char const *, char *);
char *strtok(char *, char *);
int matchToProgramList(const char *envVar_, const char *progName_) {
  char *progList;
  char *token;
  const char *progListVar = getenv(envVar_);
  if (!progListVar) {
    return 0;
  }
  progList = loggerStrDup(progListVar);
  if (!progList) {
    return 0;
  }
  token = strtok(progList, ":");
  while (token) {
    if (strstr(progName_, token)) {
      free(progList);
      return 1;
    }
    token = strtok(NULL, ":");
  }
  free(progList);
  return 0;
}


x86 assembly (clang, -O0):
<matchToProgramList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1184 <matchToProgramList+0x34>
movl   $0x0,-0x4(%rbp)
jmp    121c <matchToProgramList+0xcc>
mov    -0x30(%rbp),%rdi
call   1050 <loggerStrDup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <matchToProgramList+0x58>
movl   $0x0,-0x4(%rbp)
jmp    121c <matchToProgramList+0xcc>
mov    -0x20(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     120c <matchToProgramList+0xbc>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11f3 <matchToProgramList+0xa3>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    121c <matchToProgramList+0xcc>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe02(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    11bc <matchToProgramList+0x6c>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchToProgramList>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11d4 <matchToProgramList+0x84>
mov    %rax,%rdi
call   1050 <loggerStrDup@plt>
test   %rax,%rax
je     11d4 <matchToProgramList+0x84>
mov    %rax,%r14
lea    0xe82(%rip),%rsi
mov    %rax,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11c3 <matchToProgramList+0x73>
lea    0xe6e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rax,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11c7 <matchToProgramList+0x77>
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11a0 <matchToProgramList+0x50>
jmp    11cc <matchToProgramList+0x7c>
xor    %ebx,%ebx
jmp    11cc <matchToProgramList+0x7c>
mov    $0x1,%ebx
mov    %r14,%rdi
call   1040 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i32 @matchToProgramList(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i8* @getenv(i8* %9)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 0, i32* %3
br label %39
14: ; preds = %2
%15 = load i8*, i8** %8
%16 = call i8* @loggerStrDup(i8* %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %14
store i32 0, i32* %3
br label %39
20: ; preds = %14
%21 = load i8*, i8** %6
%22 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %7
br label %23
23: ; preds = %34, %20
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = load i8*, i8** %7
%29 = call i64 @strstr(i8* %27, i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %6
%33 = call i32 @free(i8* %32)
store i32 1, i32* %3
br label %39
34: ; preds = %26
%35 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %35, i8** %7
br label %23
36: ; preds = %23
%37 = load i8*, i8** %6
%38 = call i32 @free(i8* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %36, %31, %19, %13
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define i32 @matchToProgramList(i8* nocapture %0, i8* %1) {
%3 = tail call i8* @getenv(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i8* @loggerStrDup(i8* %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %8, %15
%12 = phi i8* [ %16, %15 ], [ %9, %8 ]
%13 = tail call i64 @strstr(i8* %1, i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %11
18: ; preds = %15, %11, %8
%19 = phi i32 [ 0, %8 ], [ 1, %11 ], [ 0, %15 ]
%20 = tail call i32 @free(i8* %6)
br label %21
21: ; preds = %18, %5, %2
%22 = phi i32 [ 0, %2 ], [ 0, %5 ], [ %19, %18 ]
ret i32 %22
}