char *fatstoragename(const char *name) {
  char *dst, *start;
  dst = malloc(strlen(name) + 1);
  start = _fatstoragepart(&dst, &name);
  if (*dst == '/')
    printf("WARNING: path passed as file to %s()\n", __func__);
  return start;
}


x86 assembly (clang, -O0):
<fatstoragename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <_fatstoragepart@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    119f <fatstoragename+0x5f>
lea    0xe6f(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fatstoragename>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <_fatstoragepart@plt>
mov    %eax,%ebx
mov    (%rsp),%rax
cmpb   $0x2f,(%rax)
jne    118b <fatstoragename+0x4b>
lea    0xe83(%rip),%rdi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"WARNING: path passed as file to %s()\0A\00"
@__func__.fatstoragename = [15 x i8] c"fatstoragename\00"
define i8* @fatstoragename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
%7 = add i64 %6, 1
%8 = call i8* @malloc(i64 %7)
store i8* %8, i8** %3
%9 = call i32 (i8**, i8**, ...) bitcast (i32 (...)* @_fatstoragepart to i32 (i8**, i8**, ...)*)(i8** %3, i8** %2)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 47
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.fatstoragename, i64 0, i64 0))
br label %18
18: ; preds = %16, %1
%19 = load i8*, i8** %4
ret i8* %19
}

LLVM IR (-O2):
@.str = [38 x i8] c"WARNING: path passed as file to %s()\0A\00"
@__func__.fatstoragename = [15 x i8] c"fatstoragename\00"
define i8* @fatstoragename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = bitcast i8** %3 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add i64 %5, 1
%7 = tail call i8* @malloc(i64 %6)
store i8* %7, i8** %3
%8 = call i32 (i8**, i8**, ...) bitcast (i32 (...)* @_fatstoragepart to i32 (i8**, i8**, ...)*)(i8** %3, i8** %2)
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.fatstoragename, i64 0, i64 0))
br label %14
14: ; preds = %12, %1
%15 = sext i32 %8 to i64
%16 = inttoptr i64 %15 to i8*
ret i8* %16
}