#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 *strsep(char **restrict string, const char *restrict delimiters) {
  char *r = *string;
  char *next;
  if (r == NULL)
    return NULL;
  next = strpbrk(r, delimiters);
  if (next != NULL)
    *next++ = 0;
  *string = next;
  return r;
}


x86 assembly (clang, -O0):
<strsep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1143 <strsep+0x33>
movq   $0x0,-0x8(%rbp)
jmp    1184 <strsep+0x74>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1171 <strsep+0x61>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsep>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbx
test   %rbx,%rbx
je     113d <strsep+0x2d>
mov    %rdi,%r14
mov    %rbx,%rdi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     1138 <strsep+0x28>
mov    %rax,%rcx
add    $0x1,%rcx
movb   $0x0,(%rax)
jmp    113a <strsep+0x2a>
xor    %ecx,%ecx
mov    %rcx,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @strsep(i8** noalias %0, i8* noalias %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i8* null, i8** %3
br label %26
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = load i8*, i8** %5
%16 = call i8* @strpbrk(i8* %14, i8* %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %7
store i8 0, i8* %20
br label %22
22: ; preds = %19, %13
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %4
store i8* %23, i8** %24
%25 = load i8*, i8** %6
store i8* %25, i8** %3
br label %26
26: ; preds = %22, %12
%27 = load i8*, i8** %3
ret i8* %27
}

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