void *lbb_append(struct linear_bounded_buffer *lbb, void *data, int len) {
  char *dest = lbb_reserve(lbb, len);
  if (dest == ((void *)0))
    return ((void *)0);
  (__builtin_constant_p(len)
       ? __constant_copy_to_user_nocheck((dest), (data), (len))
       : __generic_copy_to_user_nocheck((dest), (data), (len)));
  return dest;
}


x86 assembly (clang, -O0):
<lbb_append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1040 <lbb_reserve@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115f <lbb_append+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    1179 <lbb_append+0x59>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x0,%al
call   1030 <__generic_copy_to_user_nocheck@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lbb_append>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
xor    %ebx,%ebx
mov    %edx,%esi
xor    %eax,%eax
call   1040 <lbb_reserve@plt>
test   %eax,%eax
je     114a <lbb_append+0x2a>
movslq %eax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <__generic_copy_to_user_nocheck@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.linear_bounded_buffer = type opaque
define i8* @lbb_append(%struct.linear_bounded_buffer* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.linear_bounded_buffer*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store %struct.linear_bounded_buffer* %0, %struct.linear_bounded_buffer** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load %struct.linear_bounded_buffer*, %struct.linear_bounded_buffer** %5
%10 = load i32, i32* %7
%11 = call i32 (%struct.linear_bounded_buffer*, i32, ...) bitcast (i32 (...)* @lbb_reserve to i32 (%struct.linear_bounded_buffer*, i32, ...)*)(%struct.linear_bounded_buffer* %9, i32 %10)
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %3
store i8* null, i8** %4
br label %33
17: ; preds = %3
%18 = load i32, i32* %7
%19 = call i1 @llvm.is.constant.i32(i32 %18)
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8*, i8** %8
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__constant_copy_to_user_nocheck to i32 (i8*, i8*, i32, ...)*)(i8* %21, i8* %22, i32 %23)
br label %30
25: ; preds = %17
%26 = load i8*, i8** %8
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__generic_copy_to_user_nocheck to i32 (i8*, i8*, i32, ...)*)(i8* %26, i8* %27, i32 %28)
br label %30
30: ; preds = %25, %20
%31 = phi i32 [ %24, %20 ], [ %29, %25 ]
%32 = load i8*, i8** %8
store i8* %32, i8** %4
br label %33
33: ; preds = %30, %16
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
%struct.linear_bounded_buffer = type opaque
define i8* @lbb_append(%struct.linear_bounded_buffer* %0, i8* %1, i32 %2) {
%4 = tail call i32 (%struct.linear_bounded_buffer*, i32, ...) bitcast (i32 (...)* @lbb_reserve to i32 (%struct.linear_bounded_buffer*, i32, ...)*)(%struct.linear_bounded_buffer* %0, i32 %2)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i32 %4, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__generic_copy_to_user_nocheck to i32 (i8*, i8*, i32, ...)*)(i8* %6, i8* %1, i32 %2)
br label %10
10: ; preds = %8, %3
%11 = phi i8* [ null, %3 ], [ %6, %8 ]
ret i8* %11
}