#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*/ strcmp(char const *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int match_path(char *dir, const char *mountpoint) {
  int n = strlen(mountpoint);
  int m = strlen(dir);
  if (!strcmp(mountpoint, "/") || !strcmp(mountpoint, dir))
    return 1;
  if (n > m)
    return 0;
  if (!strncmp(dir, mountpoint, n) && dir[n] == '/')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<match_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     1187 <match_path+0x57>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1193 <match_path+0x63>
movl   $0x1,-0x4(%rbp)
jmp    11ec <match_path+0xbc>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11ab <match_path+0x7b>
movl   $0x0,-0x4(%rbp)
jmp    11ec <match_path+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e5 <match_path+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11e5 <match_path+0xb5>
movl   $0x1,-0x4(%rbp)
jmp    11ec <match_path+0xbc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    0xea5(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
mov    $0x1,%r15d
test   %eax,%eax
je     119f <match_path+0x6f>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     119f <match_path+0x6f>
cmp    %r12d,%r14d
jg     119c <match_path+0x6c>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    119c <match_path+0x6c>
movslq %r14d,%rax
cmpb   $0x2f,(%rbx,%rax,1)
je     119f <match_path+0x6f>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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