#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 *pathsep(char **s) {
  char *n;
  do
    n = strsep(s, "/");
  while (n != NULL && *n == 0);
  if (n == NULL || *n == 0)
    n = *s = NULL;
  if (*s != NULL) {
    while (**s == '/')
      (*s)++;
    if (**s == 0)
      *s = NULL;
  }
  return n;
}


x86 assembly (clang, -O0):
<pathsep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strsep@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1150 <pathsep+0x40>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    111c <pathsep+0xc>
cmpq   $0x0,-0x10(%rbp)
je     1176 <pathsep+0x66>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1189 <pathsep+0x79>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e5 <pathsep+0xd5>
jmp    119c <pathsep+0x8c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11c2 <pathsep+0xb2>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    119c <pathsep+0x8c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e0 <pathsep+0xd0>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11e5 <pathsep+0xd5>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathsep>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee2(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strsep@plt>
test   %rax,%rax
je     1156 <pathsep+0x46>
cmpb   $0x0,(%rax)
je     1120 <pathsep+0x10>
mov    (%rbx),%rcx
test   %rcx,%rcx
je     115d <pathsep+0x4d>
nopl   (%rax)
add    $0x1,%rcx
movzbl -0x1(%rcx),%edx
cmp    $0x2f,%dl
jne    1152 <pathsep+0x42>
mov    %rcx,(%rbx)
jmp    1140 <pathsep+0x30>
test   %dl,%dl
jne    115d <pathsep+0x4d>
movq   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @pathsep(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
store i8** %0, i8*** %2
br label %4
4: ; preds = %15, %1
%5 = load i8**, i8*** %2
%6 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
br label %7
7: ; preds = %4
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br label %15
15: ; preds = %10, %7
%16 = phi i1 [ false, %7 ], [ %14, %10 ]
br i1 %16, label %4, label %17
17: ; preds = %15
%18 = load i8*, i8** %3
%19 = icmp eq i8* %18, null
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20, %17
%26 = load i8**, i8*** %2
store i8* null, i8** %26
store i8* null, i8** %3
br label %27
27: ; preds = %25, %20
%28 = load i8**, i8*** %2
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %51
31: ; preds = %27
br label %32
32: ; preds = %38, %31
%33 = load i8**, i8*** %2
%34 = load i8*, i8** %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 47
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = load i8**, i8*** %2
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %39
br label %32
42: ; preds = %32
%43 = load i8**, i8*** %2
%44 = load i8*, i8** %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = load i8**, i8*** %2
store i8* null, i8** %49
br label %50
50: ; preds = %48, %42
br label %51
51: ; preds = %50, %27
%52 = load i8*, i8** %3
ret i8* %52
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @pathsep(i8** %0) {
br label %2
2: ; preds = %5, %1
%3 = tail call i8* @strsep(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %2, label %8
8: ; preds = %5
%9 = load i8*, i8** %0
%10 = icmp eq i8* %9, null
br i1 %10, label %17, label %11
11: ; preds = %8, %14
%12 = phi i8* [ %15, %14 ], [ %9, %8 ]
%13 = load i8, i8* %12
switch i8 %13, label %17 [
i8 47, label %14
i8 0, label %16
]
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %15, i8** %0
br label %11
16: ; preds = %2, %11
store i8* null, i8** %0
br label %17
17: ; preds = %11, %16, %8
ret i8* %3
}