int equivalent(lname, rname)
char *lname;
char *rname;
{
  char *s;
  if (!strcmp(lname, rname))
    return 1;
  for (s = lname; *s && (s = strchr(s, '/')); s++) {
    while (s[1] == '/')
      strcpy(s + 1, s + 2);
  }
  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    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1162 <equivalent+0x32>
movl   $0x1,-0x4(%rbp)
jmp    120e <equivalent+0xde>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     119b <equivalent+0x6b>
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ab <equivalent+0x7b>
jmp    11f1 <equivalent+0xc1>
jmp    11b0 <equivalent+0x80>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11db <equivalent+0xab>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
jmp    11b0 <equivalent+0x80>
jmp    11e0 <equivalent+0xb0>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116a <equivalent+0x3a>
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   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strcmp@plt>
test   %eax,%eax
je     11ba <equivalent+0x8a>
cmpb   $0x0,(%r15)
je     11a4 <equivalent+0x74>
mov    %r15,%rbx
jmp    1164 <equivalent+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %al,%al
je     11a4 <equivalent+0x74>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a4 <equivalent+0x74>
mov    %rax,%r12
lea    0x1(%rax),%rbx
mov    0x1(%rax),%al
cmp    $0x2f,%al
jne    1160 <equivalent+0x30>
add    $0x2,%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     1190 <equivalent+0x60>
jmp    1160 <equivalent+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
jmp    11bf <equivalent+0x8f>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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