#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*/ _inplace_trim(char *);
int /*<<< orphan*/ _itemize(char *, char ***, int *);
int /*<<< orphan*/ _items_cleanup(char **, int);
scalar_t__ _streq(int /*<<< orphan*/, char *);
int cstr_has_item(const char *in_string, const char *in_item) {
  char **items;
  int count, result = 0;
  _itemize((char *)in_string, &items, &count);
  for (int i = 0; i < count; i++) {
    if (_streq(_inplace_trim(items[i]), (char *)in_item)) {
      result = 1;
      break;
    }
  }
  _items_cleanup(items, count);
  return result;
}


x86 assembly (clang, -O0):
<cstr_has_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <_itemize@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c0 <cstr_has_item+0x80>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <_inplace_trim@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <_streq@plt>
cmp    $0x0,%rax
je     11ad <cstr_has_item+0x6d>
movl   $0x1,-0x20(%rbp)
jmp    11c0 <cstr_has_item+0x80>
jmp    11b2 <cstr_has_item+0x72>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <cstr_has_item+0x2f>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <_items_cleanup@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cstr_has_item>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <_itemize@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    119d <cstr_has_item+0x5d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <_inplace_trim@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <_streq@plt>
mov    0xc(%rsp),%esi
test   %rax,%rax
jne    11a1 <cstr_has_item+0x61>
add    $0x1,%rbx
movslq %esi,%rax
cmp    %rax,%rbx
jl     1170 <cstr_has_item+0x30>
xor    %ebx,%ebx
jmp    11a6 <cstr_has_item+0x66>
mov    $0x1,%ebx
mov    0x10(%rsp),%rdi
call   1060 <_items_cleanup@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @cstr_has_item(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%9 = load i8*, i8** %3
%10 = call i32 @_itemize(i8* %9, i8*** %5, i32* %6)
store i32 0, i32* %8
br label %11
11: ; preds = %27, %2
%12 = load i32, i32* %8
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @_inplace_trim(i8* %20)
%22 = load i8*, i8** %4
%23 = call i64 @_streq(i32 %21, i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %15
store i32 1, i32* %7
br label %30
26: ; preds = %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %11
30: ; preds = %25, %11
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = call i32 @_items_cleanup(i8** %31, i32 %32)
%34 = load i32, i32* %7
ret i32 %34
}

LLVM IR (-O2):
define i32 @cstr_has_item(i8* %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = bitcast i8*** %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @_itemize(i8* %0, i8*** %3, i32* %4)
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %13, label %23
10: ; preds = %13
%11 = sext i32 %22 to i64
%12 = icmp slt i64 %21, %11
br i1 %12, label %13, label %23
13: ; preds = %2, %10
%14 = phi i64 [ %21, %10 ], [ 0, %2 ]
%15 = load i8**, i8*** %3
%16 = getelementptr inbounds i8*, i8** %15, i64 %14
%17 = load i8*, i8** %16
%18 = call i32 @_inplace_trim(i8* %17)
%19 = call i64 @_streq(i32 %18, i8* %1)
%20 = icmp eq i64 %19, 0
%21 = add nuw nsw i64 %14, 1
%22 = load i32, i32* %4
br i1 %20, label %10, label %23
23: ; preds = %10, %13, %2
%24 = phi i32 [ %8, %2 ], [ %22, %13 ], [ %22, %10 ]
%25 = phi i32 [ 0, %2 ], [ 0, %10 ], [ 1, %13 ]
%26 = load i8**, i8*** %3
%27 = call i32 @_items_cleanup(i8** %26, i32 %24)
ret i32 %25
}