#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 strlen(char const *);
char *strstr(char const *, char const *);
int string_in_list_comma(const char *list, const char *string) {
  if (!list || !string)
    return 0;
  char *found = strstr(list, string);
  if (!found)
    return 0;
  char next = *(found + strlen(string));
  if (next == '\0' || next == ',')
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<string_in_list_comma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <string_in_list_comma+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <string_in_list_comma+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_in_list_comma+0xa7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117a <string_in_list_comma+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_in_list_comma+0xa7>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
je     11b4 <string_in_list_comma+0x94>
movsbl -0x21(%rbp),%eax
cmp    $0x2c,%eax
jne    11c0 <string_in_list_comma+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <string_in_list_comma+0xa7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_in_list_comma>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     1160 <string_in_list_comma+0x40>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1160 <string_in_list_comma+0x40>
mov    %rbx,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1160 <string_in_list_comma+0x40>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    (%r14,%rax,1),%al
cmp    $0x2c,%al
sete   %cl
test   %al,%al
sete   %al
or     %cl,%al
movzbl %al,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @string_in_list_comma(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %2
store i32 0, i32* %3
br label %37
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i8* @strstr(i8* %15, i8* %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 0, i32* %3
br label %37
21: ; preds = %14
%22 = load i8*, i8** %6
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %7
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %21
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 44
br i1 %34, label %35, label %36
35: ; preds = %31, %21
store i32 1, i32* %3
br label %37
36: ; preds = %31
store i32 0, i32* %3
br label %37
37: ; preds = %36, %35, %20, %13
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @string_in_list_comma(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = tail call i8* @strstr(i8* %0, i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %1)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 44
%15 = icmp eq i8 %13, 0
%16 = or i1 %14, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %9, %6, %2
%19 = phi i32 [ 0, %2 ], [ 0, %6 ], [ %17, %9 ]
ret i32 %19
}