char *rawname(name)
char *name;
{
  static char rawbuf[32];
  char *dp;
  if ((dp = (char *)rindex(name, '/')) == 0)
    return (0);
  *dp = 0;
  (void)strcpy(rawbuf, name);
  *dp = '/';
  (void)strcat(rawbuf, "/r");
  (void)strcat(rawbuf, &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 <rindex@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1165 <rawname+0x35>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <rawname+0x85>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
lea    0x2ed9(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x2f,(%rax)
lea    0x2ec6(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0x2eab(%rip),%rdi
call   1050 <strcat@plt>
lea    0x2e9f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rawname>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x2f,%esi
call   1050 <rindex@plt>
test   %rax,%rax
je     1198 <rawname+0x58>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x2eec(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
movb   $0x2f,(%rbx)
mov    %r14,%rdi
call   1040 <strlen@plt>
movw   $0x722f,(%rax,%r14,1)
movb   $0x0,0x2(%rax,%r14,1)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
jmp    119b <rawname+0x5b>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@rawname.rawbuf = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"/r\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* @rindex(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 %18
9: ; preds = %1
%10 = load i8*, i8** %4
store i8 0, i8* %10
%11 = load i8*, i8** %3
%12 = call i8* @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %4
store i8 47, i8* %13
%14 = call i8* @strcat(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = call i8* @strcat(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8* %16)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8** %2
br label %18
18: ; preds = %9, %8
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@rawname.rawbuf = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"/r\00"
define i8* @rawname(i8* %0) {
%2 = tail call i8* @rindex(i8* %0, i32 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1
store i8 0, i8* %2
%5 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8* dereferenceable(1) %0)
store i8 47, i8* %2
%6 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0))
%7 = getelementptr [32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 %6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %7, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
%8 = getelementptr inbounds i8, i8* %2, i64 1
%9 = tail call i8* @strcat(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %1, %4
%11 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @rawname.rawbuf, i64 0, i64 0), %4 ], [ null, %1 ]
ret i8* %11
}