#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 */
struct vfs {
  int dummy;
};

/* Variables and functions */
struct vfs *find_vfs(char const *, int);
int /*<<< orphan*/ setError(char *, ...);
char *strchr(char const *, char);
int parse_vfs_path(const char *path, const struct vfs **fs, const char **sub) {
  const char *e = strchr(path, ':');
  int len;
  if (!e) {
    setError("malformed path (no VFS specifier)");
    return 0;
  }
  len = e - path;
  *fs = find_vfs(path, len);
  if (!fs) {
    setError("unknown file system '%.*s'", len, path);
    return 0;
  }
  *sub = e + 1;
  return 1;
}


x86 assembly (clang, -O0):
<parse_vfs_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117b <parse_vfs_path+0x4b>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <setError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <parse_vfs_path+0xb1>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <find_vfs@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <parse_vfs_path+0x9b>
mov    -0x2c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <setError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <parse_vfs_path+0xb1>
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_vfs_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1171 <parse_vfs_path+0x41>
mov    %rax,%rbx
mov    %ebx,%esi
sub    %r12d,%esi
mov    %r12,%rdi
call   1050 <find_vfs@plt>
mov    %rax,(%r15)
add    $0x1,%rbx
mov    %rbx,(%r14)
mov    $0x1,%ebx
jmp    1181 <parse_vfs_path+0x51>
lea    0xe88(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <setError@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.vfs = type { i32 }
@.str = [34 x i8] c"malformed path (no VFS specifier)\00"
@.str.1 = [27 x i8] c"unknown file system '%.*s'\00"
define i32 @parse_vfs_path(i8* %0, %struct.vfs** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.vfs**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store %struct.vfs** %1, %struct.vfs*** %6
store i8** %2, i8*** %7
%10 = load i8*, i8** %5
%11 = call i8* @strchr(i8* %10, i8 signext 58)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %3
%15 = call i32 (i8*, ...) @setError(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %37
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = load i8*, i8** %5
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %9
%23 = load i8*, i8** %5
%24 = load i32, i32* %9
%25 = call %struct.vfs* @find_vfs(i8* %23, i32 %24)
%26 = load %struct.vfs**, %struct.vfs*** %6
store %struct.vfs* %25, %struct.vfs** %26
%27 = load %struct.vfs**, %struct.vfs*** %6
%28 = icmp ne %struct.vfs** %27, null
br i1 %28, label %33, label %29
29: ; preds = %16
%30 = load i32, i32* %9
%31 = load i8*, i8** %5
%32 = call i32 (i8*, ...) @setError(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31)
store i32 0, i32* %4
br label %37
33: ; preds = %16
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8**, i8*** %7
store i8* %35, i8** %36
store i32 1, i32* %4
br label %37
37: ; preds = %33, %29, %14
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
%struct.vfs = type { i32 }
@.str = [34 x i8] c"malformed path (no VFS specifier)\00"
define i32 @parse_vfs_path(i8* %0, %struct.vfs** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @setError(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %3
%9 = ptrtoint i8* %4 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = tail call %struct.vfs* @find_vfs(i8* %0, i32 %12)
store %struct.vfs* %13, %struct.vfs** %1
%14 = getelementptr inbounds i8, i8* %4, i64 1
store i8* %14, i8** %2
br label %15
15: ; preds = %8, %6
%16 = phi i32 [ 1, %8 ], [ 0, %6 ]
ret i32 %16
}