#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 strcoll(char *, char *);
char *strrchr(char *, char);
int themes_cmp(const void *a, const void *b) {
  int result;
  char *sa = *(char **)a;
  char *sb = *(char **)b;
  result = strcoll(strrchr(sa, '/') + 1, strrchr(sb, '/') + 1);
  if (result == 0)
    result = strcoll(sa, sb);
  return result;
}


x86 assembly (clang, -O0):
<themes_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
call   1040 <strcoll@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1197 <themes_cmp+0x77>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcoll@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<themes_cmp>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%r15
mov    (%rsi),%r14
mov    %r15,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rbx
mov    %r14,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rsi
mov    %rbx,%rdi
call   1040 <strcoll@plt>
test   %eax,%eax
je     115f <themes_cmp+0x3f>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strcoll@plt>

LLVM IR (-O0):
define i32 @themes_cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i8**
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to i8**
%13 = load i8*, i8** %12
store i8* %13, i8** %7
%14 = load i8*, i8** %6
%15 = call i8* @strrchr(i8* %14, i8 signext 47)
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %7
%18 = call i8* @strrchr(i8* %17, i8 signext 47)
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i32 @strcoll(i8* %16, i8* %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @strcoll(i8* %24, i8* %25)
store i32 %26, i32* %5
br label %27
27: ; preds = %23, %2
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @themes_cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i8**
%4 = load i8*, i8** %3
%5 = bitcast i8* %1 to i8**
%6 = load i8*, i8** %5
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %4, i8 signext 47)
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = tail call i8* @strrchr(i8* dereferenceable(1) %6, i8 signext 47)
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i32 @strcoll(i8* %8, i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @strcoll(i8* %4, i8* %6)
br label %15
15: ; preds = %13, %2
%16 = phi i32 [ %14, %13 ], [ %11, %2 ]
ret i32 %16
}