#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 *strpbrk(char *, char const *);
char *strtoke(char *str, const char *delim) {
  static char *start = NULL;
  char *token = 0;
  if (str)
    start = str;
  if (!start)
    return NULL;
  token = start;
  start = strpbrk(start, delim);
  if (start)
    *start++ = '\0';
  return token;
}


x86 assembly (clang, -O0):
<strtoke>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113e <strtoke+0x2e>
mov    -0x10(%rbp),%rax
mov    %rax,0x2ef2(%rip)
cmpq   $0x0,0x2eea(%rip)
jne    1159 <strtoke+0x49>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <strtoke+0x99>
mov    0x2ed0(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ec5(%rip),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strpbrk@plt>
mov    %rax,0x2eb5(%rip)
cmpq   $0x0,0x2ead(%rip)
je     11a1 <strtoke+0x91>
mov    0x2ea0(%rip),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x2e92(%rip)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoke>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1125 <strtoke+0x15>
mov    0x2f10(%rip),%rbx
test   %rbx,%rbx
je     114c <strtoke+0x3c>
mov    %rbx,%rdi
call   1030 <strpbrk@plt>
mov    %rax,0x2efc(%rip)
test   %rax,%rax
je     114e <strtoke+0x3e>
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x2ee9(%rip)
movb   $0x0,(%rax)
jmp    114e <strtoke+0x3e>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@strtoke.start = internal global i8* null
define i8* @strtoke(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
store i8* null, i8** %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i8*, i8** %4
store i8* %10, i8** @strtoke.start
br label %11
11: ; preds = %9, %2
%12 = load i8*, i8** @strtoke.start
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11
store i8* null, i8** %3
br label %27
15: ; preds = %11
%16 = load i8*, i8** @strtoke.start
store i8* %16, i8** %6
%17 = load i8*, i8** @strtoke.start
%18 = load i8*, i8** %5
%19 = call i8* @strpbrk(i8* %17, i8* %18)
store i8* %19, i8** @strtoke.start
%20 = load i8*, i8** @strtoke.start
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i8*, i8** @strtoke.start
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** @strtoke.start
store i8 0, i8* %23
br label %25
25: ; preds = %22, %15
%26 = load i8*, i8** %6
store i8* %26, i8** %3
br label %27
27: ; preds = %25, %14
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@strtoke.start = internal unnamed_addr global i8* null
define i8* @strtoke(i8* %0, i8* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** @strtoke.start
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %2, %4
%8 = phi i8* [ %5, %4 ], [ %0, %2 ]
%9 = tail call i8* @strpbrk(i8* %8, i8* %1)
store i8* %9, i8** @strtoke.start
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %12, i8** @strtoke.start
store i8 0, i8* %9
br label %13
13: ; preds = %7, %11, %4
%14 = phi i8* [ null, %4 ], [ %8, %11 ], [ %8, %7 ]
ret i8* %14
}