#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 strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
scalar_t__ strstr(char const *, char *);
int points_within_and_visible(const char *target, const char *root) {
  int tlen = strlen(target);
  int rlen = strlen(root);
  if (rlen > tlen)
    return 0;
  if (strncmp(target, root, rlen))
    return 0;
  if (target[rlen] != '/' && target[rlen] != '\0')
    return 0;
  if (strstr(target + rlen, "/."))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<points_within_and_visible>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1170 <points_within_and_visible+0x40>
movl   $0x0,-0x4(%rbp)
jmp    1200 <points_within_and_visible+0xd0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1196 <points_within_and_visible+0x66>
movl   $0x0,-0x4(%rbp)
jmp    1200 <points_within_and_visible+0xd0>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     11cc <points_within_and_visible+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11cc <points_within_and_visible+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    1200 <points_within_and_visible+0xd0>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
lea    0xe22(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11f9 <points_within_and_visible+0xc9>
movl   $0x0,-0x4(%rbp)
jmp    1200 <points_within_and_visible+0xd0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<points_within_and_visible>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1040 <strlen@plt>
xor    %r14d,%r14d
cmp    %ebp,%eax
jg     1194 <points_within_and_visible+0x64>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1194 <points_within_and_visible+0x64>
movslq %ebx,%rax
mov    (%r15,%rax,1),%cl
cmp    $0x2f,%cl
je     1178 <points_within_and_visible+0x48>
test   %cl,%cl
jne    1194 <points_within_and_visible+0x64>
add    %rax,%r15
lea    0xe7e(%rip),%rsi
mov    %r15,%rdi
call   1050 <strstr@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"/.\00"
define i32 @points_within_and_visible(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp sgt i32 %4, %3
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = sext i32 %4 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %17 [
i8 47, label %13
i8 0, label %13
]
13: ; preds = %9, %9
%14 = tail call i64 @strstr(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %9, %6, %2
%18 = phi i32 [ 0, %2 ], [ 0, %6 ], [ 0, %9 ], [ %16, %13 ]
ret i32 %18
}