#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 ct_path {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
struct ct_path *ct_path_alloc(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ct_path_free(struct ct_path *);
int ct_path_is_under_path(struct ct_path *, struct ct_path *);
void test_path_is_under_path(void) {
  struct ct_path *root = ct_path_alloc(NULL, "/my/root");
  struct ct_path *child = ct_path_alloc(NULL, "/my/root/some/child");
  struct ct_path *other = ct_path_alloc(NULL, "/some/other/path");
  struct ct_path *relative_root = ct_path_alloc(NULL, "my_root");
  struct ct_path *relative_child = ct_path_alloc(NULL, "my_root/some_child");
  assert(!ct_path_is_under_path(root, root));
  assert(ct_path_is_under_path(child, root));
  assert(!ct_path_is_under_path(root, child));
  assert(!ct_path_is_under_path(other, root));
  assert(ct_path_is_under_path(relative_child, relative_root));
  ct_path_free(relative_child);
  ct_path_free(relative_root);
  ct_path_free(other);
  ct_path_free(child);
  ct_path_free(root);
}


x86 assembly (clang, -O0):
<test_path_is_under_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
lea    0xead(%rip),%rsi
call   1060 <ct_path_alloc@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xea2(%rip),%rsi
call   1060 <ct_path_alloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xea2(%rip),%rsi
call   1060 <ct_path_alloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9f(%rip),%rsi
call   1060 <ct_path_alloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe93(%rip),%rsi
call   1060 <ct_path_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <ct_path_is_under_path@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <ct_path_is_under_path@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ct_path_is_under_path@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <ct_path_is_under_path@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <ct_path_is_under_path@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1030 <ct_path_free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <ct_path_free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ct_path_free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ct_path_free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ct_path_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_path_is_under_path>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%rsi
xor    %edi,%edi
call   1060 <ct_path_alloc@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rsi
xor    %edi,%edi
call   1060 <ct_path_alloc@plt>
mov    %rax,%r14
lea    0xeab(%rip),%rsi
xor    %edi,%edi
call   1060 <ct_path_alloc@plt>
mov    %rax,%r15
lea    0xeab(%rip),%rsi
xor    %edi,%edi
call   1060 <ct_path_alloc@plt>
mov    %rax,%r12
lea    0xea2(%rip),%rsi
xor    %edi,%edi
call   1060 <ct_path_alloc@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <ct_path_is_under_path@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <ct_path_is_under_path@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <ct_path_is_under_path@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <ct_path_is_under_path@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <ct_path_is_under_path@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %r13,%rdi
call   1030 <ct_path_free@plt>
mov    %r12,%rdi
call   1030 <ct_path_free@plt>
mov    %r15,%rdi
call   1030 <ct_path_free@plt>
mov    %r14,%rdi
call   1030 <ct_path_free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <ct_path_free@plt>

LLVM IR (-O0):
%struct.ct_path = type { i32 }
@.str = [9 x i8] c"/my/root\00"
@.str.1 = [20 x i8] c"/my/root/some/child\00"
@.str.2 = [17 x i8] c"/some/other/path\00"
@.str.3 = [8 x i8] c"my_root\00"
@.str.4 = [19 x i8] c"my_root/some_child\00"
define void @test_path_is_under_path() {
%1 = alloca %struct.ct_path*
%2 = alloca %struct.ct_path*
%3 = alloca %struct.ct_path*
%4 = alloca %struct.ct_path*
%5 = alloca %struct.ct_path*
%6 = call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store %struct.ct_path* %6, %struct.ct_path** %1
%7 = call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store %struct.ct_path* %7, %struct.ct_path** %2
%8 = call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store %struct.ct_path* %8, %struct.ct_path** %3
%9 = call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store %struct.ct_path* %9, %struct.ct_path** %4
%10 = call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
store %struct.ct_path* %10, %struct.ct_path** %5
%11 = load %struct.ct_path*, %struct.ct_path** %1
%12 = load %struct.ct_path*, %struct.ct_path** %1
%13 = call i32 @ct_path_is_under_path(%struct.ct_path* %11, %struct.ct_path* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load %struct.ct_path*, %struct.ct_path** %2
%19 = load %struct.ct_path*, %struct.ct_path** %1
%20 = call i32 @ct_path_is_under_path(%struct.ct_path* %18, %struct.ct_path* %19)
%21 = call i32 @assert(i32 %20)
%22 = load %struct.ct_path*, %struct.ct_path** %1
%23 = load %struct.ct_path*, %struct.ct_path** %2
%24 = call i32 @ct_path_is_under_path(%struct.ct_path* %22, %struct.ct_path* %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load %struct.ct_path*, %struct.ct_path** %3
%30 = load %struct.ct_path*, %struct.ct_path** %1
%31 = call i32 @ct_path_is_under_path(%struct.ct_path* %29, %struct.ct_path* %30)
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load %struct.ct_path*, %struct.ct_path** %5
%37 = load %struct.ct_path*, %struct.ct_path** %4
%38 = call i32 @ct_path_is_under_path(%struct.ct_path* %36, %struct.ct_path* %37)
%39 = call i32 @assert(i32 %38)
%40 = load %struct.ct_path*, %struct.ct_path** %5
%41 = call i32 @ct_path_free(%struct.ct_path* %40)
%42 = load %struct.ct_path*, %struct.ct_path** %4
%43 = call i32 @ct_path_free(%struct.ct_path* %42)
%44 = load %struct.ct_path*, %struct.ct_path** %3
%45 = call i32 @ct_path_free(%struct.ct_path* %44)
%46 = load %struct.ct_path*, %struct.ct_path** %2
%47 = call i32 @ct_path_free(%struct.ct_path* %46)
%48 = load %struct.ct_path*, %struct.ct_path** %1
%49 = call i32 @ct_path_free(%struct.ct_path* %48)
ret void
}

LLVM IR (-O2):
%struct.ct_path = type { i32 }
@.str = [9 x i8] c"/my/root\00"
@.str.1 = [20 x i8] c"/my/root/some/child\00"
@.str.2 = [17 x i8] c"/some/other/path\00"
@.str.3 = [8 x i8] c"my_root\00"
@.str.4 = [19 x i8] c"my_root/some_child\00"
define void @test_path_is_under_path() {
%1 = tail call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = tail call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call %struct.ct_path* @ct_path_alloc(i32* null, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @ct_path_is_under_path(%struct.ct_path* %1, %struct.ct_path* %1)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @ct_path_is_under_path(%struct.ct_path* %2, %struct.ct_path* %1)
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @ct_path_is_under_path(%struct.ct_path* %1, %struct.ct_path* %2)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @ct_path_is_under_path(%struct.ct_path* %3, %struct.ct_path* %1)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = tail call i32 @ct_path_is_under_path(%struct.ct_path* %5, %struct.ct_path* %4)
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @ct_path_free(%struct.ct_path* %5)
%23 = tail call i32 @ct_path_free(%struct.ct_path* %4)
%24 = tail call i32 @ct_path_free(%struct.ct_path* %3)
%25 = tail call i32 @ct_path_free(%struct.ct_path* %2)
%26 = tail call i32 @ct_path_free(%struct.ct_path* %1)
ret void
}