#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 strcasecmp(char *, char *);
int strlen(char *);
int filename_cmp(char *left, char *right) {
  int rlen, llen;
  char llast, rlast;
  llen = strlen(left) - 1;
  rlen = strlen(right) - 1;
  llast = left[llen];
  rlast = right[rlen];
  if (llast == '/' && rlast == '/')
    return strcasecmp(left, right);
  else if (llast == '/')
    return -1;
  else if (rlast == '/')
    return 1;
  else
    return strcasecmp(left, right);
}


x86 assembly (clang, -O0):
<filename_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x22(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x2f,%eax
jne    1199 <filename_cmp+0x79>
movsbl -0x22(%rbp),%eax
cmp    $0x2f,%eax
jne    1199 <filename_cmp+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
jmp    11db <filename_cmp+0xbb>
movsbl -0x21(%rbp),%eax
cmp    $0x2f,%eax
jne    11b2 <filename_cmp+0x92>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <filename_cmp+0xbb>
movsbl -0x22(%rbp),%eax
cmp    $0x2f,%eax
jne    11cb <filename_cmp+0xab>
movl   $0x1,-0x4(%rbp)
jmp    11db <filename_cmp+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filename_cmp>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
mov    -0x1(%r15,%rbx,1),%dl
mov    -0x1(%rax,%r14,1),%al
cmp    $0x2f,%dl
jne    1150 <filename_cmp+0x30>
cmp    $0x2f,%al
je     115e <filename_cmp+0x3e>
xor    %ecx,%ecx
cmp    $0x2f,%dl
setne  %dl
je     116e <filename_cmp+0x4e>
cmp    $0x2f,%al
je     116e <filename_cmp+0x4e>
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcasecmp@plt>
mov    %dl,%cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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