char *Test20(char *p, const char *in, unsigned n) {
  static char buf[10];
  __builtin___memcpy_chk(&buf[6], in, 5, __builtin_object_size(&buf[6], 0));
  __builtin___memcpy_chk(p, "abcde", n, __builtin_object_size(p, 0));
  __builtin___memcpy_chk(&buf[5], "abcde", 5,
                         __builtin_object_size(&buf[5], 0));
  __builtin___memcpy_chk(&buf[5], "abcde", n,
                         __builtin_object_size(&buf[5], 0));
  __builtin___memcpy_chk(&buf[6], "abcde", 5,
                         __builtin_object_size(&buf[6], 0));
  return buf;
}


x86 assembly (clang, -O0):
<Test20>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2efb(%rip),%rdi
add    $0x6,%rdi
mov    $0x5,%edx
mov    $0x4,%ecx
call   1030 <__memcpy_chk@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,%edx
lea    0xeaf(%rip),%rsi
mov    $0xffffffffffffffff,%rcx
call   1030 <__memcpy_chk@plt>
mov    0xe9d(%rip),%eax
mov    %eax,0x2ec5(%rip)
mov    0xe95(%rip),%al
mov    %al,0x2ebd(%rip)
mov    -0x14(%rbp),%eax
mov    %eax,%edx
lea    0x2ea8(%rip),%rdi
add    $0x5,%rdi
lea    0xe74(%rip),%rsi
mov    $0x5,%ecx
call   1030 <__memcpy_chk@plt>
lea    0x2e8c(%rip),%rdi
add    $0x6,%rdi
lea    0xe58(%rip),%rsi
mov    $0x5,%edx
mov    $0x4,%ecx
call   1030 <__memcpy_chk@plt>
lea    0x2e6b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Test20>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rdi,%rbx
lea    0x2f03(%rip),%r14
mov    $0x5,%edx
mov    $0x4,%ecx
mov    %r14,%rdi
call   1030 <__memcpy_chk@plt>
lea    0x2ee4(%rip),%r15
mov    %ebp,%ebp
lea    0xeaa(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
movl   $0x64636261,0x2ec8(%rip)
62 63 64
movb   $0x65,0x2ec5(%rip)
lea    0x2eba(%rip),%rdi
mov    $0x5,%ecx
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <__memcpy_chk@plt>
mov    $0x5,%edx
mov    $0x4,%ecx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <__memcpy_chk@plt>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@Test20.buf = internal global [10 x i8] zeroinitializer
@.str = [6 x i8] c"abcde\00"
define i8* @Test20(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %5
%8 = call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 6), i8* %7, i64 5, i64 4)
%9 = load i8*, i8** %4
%10 = load i32, i32* %6
%11 = zext i32 %10 to i64
%12 = load i8*, i8** %4
%13 = call i64 @llvm.objectsize.i64.p0i8(i8* %12, i1 false, i1 true, i1 false)
%14 = call i8* @__memcpy_chk(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %13)
%15 = load i32, i32* %6
%16 = zext i32 %15 to i64
%17 = call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 5), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %16, i64 5)
%18 = call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 6), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 4)
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@Test20.buf = internal global [10 x i8] zeroinitializer
@.str = [6 x i8] c"abcde\00"
define i8* @Test20(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 6), i8* %1, i64 5, i64 4)
%5 = zext i32 %2 to i64
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %5, i1 false)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 5), i8* align 1 dereferenceable(5) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i1 false)
%6 = tail call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 5), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %5, i64 5)
%7 = tail call i8* @__memcpy_chk(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 6), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 4)
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @Test20.buf, i64 0, i64 0)
}