#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 */
int /*<<< orphan*/ strcat(char *, char *);
char *osparsepath(char **pp) {
  static char buf[256];
  char *src, *dst;
  for (src = *pp, dst = buf; *src != '\0'; *dst++ = *src++)
    if (*src == ':') {
      ++src;
      break;
    }
  *dst = '\0';
  if (dst > buf && dst[-1] != '/')
    strcat(dst, "/");
  *pp = src;
  return dst == buf ? NULL : buf;
}


x86 assembly (clang, -O0):
<osparsepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f12(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118f <osparsepath+0x7f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1163 <osparsepath+0x53>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118f <osparsepath+0x7f>
jmp    1168 <osparsepath+0x58>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1132 <osparsepath+0x22>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ea3(%rip),%rax
cmp    %rax,-0x18(%rbp)
jbe    11c8 <osparsepath+0xb8>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
je     11c8 <osparsepath+0xb8>
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdx
lea    0x2e62(%rip),%rax
xor    %ecx,%ecx
cmp    %rax,%rdx
cmove  %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osparsepath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%r15
xor    %eax,%eax
lea    0x2f19(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r15,%rax,1),%ecx
test   %cl,%cl
je     1155 <osparsepath+0x45>
cmp    $0x3a,%cl
je     114c <osparsepath+0x3c>
mov    %cl,(%rax,%r12,1)
add    $0xffffffffffffffff,%rbx
add    $0x1,%rax
jmp    1130 <osparsepath+0x20>
sub    %rbx,%r15
add    $0x1,%r15
jmp    1158 <osparsepath+0x48>
sub    %rbx,%r15
movb   $0x0,(%rax,%r12,1)
mov    %r12,%rdi
sub    %rbx,%rdi
cmp    %r12,%rdi
jbe    117c <osparsepath+0x6c>
cmpb   $0x2f,-0x1(%rax,%r12,1)
je     117c <osparsepath+0x6c>
lea    0xe89(%rip),%rsi
call   1030 <strcat@plt>
mov    %r15,(%r14)
test   %rbx,%rbx
cmove  %rbx,%r12
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@osparsepath.buf = internal global [256 x i8] zeroinitializer
@.str = [2 x i8] c"/\00"
define i8* @osparsepath(i8** nocapture %0) {
%2 = load i8*, i8** %0
br label %3
3: ; preds = %9, %1
%4 = phi i8* [ %2, %1 ], [ %10, %9 ]
%5 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @osparsepath.buf, i64 0, i64 0), %1 ], [ %11, %9 ]
%6 = load i8, i8* %4
switch i8 %6, label %9 [
i8 0, label %12
i8 58, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
br label %12
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %4, i64 1
%11 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %6, i8* %5
br label %3
12: ; preds = %3, %7
%13 = phi i8* [ %8, %7 ], [ %4, %3 ]
store i8 0, i8* %5
%14 = icmp ugt i8* %5, getelementptr inbounds ([256 x i8], [256 x i8]* @osparsepath.buf, i64 0, i64 0)
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %5, i64 -1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 47
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %12
store i8* %13, i8** %0
%22 = icmp eq i8* %5, getelementptr inbounds ([256 x i8], [256 x i8]* @osparsepath.buf, i64 0, i64 0)
%23 = select i1 %22, i8* null, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @osparsepath.buf, i64 0, i64 0)
ret i8* %23
}