#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 strlen(char const *);
const char *COM_GetExtension(const char *name) {
  int length, i;
  length = strlen(name) - 1;
  i = length;
  while (name[i] != '.') {
    i--;
    if (name[i] == '/' || i == 0)
      return "";
  }
  return &name[i + 1];
}


x86 assembly (clang, -O0):
<COM_GetExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     1183 <COM_GetExtension+0x73>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     116e <COM_GetExtension+0x5e>
cmpl   $0x0,-0x18(%rbp)
jne    117e <COM_GetExtension+0x6e>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1197 <COM_GetExtension+0x87>
jmp    1131 <COM_GetExtension+0x21>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_GetExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    -0x1(%rax),%ecx
movslq %ecx,%rsi
mov    (%r14,%rsi,1),%bl
lea    (%r14,%rsi,1),%r9
add    $0xffffffffffffffff,%r9
shl    $0x20,%rsi
movabs $0x100000000,%rcx
add    %rsi,%rcx
mov    $0x2,%esi
sub    %eax,%esi
xor    %edi,%edi
movabs $0xffffffff00000000,%r8
ff ff ff
lea    0xea7(%rip),%rax
nopl   0x0(%rax)
cmp    $0x2e,%bl
je     117f <COM_GetExtension+0x6f>
movzbl (%r9,%rdi,1),%ebx
cmp    $0x2f,%bl
je     1189 <COM_GetExtension+0x79>
add    %r8,%rcx
lea    -0x1(%rdi),%rdx
cmp    %edi,%esi
mov    %rdx,%rdi
jne    1160 <COM_GetExtension+0x50>
jmp    1189 <COM_GetExtension+0x79>
sar    $0x20,%rcx
add    %rcx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @COM_GetExtension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %4
%9 = load i32, i32* %4
store i32 %9, i32* %5
br label %10
10: ; preds = %32, %1
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 46
br i1 %17, label %18, label %33
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 47
br i1 %27, label %31, label %28
28: ; preds = %18
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28, %18
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %39
32: ; preds = %28
br label %10
33: ; preds = %10
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8* %38, i8** %2
br label %39
39: ; preds = %33, %31
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @COM_GetExtension(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
br label %7
7: ; preds = %11, %1
%8 = phi i8 [ %14, %11 ], [ %6, %1 ]
%9 = phi i64 [ %12, %11 ], [ %4, %1 ]
%10 = icmp eq i8 %8, 46
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = add nsw i64 %9, -1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 47
%16 = trunc i64 %12 to i32
%17 = icmp eq i32 %16, 0
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %24, label %7
19: ; preds = %7
%20 = shl i64 %9, 32
%21 = add i64 %20, 4294967296
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds i8, i8* %0, i64 %22
br label %24
24: ; preds = %11, %19
%25 = phi i8* [ %23, %19 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %11 ]
ret i8* %25
}