#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 */
char strchr(char *, char);
char *_next_tok(char *sep, char **str) {
  char *tok;
  while (**str != '\0' && strchr(sep, **str) != '\0')
    (*str)++;
  if (**str == '\0')
    return NULL;
  tok = *str;
  while (**str != '\0' && strchr(sep, **str) == '\0')
    (*str)++;
  while (**str != '\0' && strchr(sep, **str) != '\0')
    *(*str)++ = '\0';
  return tok;
}


x86 assembly (clang, -O0):
<_next_tok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1157 <_next_tok+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
movsbl %al,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1167 <_next_tok+0x57>
jmp    117a <_next_tok+0x6a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1120 <_next_tok+0x10>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119a <_next_tok+0x8a>
movq   $0x0,-0x8(%rbp)
jmp    126c <_next_tok+0x15c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x22(%rbp)
je     11dc <_next_tok+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
movsbl %al,%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    11ec <_next_tok+0xdc>
jmp    11ff <_next_tok+0xef>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11a5 <_next_tok+0x95>
jmp    1204 <_next_tok+0xf4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x23(%rbp)
je     123b <_next_tok+0x12b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
movsbl %al,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    124b <_next_tok+0x13b>
jmp    1264 <_next_tok+0x154>
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x0,(%rax)
jmp    1204 <_next_tok+0xf4>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_next_tok>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%rax
mov    (%rax),%al
test   %al,%al
je     1183 <_next_tok+0x73>
mov    %rsi,%r14
mov    %rdi,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
mov    (%r14),%rbx
test   %al,%al
je     1153 <_next_tok+0x43>
lea    0x1(%rbx),%rax
mov    %rax,(%r14)
movzbl 0x1(%rbx),%eax
test   %al,%al
jne    1130 <_next_tok+0x20>
jmp    1183 <_next_tok+0x73>
mov    (%rbx),%al
test   %al,%al
je     1183 <_next_tok+0x73>
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
mov    (%r14),%rcx
test   %al,%al
jne    118e <_next_tok+0x7e>
lea    0x1(%rcx),%rax
mov    %rax,(%r14)
movzbl 0x1(%rcx),%eax
test   %al,%al
jne    1160 <_next_tok+0x50>
jmp    1185 <_next_tok+0x75>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%rcx),%al
test   %al,%al
je     1185 <_next_tok+0x75>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %al,%al
je     1185 <_next_tok+0x75>
mov    (%r14),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r14)
movb   $0x0,(%rax)
mov    (%r14),%rax
movzbl (%rax),%eax
test   %al,%al
jne    11a0 <_next_tok+0x90>
jmp    1185 <_next_tok+0x75>

LLVM IR (-O0):
define i8* @_next_tok(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %23, %2
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %7
%14 = load i8*, i8** %4
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = call signext i8 @strchr(i8* %14, i8 signext %17)
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %13, %7
%22 = phi i1 [ false, %7 ], [ %20, %13 ]
br i1 %22, label %23, label %27
23: ; preds = %21
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %24
br label %7
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i8* null, i8** %3
br label %80
34: ; preds = %27
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
store i8* %36, i8** %6
br label %37
37: ; preds = %53, %34
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = load i8**, i8*** %5
%46 = load i8*, i8** %45
%47 = load i8, i8* %46
%48 = call signext i8 @strchr(i8* %44, i8 signext %47)
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 0
br label %51
51: ; preds = %43, %37
%52 = phi i1 [ false, %37 ], [ %50, %43 ]
br i1 %52, label %53, label %57
53: ; preds = %51
%54 = load i8**, i8*** %5
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %54
br label %37
57: ; preds = %51
br label %58
58: ; preds = %74, %57
%59 = load i8**, i8*** %5
%60 = load i8*, i8** %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %72
64: ; preds = %58
%65 = load i8*, i8** %4
%66 = load i8**, i8*** %5
%67 = load i8*, i8** %66
%68 = load i8, i8* %67
%69 = call signext i8 @strchr(i8* %65, i8 signext %68)
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 0
br label %72
72: ; preds = %64, %58
%73 = phi i1 [ false, %58 ], [ %71, %64 ]
br i1 %73, label %74, label %78
74: ; preds = %72
%75 = load i8**, i8*** %5
%76 = load i8*, i8** %75
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %75
store i8 0, i8* %76
br label %58
78: ; preds = %72
%79 = load i8*, i8** %6
store i8* %79, i8** %3
br label %80
80: ; preds = %78, %33
%81 = load i8*, i8** %3
ret i8* %81
}

LLVM IR (-O2):
define i8* @_next_tok(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %40, label %6
6: ; preds = %2, %11
%7 = phi i8 [ %13, %11 ], [ %4, %2 ]
%8 = tail call signext i8 @strchr(i8* %0, i8 signext %7)
%9 = icmp eq i8 %8, 0
%10 = load i8*, i8** %1
br i1 %9, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %12, i8** %1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %40, label %6
15: ; preds = %6
%16 = load i8, i8* %10
%17 = icmp eq i8 %16, 0
br i1 %17, label %40, label %18
18: ; preds = %15, %23
%19 = phi i8 [ %25, %23 ], [ %16, %15 ]
%20 = tail call signext i8 @strchr(i8* %0, i8 signext %19)
%21 = icmp eq i8 %20, 0
%22 = load i8*, i8** %1
br i1 %21, label %23, label %27
23: ; preds = %18
%24 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %24, i8** %1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %40, label %18
27: ; preds = %18
%28 = load i8, i8* %22
%29 = icmp eq i8 %28, 0
br i1 %29, label %40, label %30
30: ; preds = %27, %34
%31 = phi i8 [ %38, %34 ], [ %28, %27 ]
%32 = tail call signext i8 @strchr(i8* %0, i8 signext %31)
%33 = icmp eq i8 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %30
%35 = load i8*, i8** %1
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %1
store i8 0, i8* %35
%37 = load i8*, i8** %1
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %40, label %30
40: ; preds = %11, %23, %34, %30, %2, %27, %15
%41 = phi i8* [ null, %15 ], [ %10, %27 ], [ null, %2 ], [ %10, %30 ], [ %10, %34 ], [ %10, %23 ], [ null, %11 ]
ret i8* %41
}