#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 *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strrchr(char const *, char);
void make_shortname(char *dest, const char *src) {
  char *ext;
  const char *slash;
  slash = strrchr(src, '/') ?: src - 1;
  strcpy(dest, slash + 1);
  ext = strchr(dest, '.');
  if (ext)
    *ext = '\0';
}


x86 assembly (clang, -O0):
<make_shortname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1169 <make_shortname+0x39>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1175 <make_shortname+0x45>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b2 <make_shortname+0x82>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_shortname>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
add    $0xffffffffffffffff,%rbx
test   %rax,%rax
cmovne %rax,%rbx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1176 <make_shortname+0x46>
movb   $0x0,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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