#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*/ free(char *);
scalar_t__ ne_path_compare(char const *, char *);
char *ne_strdup(char const *);
size_t strlen(char const *);
int ne_path_childof(const char *parent, const char *child) {
  char *root = ne_strdup(child);
  int ret;
  if (strlen(parent) >= strlen(child)) {
    ret = 0;
  } else {
    root[strlen(parent)] = '\0';
    ret = (ne_path_compare(parent, root) == 0);
  }
  free(root);
  return ret;
}


x86 assembly (clang, -O0):
<ne_path_childof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ne_strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jb     118f <ne_path_childof+0x4f>
movl   $0x0,-0x1c(%rbp)
jmp    11c7 <ne_path_childof+0x87>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <ne_path_compare@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ne_path_childof>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <ne_strdup@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    %rax,%rbx
jae    118b <ne_path_childof+0x4b>
movb   $0x0,(%r15,%rbx,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <ne_path_compare@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ne_path_childof(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i8* @ne_strdup(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = icmp uge i64 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %6
br label %25
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = load i8*, i8** %3
%18 = call i64 @strlen(i8* %17)
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %3
%21 = load i8*, i8** %5
%22 = call i64 @ne_path_compare(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %6
br label %25
25: ; preds = %15, %14
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %6
ret i32 %28
}

LLVM IR (-O2):
define i32 @ne_path_childof(i8* %0, i8* %1) {
%3 = tail call i8* @ne_strdup(i8* %1)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = icmp ult i64 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 %4
store i8 0, i8* %8
%9 = tail call i64 @ne_path_compare(i8* %0, i8* %3)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %2, %7
%13 = phi i32 [ %11, %7 ], [ 0, %2 ]
%14 = tail call i32 @free(i8* %3)
ret i32 %13
}