__attribute__((no, noclone)) char *foo(char *p, char *r) {
  char buf[26];
  if (strlen(p) + strlen(r) + 9 > 26)
    return ((void *)0);
  strcpy(buf, p);
  strcat(buf, "/");
  strcat(buf, "abcde");
  strcat(buf, r);
  strcat(buf, "fg");
  return strdup(buf);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
add    $0x9,%rax
cmp    $0x1a,%rax
jbe    118b <foo+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    11e2 <foo+0xa2>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %rbx,%rax
add    $0xffffffffffffffee,%rax
cmp    $0xffffffffffffffe5,%rax
jae    1172 <foo+0x32>
xor    %eax,%eax
jmp    11ca <foo+0x8a>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movw   $0x2f,(%rsp,%rax,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
movl   $0x64636261,(%rsp,%rax,1)
movw   $0x65,0x4(%rsp,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movw   $0x6766,(%rsp,%rax,1)
movb   $0x0,0x2(%rsp,%rax,1)
mov    %r14,%rdi
call   1060 <strdup@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [6 x i8] c"abcde\00"
@.str.2 = [3 x i8] c"fg\00"
define i8* @foo(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [26 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = add i64 %8, %10
%12 = add i64 %11, 9
%13 = icmp ugt i64 %12, 26
br i1 %13, label %14, label %15
14: ; preds = %2
store i8* null, i8** %3
br label %30
15: ; preds = %2
%16 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i8* @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%20 = call i8* @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%22 = call i8* @strcat(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %5
%25 = call i8* @strcat(i8* %23, i8* %24)
%26 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%27 = call i8* @strcat(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%29 = call i8* @strdup(i8* %28)
store i8* %29, i8** %3
br label %30
30: ; preds = %15, %14
%31 = load i8*, i8** %3
ret i8* %31
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"abcde\00"
@.str.2 = [3 x i8] c"fg\00"
define noalias i8* @foo(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [26 x i8]
%4 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = add i64 %5, -18
%8 = add i64 %7, %6
%9 = icmp ult i64 %8, -27
br i1 %9, label %21, label %10
10: ; preds = %2
%11 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %0)
%12 = call i64 @strlen(i8* %4)
%13 = getelementptr [26 x i8], [26 x i8]* %3, i64 0, i64 %12
%14 = bitcast i8* %13 to i16*
store i16 47, i16* %14
%15 = call i64 @strlen(i8* %4)
%16 = getelementptr [26 x i8], [26 x i8]* %3, i64 0, i64 %15
%17 = call i8* @strcat(i8* %4, i8* dereferenceable(1) %1)
%18 = call i64 @strlen(i8* %4)
%19 = getelementptr [26 x i8], [26 x i8]* %3, i64 0, i64 %18
%20 = call i8* @strdup(i8* %4)
br label %21
21: ; preds = %2, %10
%22 = phi i8* [ %20, %10 ], [ null, %2 ]
ret i8* %22
}