#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 /*<<< orphan*/ strcmp(char const *, char *);
char *strrchr(char const *, char);
const char *suffix(const char *filename) {
  const char *p;
  if (!filename)
    return NULL;
  if (!strcmp(filename, "-"))
    return NULL;
  p = strrchr(filename, '.');
  if (!p)
    return NULL;
  return p + 1;
}


x86 assembly (clang, -O0):
<suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <suffix+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <suffix+0x80>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    116a <suffix+0x4a>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <suffix+0x80>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1194 <suffix+0x74>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <suffix+0x80>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suffix>:
push   %rbx
test   %rdi,%rdi
je     1156 <suffix+0x36>
mov    %rdi,%rbx
lea    0xed0(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1156 <suffix+0x36>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
add    $0x1,%rax
test   %rcx,%rcx
cmove  %rcx,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define i8* @suffix(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* null, i8** %2
br label %22
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8* null, i8** %2
br label %22
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i8* @strrchr(i8* %14, i8 signext 46)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %13
store i8* null, i8** %2
br label %22
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8* %21, i8** %2
br label %22
22: ; preds = %19, %18, %12, %7
%23 = load i8*, i8** %2
ret i8* %23
}

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