#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 */
scalar_t__ strlen(char const *);
char *strrchr(char const *, char);
char *FN_get_extension_imp(const char *fname_or_path) {
  char *dot;
  char *sep;
  if (!fname_or_path || strlen(fname_or_path) == 0)
    return 0;
  dot = strrchr(fname_or_path, '.');
  if (!dot)
    return 0;
  sep = strrchr(fname_or_path, '/');
  if (!sep)
    return dot;
  if (sep < dot)
    return dot;
  return 0;
}


x86 assembly (clang, -O0):
<FN_get_extension_imp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114a <FN_get_extension_imp+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1157 <FN_get_extension_imp+0x37>
movq   $0x0,-0x8(%rbp)
jmp    11ce <FN_get_extension_imp+0xae>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <FN_get_extension_imp+0x61>
movq   $0x0,-0x8(%rbp)
jmp    11ce <FN_get_extension_imp+0xae>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ab <FN_get_extension_imp+0x8b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ce <FN_get_extension_imp+0xae>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c6 <FN_get_extension_imp+0xa6>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ce <FN_get_extension_imp+0xae>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FN_get_extension_imp>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1153 <FN_get_extension_imp+0x43>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1153 <FN_get_extension_imp+0x43>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1153 <FN_get_extension_imp+0x43>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1156 <FN_get_extension_imp+0x46>
xor    %ecx,%ecx
cmp    %r14,%rax
cmovae %rcx,%r14
jmp    1156 <FN_get_extension_imp+0x46>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @FN_get_extension_imp(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 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8, %1
store i8* null, i8** %2
br label %33
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i8* @strrchr(i8* %14, i8 signext 46)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %13
store i8* null, i8** %2
br label %33
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = call i8* @strrchr(i8* %20, i8 signext 47)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %33
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = load i8*, i8** %4
%29 = icmp ult i8* %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %33
32: ; preds = %26
store i8* null, i8** %2
br label %33
33: ; preds = %32, %30, %24, %18, %12
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
define i8* @FN_get_extension_imp(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i8* @strrchr(i8* %0, i8 signext 47)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = icmp ult i8* %10, %7
%14 = select i1 %13, i8* %7, i8* null
br label %15
15: ; preds = %12, %9, %6, %1, %3
%16 = phi i8* [ null, %3 ], [ null, %1 ], [ null, %6 ], [ %7, %9 ], [ %14, %12 ]
ret i8* %16
}