#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 */
scalar_t__ strcmp(char *, char const *);
char *strtok_r(char *, char *, char **);
int controller_in_clist(char *cgline, const char *c) {
  char *tok;
  for (char *__p = NULL, *__it = strtok_r(cgline, ",", &__p); (tok = __it);
       tok = __it = strtok_r(NULL, ",", &__p))
    if (strcmp(tok, c) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<controller_in_clist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ab <controller_in_clist+0x8b>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1185 <controller_in_clist+0x65>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <controller_in_clist+0x92>
jmp    118a <controller_in_clist+0x6a>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6b(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x20(%rbp)
jmp    1150 <controller_in_clist+0x30>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<controller_in_clist>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
movq   $0x0,(%rsp)
lea    0xec6(%rip),%rsi
mov    %rsp,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
je     118f <controller_in_clist+0x6f>
lea    0xeb2(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1185 <controller_in_clist+0x65>
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
jne    1160 <controller_in_clist+0x40>
xor    %eax,%eax
test   %rbx,%rbx
sete   %al
jmp    1191 <controller_in_clist+0x71>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @controller_in_clist(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
store i8* null, i8** %7
%9 = load i8*, i8** %4
%10 = call i8* @strtok_r(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7)
store i8* %10, i8** %8
br label %11
11: ; preds = %21, %2
%12 = load i8*, i8** %8
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i8*, i8** %6
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %3
br label %24
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7)
store i8* %22, i8** %8
store i8* %22, i8** %6
br label %11
23: ; preds = %11
store i32 0, i32* %3
br label %24
24: ; preds = %23, %19
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @controller_in_clist(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2, %11
%8 = phi i8* [ %12, %11 ], [ %5, %2 ]
%9 = call i64 @strcmp(i8* %8, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %7
14: ; preds = %7, %11
%15 = zext i1 %10 to i32
br label %16
16: ; preds = %14, %2
%17 = phi i32 [ 0, %2 ], [ %15, %14 ]
ret i32 %17
}