#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 *const);
char *split_and_get(char *, char, char **);
scalar_t__ starts_with(char const *, char *);
char *strdup(char const *);
int starts_with_list_item(const char str[], const char list[]) {
  char *const list_copy = strdup(list);
  char *prefix = list_copy, *state = NULL;
  while ((prefix = split_and_get(prefix, ',', &state)) != NULL) {
    if (starts_with(str, prefix)) {
      break;
    }
  }
  free(list_copy);
  return prefix != NULL;
}


x86 assembly (clang, -O0):
<starts_with_list_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2c,%esi
lea    -0x28(%rbp),%rdx
call   1040 <split_and_get@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ae <starts_with_list_item+0x6e>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <starts_with@plt>
cmp    $0x0,%rax
je     11a9 <starts_with_list_item+0x69>
jmp    11ae <starts_with_list_item+0x6e>
jmp    116d <starts_with_list_item+0x2d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<starts_with_list_item>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r12
mov    %rsi,%rdi
call   1060 <strdup@plt>
mov    %rax,%r14
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r15
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
call   1040 <split_and_get@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1198 <starts_with_list_item+0x58>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <starts_with@plt>
test   %rax,%rax
je     1170 <starts_with_list_item+0x30>
xor    %ebp,%ebp
test   %rbx,%rbx
setne  %bpl
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @starts_with_list_item(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
store i8* %10, i8** %6
store i8* null, i8** %7
br label %11
11: ; preds = %21, %2
%12 = load i8*, i8** %6
%13 = call i8* @split_and_get(i8* %12, i8 signext 44, i8** %7)
store i8* %13, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8*, i8** %6
%18 = call i64 @starts_with(i8* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %22
21: ; preds = %15
br label %11
22: ; preds = %20, %11
%23 = load i8*, i8** %5
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %6
%26 = icmp ne i8* %25, null
%27 = zext i1 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
define i32 @starts_with_list_item(i8* %0, i8* nocapture %1) {
%3 = alloca i8*
%4 = tail call i8* @strdup(i8* %1)
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
br label %6
6: ; preds = %10, %2
%7 = phi i8* [ %4, %2 ], [ %8, %10 ]
%8 = call i8* @split_and_get(i8* %7, i8 signext 44, i8** %3)
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = call i64 @starts_with(i8* %0, i8* %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %10, %6
%14 = xor i1 %9, true
%15 = call i32 @free(i8* %4)
%16 = zext i1 %14 to i32
ret i32 %16
}