#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 *__imlib_FileRealFile(char const *);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
char *strrchr(char const *, char);
char *__imlib_FileExtension(const char *file) {
  char *p;
  char *fl;
  fl = __imlib_FileRealFile(file);
  if (!fl)
    return strdup("");
  p = strrchr(file, '.');
  if (p) {
    char *ret;
    ret = strdup(p + 1);
    free(fl);
    return ret;
  }
  free(fl);
  return strdup("");
}


x86 assembly (clang, -O0):
<__imlib_FileExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <__imlib_FileRealFile@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1179 <__imlib_FileExtension+0x39>
lea    0xe95(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11d6 <__imlib_FileExtension+0x96>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11bd <__imlib_FileExtension+0x7d>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d6 <__imlib_FileExtension+0x96>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xe33(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__imlib_FileExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <__imlib_FileRealFile@plt>
test   %rax,%rax
je     1190 <__imlib_FileExtension+0x50>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1188 <__imlib_FileExtension+0x48>
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe69(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <strdup@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @__imlib_FileExtension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @__imlib_FileRealFile(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %1
%12 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %2
br label %29
13: ; preds = %1
%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 %18, label %25
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i8* @strdup(i8* %20)
store i8* %21, i8** %6
%22 = load i8*, i8** %5
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %6
store i8* %24, i8** %2
br label %29
25: ; preds = %13
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
%28 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %2
br label %29
29: ; preds = %25, %18, %11
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define noalias i8* @__imlib_FileExtension(i8* %0) {
%2 = tail call i8* @__imlib_FileRealFile(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %16
6: ; preds = %1
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i8* @strdup(i8* %10)
%12 = tail call i32 @free(i8* %2)
br label %16
13: ; preds = %6
%14 = tail call i32 @free(i8* %2)
%15 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %9, %4
%17 = phi i8* [ %11, %9 ], [ %15, %13 ], [ %5, %4 ]
ret i8* %17
}