#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 */
scalar_t__ strchr(char const *, char);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char const *, int);
int unfs_child_of(const char *child, const char *parent) {
  int clen = strlen(child);
  int plen = strlen(parent);
  if (clen <= plen)
    return 0;
  if (plen == 1)
    return (strchr(child + 1, '/') == 0);
  const char *s = child + plen;
  return (*s == '/' && !strncmp(child, parent, plen) && !strchr(s + 1, '/'));
}


x86 assembly (clang, -O0):
<unfs_child_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1170 <unfs_child_of+0x40>
movl   $0x0,-0x4(%rbp)
jmp    120d <unfs_child_of+0xdd>
cmpl   $0x1,-0x20(%rbp)
jne    11a0 <unfs_child_of+0x70>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    120d <unfs_child_of+0xdd>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x29(%rbp)
jne    1202 <unfs_child_of+0xd2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    1202 <unfs_child_of+0xd2>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unfs_child_of>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    %eax,%ebx
jle    118e <unfs_child_of+0x5e>
cmp    $0x1,%eax
jne    1173 <unfs_child_of+0x43>
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    118e <unfs_child_of+0x5e>
movslq %eax,%rbx
cmpb   $0x2f,(%r15,%rbx,1)
jne    118e <unfs_child_of+0x5e>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     119b <unfs_child_of+0x6b>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    %rbx,%r15
jmp    1157 <unfs_child_of+0x27>

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

LLVM IR (-O2):
define i32 @unfs_child_of(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp sgt i32 %3, %4
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = icmp eq i32 %4, 1
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = sext i32 %4 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 47
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13, %6
%17 = phi i8* [ %0, %6 ], [ %10, %13 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = tail call i64 @strchr(i8* %18, i8 signext 47)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %16, %8, %13, %2
%23 = phi i32 [ 0, %2 ], [ 0, %13 ], [ 0, %8 ], [ %21, %16 ]
ret i32 %23
}