#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 *strsep(char **, char *);
char *mystrsep(char **ptr, char *s) {
  char *p = "";
  while (p && !p[0] && *ptr)
    p = strsep(ptr, s);
  return (p);
}


x86 assembly (clang, -O0):
<mystrsep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     115b <mystrsep+0x4b>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpb   $0x0,(%rcx)
mov    %al,-0x19(%rbp)
jne    115b <mystrsep+0x4b>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    116b <mystrsep+0x5b>
jmp    1181 <mystrsep+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strsep@plt>
mov    %rax,-0x18(%rbp)
jmp    112b <mystrsep+0x1b>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mystrsep>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rax)
jne    114d <mystrsep+0x3d>
cmpq   $0x0,(%rbx)
je     114d <mystrsep+0x3d>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strsep@plt>
test   %rax,%rax
jne    1130 <mystrsep+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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