const char *rawname(name) const char *name;
{
  static char rawbuf[32];
  const char *dp;
  if ((dp = strrchr(name, '/')) == 0)
    return (0);
  (void)snprintf(rawbuf, 32, "%.*s/r%s", (int)(dp - name), name, dp + 1);
  return (rawbuf);
}


x86 assembly (clang, -O0):
<rawname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1155 <rawname+0x35>
movq   $0x0,-0x8(%rbp)
jmp    1193 <rawname+0x73>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
add    $0x1,%r9
lea    0x2ecb(%rip),%rdi
mov    $0x20,%esi
lea    0xe7f(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2eb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rawname>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1163 <rawname+0x43>
mov    %eax,%ecx
sub    %ebx,%ecx
add    $0x1,%rax
lea    0x2efb(%rip),%r14
lea    0xeb4(%rip),%rdx
mov    $0x20,%esi
mov    %r14,%rdi
mov    %rbx,%r8
mov    %rax,%r9
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1166 <rawname+0x46>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@rawname.rawbuf = internal global [32 x i8] zeroinitializer
@.str = [9 x i8] c"%.*s/r%s\00"
define i8* @rawname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strrchr(i8* %5, i32 47)
store i8* %6, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* null, i8** %2
br label %20
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = trunc i64 %14 to i32
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i64 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %16, i8* %18)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %9, %8
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@rawname.rawbuf = internal global [32 x i8] zeroinitializer
@.str = [9 x i8] c"%.*s/r%s\00"
define i8* @rawname(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i32 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = ptrtoint i8* %2 to i64
%6 = ptrtoint i8* %0 to i64
%7 = sub i64 %5, %6
%8 = trunc i64 %7 to i32
%9 = getelementptr inbounds i8, i8* %2, i64 1
%10 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i64 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %0, i8* %9)
br label %11
11: ; preds = %1, %4
%12 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), %4 ], [ null, %1 ]
ret i8* %12
}