#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 *mystrsep(char **stringp, const char *delim) {
  char *start = *stringp;
  char *p;
  p = (start != NULL) ? strpbrk(start, delim) : NULL;
  if (p == NULL) {
    *stringp = NULL;
  } else {
    *p = '\0';
    *stringp = p + 1;
  }
  return start;
}


x86 assembly (clang, -O0):
<mystrsep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114c <mystrsep+0x3c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x28(%rbp)
jmp    1157 <mystrsep+0x47>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1157 <mystrsep+0x47>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117a <mystrsep+0x6a>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    1190 <mystrsep+0x80>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mystrsep>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
test   %rbx,%rbx
je     1135 <mystrsep+0x25>
mov    %rbx,%rdi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     1135 <mystrsep+0x25>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    1137 <mystrsep+0x27>
xor    %eax,%eax
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @mystrsep(i8** nocapture %0, i8* nocapture %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %10, 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
store i8 0, i8* %6
%9 = getelementptr inbounds i8, i8* %6, i64 1
br label %10
10: ; preds = %2, %5, %8
%11 = phi i8* [ %9, %8 ], [ null, %5 ], [ null, %2 ]
store i8* %11, i8** %0
ret i8* %3
}