#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int contains_tok(char *s1, char *s2, char *delims) {
  char *p;
  char tempstr[8092];
  strcpy(tempstr, s1);
  p = strtok(tempstr, delims);
  while (p != NULL) {
    if (!strcmp(p, s2)) {
      return (1);
    }
    p = strtok(NULL, delims);
  }
  return (0);
}


x86 assembly (clang, -O0):
<contains_tok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x1fd0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1fd0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ae <contains_tok+0x7e>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1198 <contains_tok+0x68>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <contains_tok+0x85>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    116b <contains_tok+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1fd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains_tok>:
push   %r15
push   %r14
push   %rbx
sub    $0x1fa0,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1182 <contains_tok+0x52>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1186 <contains_tok+0x56>
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1160 <contains_tok+0x30>
jmp    118b <contains_tok+0x5b>
xor    %ebx,%ebx
jmp    118b <contains_tok+0x5b>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x1fa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @contains_tok(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [8092 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [8092 x i8], [8092 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [8092 x i8], [8092 x i8]* %9, i64 0, i64 0
%14 = load i8*, i8** %7
%15 = call i8* @strtok(i8* %13, i8* %14)
store i8* %15, i8** %8
br label %16
16: ; preds = %25, %3
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i8*, i8** %8
%21 = load i8*, i8** %6
%22 = call i32 @strcmp(i8* %20, i8* %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 1, i32* %4
br label %29
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = call i8* @strtok(i8* null, i8* %26)
store i8* %27, i8** %8
br label %16
28: ; preds = %16
store i32 0, i32* %4
br label %29
29: ; preds = %28, %24
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @contains_tok(i8* %0, i8* nocapture %1, i8* nocapture %2) {
%4 = alloca [8092 x i8]
%5 = getelementptr inbounds [8092 x i8], [8092 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i8* @strtok(i8* %5, i8* %2)
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %3, %13
%10 = phi i8* [ %14, %13 ], [ %7, %3 ]
%11 = call i32 @strcmp(i8* %10, i8* dereferenceable(1) %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = call i8* @strtok(i8* null, i8* %2)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %9
16: ; preds = %9, %13, %3
%17 = phi i32 [ 0, %3 ], [ 0, %13 ], [ 1, %9 ]
ret i32 %17
}