char *COM_FileExtension(char *in) {
  static char exten[8];
  int i;
  while (*in && *in != '.')
    in++;
  if (!*in)
    return "";
  in++;
  for (i = 0; i < 7 && *in; i++, in++)
    exten[i] = *in;
  exten[i] = 0;
  return exten;
}


x86 assembly (clang, -O0):
<COM_FileExtension>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     112d <COM_FileExtension+0x2d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    113d <COM_FileExtension+0x3d>
jmp    114e <COM_FileExtension+0x4e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1108 <COM_FileExtension+0x8>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116b <COM_FileExtension+0x6b>
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f5 <COM_FileExtension+0xf5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x7,-0x14(%rbp)
mov    %al,-0x16(%rbp)
jge    119d <COM_FileExtension+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    11ad <COM_FileExtension+0xad>
jmp    11db <COM_FileExtension+0xdb>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
movslq -0x14(%rbp),%rcx
lea    0x2e63(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117e <COM_FileExtension+0x7e>
movslq -0x14(%rbp),%rcx
lea    0x2e3b(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e30(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_FileExtension>:
add    $0x7,%rdi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl -0x7(%rdi),%eax
test   %al,%al
je     1122 <COM_FileExtension+0x22>
cmp    $0x2e,%al
je     112a <COM_FileExtension+0x2a>
add    $0x1,%rdi
jmp    1110 <COM_FileExtension+0x10>
lea    0xed7(%rip),%rax
ret
mov    -0x6(%rdi),%al
test   %al,%al
je     118b <COM_FileExtension+0x8b>
mov    %al,0x2eea(%rip)
mov    -0x5(%rdi),%al
test   %al,%al
je     118f <COM_FileExtension+0x8f>
mov    %al,0x2ede(%rip)
mov    -0x4(%rdi),%al
test   %al,%al
je     1196 <COM_FileExtension+0x96>
mov    %al,0x2ed2(%rip)
mov    -0x3(%rdi),%al
test   %al,%al
je     119d <COM_FileExtension+0x9d>
mov    %al,0x2ec6(%rip)
mov    -0x2(%rdi),%al
test   %al,%al
je     11a4 <COM_FileExtension+0xa4>
mov    %al,0x2eba(%rip)
mov    -0x1(%rdi),%al
test   %al,%al
je     11ab <COM_FileExtension+0xab>
mov    %al,0x2eae(%rip)
mov    (%rdi),%al
test   %al,%al
je     11b2 <COM_FileExtension+0xb2>
mov    %al,0x2ea3(%rip)
mov    $0x7,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
xor    %ecx,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x1,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x2,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x3,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x4,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x5,%ecx
jmp    11b7 <COM_FileExtension+0xb7>
mov    $0x6,%ecx
lea    0x2e63(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
ret

LLVM IR (-O0):
@COM_FileExtension.exten = internal global [8 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @COM_FileExtension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
br label %5
5: ; preds = %17, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 46
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %5
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %20
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %53
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
store i32 0, i32* %4
br label %28
28: ; preds = %44, %25
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 7
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br label %36
36: ; preds = %31, %28
%37 = phi i1 [ false, %28 ], [ %35, %31 ]
br i1 %37, label %38, label %49
38: ; preds = %36
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %38
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
br label %28
49: ; preds = %36
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 %51
store i8 0, i8* %52
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 0), i8** %2
br label %53
53: ; preds = %49, %24
%54 = load i8*, i8** %2
ret i8* %54
}

LLVM IR (-O2):
@COM_FileExtension.exten = internal global [8 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @COM_FileExtension(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %10, %9 ]
%4 = load i8, i8* %3
switch i8 %4, label %9 [
i8 0, label %39
i8 46, label %5
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %36, label %11
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %5
store i8 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 0)
%12 = getelementptr inbounds i8, i8* %3, i64 2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %36, label %15
15: ; preds = %11
store i8 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 1)
%16 = getelementptr inbounds i8, i8* %3, i64 3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %36, label %19
19: ; preds = %15
store i8 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 2)
%20 = getelementptr inbounds i8, i8* %3, i64 4
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %36, label %23
23: ; preds = %19
store i8 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 3)
%24 = getelementptr inbounds i8, i8* %3, i64 5
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %23
store i8 %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 4)
%28 = getelementptr inbounds i8, i8* %3, i64 6
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %27
store i8 %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 5)
%32 = getelementptr inbounds i8, i8* %3, i64 7
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31
store i8 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 6)
br label %36
36: ; preds = %35, %31, %27, %23, %19, %15, %11, %5
%37 = phi i64 [ 0, %5 ], [ 1, %11 ], [ 2, %15 ], [ 3, %19 ], [ 4, %23 ], [ 5, %27 ], [ 6, %31 ], [ 7, %35 ]
%38 = getelementptr inbounds [8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %2, %36
%40 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @COM_FileExtension.exten, i64 0, i64 0), %36 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %40
}