#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *strtok(char *, char *);
int tokenize_list(const char *thelist, int verbose) {
  char *tmpbuf, *token;
  int count = 0;
  tmpbuf = malloc(strlen(thelist) + 1);
  strcpy(tmpbuf, thelist);
  token = strtok(tmpbuf, "\t, \n");
  while (token) {
    if (verbose) {
      if (count)
        fprintf(stderr, "|%s", token);
      else
        fprintf(stderr, "%s", token);
    }
    count++;
    token = strtok(NULL, "\t, \n");
  }
  free(tmpbuf);
  return count;
}


x86 assembly (clang, -O0):
<tokenize_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122d <tokenize_list+0xcd>
cmpl   $0x0,-0xc(%rbp)
je     120b <tokenize_list+0xab>
cmpl   $0x0,-0x24(%rbp)
je     11ed <tokenize_list+0x8d>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe22(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1206 <tokenize_list+0xa6>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1060 <fprintf@plt>
jmp    120b <tokenize_list+0xab>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde1(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    11b0 <tokenize_list+0x50>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     1217 <tokenize_list+0xb7>
test   %ebx,%ebx
je     11bc <tokenize_list+0x5c>
mov    0x2e35(%rip),%rcx
mov    (%rcx),%edi
lea    0xe52(%rip),%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
lea    0xe3d(%rip),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1219 <tokenize_list+0xb9>
lea    0xe25(%rip),%r15
mov    0x2dfe(%rip),%r13
lea    0xe1c(%rip),%r12
jmp    1202 <tokenize_list+0xa2>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     1219 <tokenize_list+0xb9>
test   %ebx,%ebx
je     11f0 <tokenize_list+0x90>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
jmp    11f0 <tokenize_list+0x90>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\09, \0A\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"|%s\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @tokenize_list(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %9, 1
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %5
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %6
br label %17
17: ; preds = %35, %2
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %34
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %6
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %30, %26
br label %35
35: ; preds = %34, %20
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %6
br label %17
39: ; preds = %17
%40 = load i8*, i8** %5
%41 = call i32 @free(i8* %40)
%42 = load i32, i32* %7
ret i32 %42
}

LLVM IR (-O2):
@.str = [5 x i8] c"\09, \0A\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"|%s\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @tokenize_list(i8* %0, i32 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 1
%5 = tail call i8* @malloc(i64 %4)
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
%7 = tail call i8* @strtok(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %27, label %9
9: ; preds = %2
%10 = icmp eq i32 %1, 0
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %14
14: ; preds = %11, %9
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %27, label %17
17: ; preds = %14, %23
%18 = phi i32 [ %24, %23 ], [ 1, %14 ]
%19 = phi i8* [ %25, %23 ], [ %15, %14 ]
br i1 %10, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %23
23: ; preds = %20, %17
%24 = add nuw nsw i32 %18, 1
%25 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %17
27: ; preds = %23, %14, %2
%28 = phi i32 [ 0, %2 ], [ 1, %14 ], [ %24, %23 ]
%29 = tail call i32 @free(i8* %5)
ret i32 %28
}