#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 */
struct DateCriteria {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ appendDateCriteria(struct DateCriteria **,
                                      struct DateCriteria *);
struct DateCriteria *makeSingleDateCriteriaFromTxt(char *);
scalar_t__ strcmp(char *, char *);
char *strdupa(char *);
int strlen(char *);
char *strtok(char *, char *);
struct DateCriteria *makeMultipleDateCriteriaFromTxt(char *txt) {
  struct DateCriteria *result = NULL;
  char *txtCopy = strdupa(txt);
  char *tmp = strtok(txtCopy, "[]");
  while (tmp != NULL) {
    if (strcmp(tmp, ",") != 0) {
      struct DateCriteria *item = makeSingleDateCriteriaFromTxt(tmp);
      appendDateCriteria(&result, item);
    }
    tmp = strtok(tmp + strlen(tmp) + 1, "[]");
  }
  return result;
}


x86 assembly (clang, -O0):
<makeMultipleDateCriteriaFromTxt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdupa@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1207 <makeMultipleDateCriteriaFromTxt+0xa7>
mov    -0x20(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11d4 <makeMultipleDateCriteriaFromTxt+0x74>
mov    -0x20(%rbp),%rdi
call   1040 <makeSingleDateCriteriaFromTxt@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1030 <appendDateCriteria@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
lea    0xe07(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    1195 <makeMultipleDateCriteriaFromTxt+0x35>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeMultipleDateCriteriaFromTxt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
call   1070 <strdupa@plt>
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     11ed <makeMultipleDateCriteriaFromTxt+0x8d>
mov    %rax,%rbx
lea    0xe70(%rip),%r14
lea    0xe66(%rip),%r15
mov    %rsp,%r12
jmp    11c2 <makeMultipleDateCriteriaFromTxt+0x62>
nop
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11e7 <makeMultipleDateCriteriaFromTxt+0x87>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a0 <makeMultipleDateCriteriaFromTxt+0x40>
mov    %rbx,%rdi
call   1040 <makeSingleDateCriteriaFromTxt@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <appendDateCriteria@plt>
jmp    11a0 <makeMultipleDateCriteriaFromTxt+0x40>
mov    (%rsp),%rax
jmp    11ef <makeMultipleDateCriteriaFromTxt+0x8f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.DateCriteria = type { i32 }
@.str = [3 x i8] c"[]\00"
@.str.1 = [2 x i8] c",\00"
define %struct.DateCriteria* @makeMultipleDateCriteriaFromTxt(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.DateCriteria*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.DateCriteria*
store i8* %0, i8** %2
store %struct.DateCriteria* null, %struct.DateCriteria** %3
%7 = load i8*, i8** %2
%8 = call i8* @strdupa(i8* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %5
br label %11
11: ; preds = %23, %1
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call %struct.DateCriteria* @makeSingleDateCriteriaFromTxt(i8* %19)
store %struct.DateCriteria* %20, %struct.DateCriteria** %6
%21 = load %struct.DateCriteria*, %struct.DateCriteria** %6
%22 = call i32 @appendDateCriteria(%struct.DateCriteria** %3, %struct.DateCriteria* %21)
br label %23
23: ; preds = %18, %14
%24 = load i8*, i8** %5
%25 = load i8*, i8** %5
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %30, i8** %5
br label %11
31: ; preds = %11
%32 = load %struct.DateCriteria*, %struct.DateCriteria** %3
ret %struct.DateCriteria* %32
}

LLVM IR (-O2):
%struct.DateCriteria = type { i32 }
@.str = [3 x i8] c"[]\00"
@.str.1 = [2 x i8] c",\00"
define %struct.DateCriteria* @makeMultipleDateCriteriaFromTxt(i8* %0) {
%2 = alloca %struct.DateCriteria*
%3 = bitcast %struct.DateCriteria** %2 to i8*
store %struct.DateCriteria* null, %struct.DateCriteria** %2
%4 = tail call i8* @strdupa(i8* %0)
%5 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %23, label %7
7: ; preds = %1, %14
%8 = phi i8* [ %19, %14 ], [ %5, %1 ]
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = call %struct.DateCriteria* @makeSingleDateCriteriaFromTxt(i8* %8)
%13 = call i32 @appendDateCriteria(%struct.DateCriteria** %2, %struct.DateCriteria* %12)
br label %14
14: ; preds = %11, %7
%15 = call i32 @strlen(i8* %8)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = getelementptr inbounds i8, i8* %17, i64 %16
%19 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %7
21: ; preds = %14
%22 = load %struct.DateCriteria*, %struct.DateCriteria** %2
br label %23
23: ; preds = %21, %1
%24 = phi %struct.DateCriteria* [ %22, %21 ], [ null, %1 ]
ret %struct.DateCriteria* %24
}