#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 *);
char *strstr(char const *, char const *);
int is_self_copy(const char *src, const char *dest) {
  char c;
  char *sub = strstr(dest, src);
  if (sub) {
    c = sub[strlen(src)];
    return c == '\0' || c == '/' || src[strlen(src) - 1] == '/';
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<is_self_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ca <is_self_copy+0xaa>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11ba <is_self_copy+0x9a>
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x29(%rbp)
je     11ba <is_self_copy+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <is_self_copy+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_self_copy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     116d <is_self_copy+0x4d>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
mov    (%rbx,%rax,1),%cl
mov    $0x1,%eax
test   %cl,%cl
je     116f <is_self_copy+0x4f>
cmp    $0x2f,%cl
je     116f <is_self_copy+0x4f>
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
xor    %eax,%eax
cmpb   $0x2f,-0x1(%rcx,%r14,1)
sete   %al
jmp    116f <is_self_copy+0x4f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @is_self_copy(i8* %0, i8* %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %3, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 47, label %18
i8 0, label %18
]
10: ; preds = %5
%11 = tail call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %2, %10, %5, %5
%19 = phi i32 [ 1, %5 ], [ %17, %10 ], [ 1, %5 ], [ 0, %2 ]
ret i32 %19
}