#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 *);
char *COM_FileExtension(const char *in) {
  const char *s, *last;
  last = s = in + strlen(in);
  while (s != in) {
    if (*s == '/') {
      break;
    }
    if (*s == '.') {
      return (char *)s;
    }
    s--;
  }
  return (char *)last;
}


x86 assembly (clang, -O0):
<COM_FileExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1192 <COM_FileExtension+0x82>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1164 <COM_FileExtension+0x54>
jmp    1192 <COM_FileExtension+0x82>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1181 <COM_FileExtension+0x71>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <COM_FileExtension+0x8a>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <COM_FileExtension+0x31>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_FileExtension>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    (%rbx,%rcx,1),%rax
test   %ecx,%ecx
je     1144 <COM_FileExtension+0x34>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx,%rcx,1),%edx
cmp    $0x2e,%dl
je     1146 <COM_FileExtension+0x36>
cmp    $0x2f,%dl
je     1144 <COM_FileExtension+0x34>
add    $0xffffffffffffffff,%rcx
jne    1130 <COM_FileExtension+0x20>
pop    %rbx
ret
add    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @COM_FileExtension(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp eq i32 %2, 0
br i1 %5, label %13, label %6
6: ; preds = %1, %9
%7 = phi i8* [ %10, %9 ], [ %4, %1 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 47, label %13
i8 46, label %12
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 -1
%11 = icmp eq i8* %10, %0
br i1 %11, label %13, label %6
12: ; preds = %6
br label %13
13: ; preds = %6, %9, %12, %1
%14 = phi i8* [ %4, %1 ], [ %7, %12 ], [ %4, %9 ], [ %4, %6 ]
ret i8* %14
}