#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 *private_strdup(char const *);
char *strrchr(char const *, char);
char *lisys_path_fileext(const char *path) {
  const char *ptr0;
  const char *ptr1;
  ptr0 = strrchr(path, '.');
  ptr1 = strrchr(path, '/');
  if (ptr0 == NULL)
    return private_strdup("");
  if (ptr1 != NULL && ptr0 < ptr1)
    return private_strdup("");
  return private_strdup(ptr0 + 1);
}


x86 assembly (clang, -O0):
<lisys_path_fileext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1170 <lisys_path_fileext+0x50>
lea    0xe9e(%rip),%rdi
call   1030 <private_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11af <lisys_path_fileext+0x8f>
cmpq   $0x0,-0x20(%rbp)
je     119e <lisys_path_fileext+0x7e>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    119e <lisys_path_fileext+0x7e>
lea    0xe70(%rip),%rdi
call   1030 <private_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11af <lisys_path_fileext+0x8f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1030 <private_strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lisys_path_fileext>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %r14,%r14
je     1150 <lisys_path_fileext+0x30>
test   %rax,%rax
je     1159 <lisys_path_fileext+0x39>
cmp    %rax,%r14
jae    1159 <lisys_path_fileext+0x39>
lea    0xea9(%rip),%rdi
jmp    1160 <lisys_path_fileext+0x40>
add    $0x1,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <private_strdup@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @lisys_path_fileext(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strrchr(i8* %6, i8 signext 46)
store i8* %7, i8** %4
%8 = load i8*, i8** %3
%9 = call i8* @strrchr(i8* %8, i8 signext 47)
store i8* %9, i8** %5
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i8* @private_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %2
br label %27
14: ; preds = %1
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i8* @private_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %2
br label %27
23: ; preds = %17, %14
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i8* @private_strdup(i8* %25)
store i8* %26, i8** %2
br label %27
27: ; preds = %23, %21, %12
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @lisys_path_fileext(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i8* @private_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %16
7: ; preds = %1
%8 = icmp ne i8* %3, null
%9 = icmp ult i8* %2, %3
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i8* @private_strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %2, i64 1
%15 = tail call i8* @private_strdup(i8* %14)
br label %16
16: ; preds = %13, %11, %5
%17 = phi i8* [ %6, %5 ], [ %12, %11 ], [ %15, %13 ]
ret i8* %17
}