void __attribute__((no, noclone)) test(char *data, long unsigned int len) {
  static char const appended[] = "/./";
  char *buf = __builtin_alloca(len + sizeof appended);
  __builtin_memcpy(buf, data, len);
  __builtin_strcpy(buf + len, &appended[data[len - 1] == '/']);
  if (__builtin_strcmp(buf, "test1234/./"))
    __builtin_abort();
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
add    $0x13,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rax
sub    %rcx,%rax
mov    %rax,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rdi
add    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
lea    0xe5a(%rip),%rsi
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11cc <test+0x8c>
call   1030 <abort@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rbx
lea    0x13(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <memcpy@plt>
xor    %eax,%eax
cmpb   $0x2f,-0x1(%r15,%r14,1)
lea    (%rbx,%r15,1),%rdi
sete   %al
lea    0xe7b(%rip),%rsi
add    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11ab <test+0x6b>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
call   1030 <abort@plt>

LLVM IR (-O0):
@test.appended = internal constant [4 x i8] c"/./\00"
@.str = [12 x i8] c"test1234/./\00"
define void @test(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = add i64 %6, 4
%8 = alloca i8, i64 %7
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i8*, i8** %3
%11 = load i64, i64* %4
%12 = load i8*, i8** %5
%13 = load i64, i64* %4
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8*, i8** %3
%16 = load i64, i64* %4
%17 = sub i64 %16, 1
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
%22 = zext i1 %21 to i32
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i8], [4 x i8]* @test.appended, i64 0, i64 %23
%25 = call i8* @strcpy(i8* %14, i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %2
unreachable
30: ; preds = %2
ret void
}

LLVM IR (-O2):
@test.appended = internal constant [4 x i8] c"/./\00"
@.str = [12 x i8] c"test1234/./\00"
define void @test(i8* nocapture %0, i64 %1) {
%3 = add i64 %1, 4
%4 = alloca i8, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 %1
%6 = add i64 %1, -1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 47
%10 = zext i1 %9 to i64
%11 = getelementptr inbounds [4 x i8], [4 x i8]* @test.appended, i64 0, i64 %10
%12 = call i8* @strcpy(i8* %5, i8* %11)
%13 = call i32 @strcmp(i8* %4, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %2
unreachable
16: ; preds = %2
ret void
}