#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*/ qe_pstrcpy(char *, int, char const *);
void *strrchr(char const *, char);
void getname(char *name, int name_size, const char *filename) {
  const char *p;
  char *q;
  p = strrchr(filename, '/');
  if (!p)
    p = filename;
  else
    p++;
  qe_pstrcpy(name, name_size, p);
  q = strrchr(name, '.');
  if (q)
    *q = '\0';
}


x86 assembly (clang, -O0):
<getname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115d <getname+0x3d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1169 <getname+0x49>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <qe_pstrcpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     119d <getname+0x7d>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getname>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%rbp
mov    %rdx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rdx
test   %rax,%rax
cmove  %rbx,%rdx
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <qe_pstrcpy@plt>
mov    %rbp,%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1165 <getname+0x45>
movb   $0x0,(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @getname(i8* %0, i32 %1, i8* %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %2, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %2, i8* %6
%8 = tail call i32 @qe_pstrcpy(i8* %0, i32 %1, i8* %7)
%9 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%10 = icmp eq i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %3
store i8 0, i8* %9
br label %12
12: ; preds = %11, %3
ret void
}