#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 */
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int equivalent(char *lname, char *rname, char **p) {
  char *s;
  if (!strcmp(lname, rname))
    return 1;
  for (s = lname; *s && (s = strchr(s, '/')); s++) {
    while (s[1] == '/') {
      strcpy(s + 1, s + 2);
      if (*p)
        (*p)--;
    }
  }
  return !strcmp(lname, rname);
}


x86 assembly (clang, -O0):
<equivalent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1166 <equivalent+0x36>
movl   $0x1,-0x4(%rbp)
jmp    122e <equivalent+0xfe>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     119f <equivalent+0x6f>
mov    -0x28(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11af <equivalent+0x7f>
jmp    1211 <equivalent+0xe1>
jmp    11b4 <equivalent+0x84>
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11fb <equivalent+0xcb>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    -0x28(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f6 <equivalent+0xc6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
jmp    11b4 <equivalent+0x84>
jmp    1200 <equivalent+0xd0>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116e <equivalent+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%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):
<equivalent>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strcmp@plt>
test   %eax,%eax
je     11cb <equivalent+0x9b>
cmpb   $0x0,(%r15)
je     11b5 <equivalent+0x85>
mov    %r15,%rbx
jmp    1164 <equivalent+0x34>
nopw   0x0(%rax,%rax,1)
test   %al,%al
je     11b5 <equivalent+0x85>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b5 <equivalent+0x85>
mov    %rax,%r13
lea    0x1(%rax),%rbx
mov    0x1(%rax),%al
cmp    $0x2f,%al
jne    1160 <equivalent+0x30>
add    $0x2,%r13
jmp    1197 <equivalent+0x67>
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
cmp    $0x2f,%al
jne    1160 <equivalent+0x30>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    (%r12),%rax
test   %rax,%rax
je     1190 <equivalent+0x60>
add    $0xffffffffffffffff,%rax
mov    %rax,(%r12)
jmp    1190 <equivalent+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
jmp    11d0 <equivalent+0xa0>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @equivalent(i8* %0, i8* nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %35, label %6
6: ; preds = %3
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %31, label %12
9: ; preds = %28, %16
%10 = phi i8 [ %18, %16 ], [ %29, %28 ]
%11 = icmp eq i8 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %6, %9
%13 = phi i8* [ %17, %9 ], [ %0, %6 ]
%14 = tail call i8* @strchr(i8* %13, i8 signext 47)
%15 = icmp eq i8* %14, null
br i1 %15, label %31, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 47
br i1 %19, label %20, label %9
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %14, i64 2
br label %22
22: ; preds = %20, %28
%23 = tail call i32 @strcpy(i8* %17, i8* %21)
%24 = load i8*, i8** %2
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %24, i64 -1
store i8* %27, i8** %2
br label %28
28: ; preds = %26, %22
%29 = load i8, i8* %17
%30 = icmp eq i8 %29, 47
br i1 %30, label %22, label %9
31: ; preds = %12, %9, %6
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %3, %31
%36 = phi i32 [ %34, %31 ], [ 1, %3 ]
ret i32 %36
}