#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*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int strlen(char *);
char *fmtname(char *path) {
  static char buf[14 + 1];
  char *p;
  for (p = path + strlen(path); p >= path && *p != '/'; p--)
    ;
  p++;
  if (strlen(p) >= 14)
    return p;
  memmove(buf, p, strlen(p));
  memset(buf + strlen(p), '\0', 14 - strlen(p));
  return buf;
}


x86 assembly (clang, -O0):
<fmtname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     1180 <fmtname+0x50>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1190 <fmtname+0x60>
jmp    11a6 <fmtname+0x76>
jmp    1195 <fmtname+0x65>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    115d <fmtname+0x2d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xe,%eax
jl     11d1 <fmtname+0xa1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1234 <fmtname+0x104>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0x2e4a(%rip),%rdi
call   1050 <memmove@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    0x2e32(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    $0xe,%edx
sub    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x2e09(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmtname>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
test   %eax,%eax
js     115e <fmtname+0x2e>
nopw   0x0(%rax,%rax,1)
cmpb   $0x2f,(%rbx)
je     115e <fmtname+0x2e>
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jae    1150 <fmtname+0x20>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xd,%eax
jg     11b5 <fmtname+0x85>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x2ebb(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%r15
add    %r14,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0xe,%edx
sub    %eax,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@fmtname.buf = internal global [15 x i8] zeroinitializer
define i8* @fmtname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %4
br label %10
10: ; preds = %22, %1
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp uge i8* %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 47
br label %19
19: ; preds = %14, %10
%20 = phi i1 [ false, %10 ], [ %18, %14 ]
br i1 %20, label %21, label %25
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
br label %10
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = call i32 @strlen(i8* %28)
%30 = icmp sge i32 %29, 14
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i8*, i8** %4
store i8* %32, i8** %2
br label %46
33: ; preds = %25
%34 = load i8*, i8** %4
%35 = load i8*, i8** %4
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @memmove(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 0), i8* %34, i32 %36)
%38 = load i8*, i8** %4
%39 = call i32 @strlen(i8* %38)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 0), i64 %40
%42 = load i8*, i8** %4
%43 = call i32 @strlen(i8* %42)
%44 = sub nsw i32 14, %43
%45 = call i32 @memset(i8* %41, i8 signext 0, i32 %44)
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 0), i8** %2
br label %46
46: ; preds = %33, %31
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@fmtname.buf = internal global [15 x i8] zeroinitializer
define i8* @fmtname(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp slt i32 %2, 0
br i1 %5, label %13, label %6
6: ; preds = %1, %10
%7 = phi i8* [ %11, %10 ], [ %4, %1 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 47
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 -1
%12 = icmp ult i8* %11, %0
br i1 %12, label %13, label %6
13: ; preds = %6, %10, %1
%14 = phi i8* [ %4, %1 ], [ %11, %10 ], [ %7, %6 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = tail call i32 @strlen(i8* %15)
%17 = icmp sgt i32 %16, 13
br i1 %17, label %27, label %18
18: ; preds = %13
%19 = tail call i32 @strlen(i8* %15)
%20 = tail call i32 @memmove(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 0), i8* %15, i32 %19)
%21 = tail call i32 @strlen(i8* %15)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 %22
%24 = tail call i32 @strlen(i8* %15)
%25 = sub nsw i32 14, %24
%26 = tail call i32 @memset(i8* %23, i8 signext 0, i32 %25)
br label %27
27: ; preds = %13, %18
%28 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @fmtname.buf, i64 0, i64 0), %18 ], [ %15, %13 ]
ret i8* %28
}