#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 *strrchr(char const *, char);
const char *COM_GetExtension(const char *name) {
  const char *dot = strrchr(name, '.'), *slash;
  if (dot && (!(slash = strrchr(name, '/')) || slash < dot))
    return dot + 1;
  else
    return "";
}


x86 assembly (clang, -O0):
<COM_GetExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1174 <COM_GetExtension+0x64>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1163 <COM_GetExtension+0x53>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1174 <COM_GetExtension+0x64>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117f <COM_GetExtension+0x6f>
lea    0xe85(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_GetExtension>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x2e,%esi
call   1030 <strrchr@plt>
lea    0xed7(%rip),%r14
test   %rax,%rax
je     114f <COM_GetExtension+0x3f>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1148 <COM_GetExtension+0x38>
cmp    %rbx,%rax
jae    114f <COM_GetExtension+0x3f>
add    $0x1,%rbx
mov    %rbx,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @COM_GetExtension(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** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @strrchr(i8* %11, i8 signext 47)
store i8* %12, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i8*, i8** %4
%17 = icmp ult i8* %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14, %10
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %2
br label %22
21: ; preds = %14, %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
22: ; preds = %21, %18
%23 = load i8*, i8** %2
ret i8* %23
}

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