#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);
char *ext_pos(const char *file) {
  char *ext = strrchr(file, '.');
  char *slash = strrchr(file, '/');
  if (ext && (!slash || slash < ext) && ext != file && *(ext - 1) != '/')
    ext++;
  else
    ext = NULL;
  return ext;
}


x86 assembly (clang, -O0):
<ext_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1194 <ext_pos+0x84>
cmpq   $0x0,-0x18(%rbp)
je     1164 <ext_pos+0x54>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1194 <ext_pos+0x84>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     1194 <ext_pos+0x84>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
je     1194 <ext_pos+0x84>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    119c <ext_pos+0x8c>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext_pos>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rbx,%rbx
je     1160 <ext_pos+0x50>
test   %rax,%rax
setne  %cl
cmp    %rbx,%rax
setae  %dl
xor    %eax,%eax
test   %dl,%cl
jne    1162 <ext_pos+0x52>
cmp    %r14,%rbx
je     1162 <ext_pos+0x52>
mov    %rbx,%rcx
add    $0x1,%rcx
xor    %eax,%eax
cmpb   $0x2f,-0x1(%rbx)
cmovne %rcx,%rax
jmp    1162 <ext_pos+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @ext_pos(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %3
%7 = load i8*, i8** %2
%8 = call i8* @strrchr(i8* %7, i8 signext 47)
store i8* %8, i8** %4
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %31
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = load i8*, i8** %3
%17 = icmp ult i8* %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14, %11
%19 = load i8*, i8** %3
%20 = load i8*, i8** %2
%21 = icmp ne i8* %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 -1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 47
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
br label %32
31: ; preds = %22, %18, %14, %1
store i8* null, i8** %3
br label %32
32: ; preds = %31, %28
%33 = load i8*, i8** %3
ret i8* %33
}

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