#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ VERSION;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ malloc(size_t const);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t const);
int /*<<< orphan*/ printf(char *, char *);
size_t strlen(char const *);
char *lti_version_information(const char *banner) {
  char VERSION[] = "LIB TO INTERFACE v0.2";
  const size_t ver_ret_len = sizeof(VERSION) + strlen(banner);
  char *ver_ret = (char *)malloc(ver_ret_len);
  assert(NULL != ver_ret);
  memset(ver_ret, 0, ver_ret_len);
  memcpy(ver_ret, banner, strlen(banner));
  memcpy(ver_ret + strlen(banner), VERSION, sizeof(VERSION));
  printf("allocated string %p\n", ver_ret);
  return ver_ret;
}


x86 assembly (clang, -O0):
<lti_version_information>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe88(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe82(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x16,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x16,%edx
call   1070 <memcpy@plt>
mov    -0x30(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lti_version_information>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x322e3076204543,%rax
mov    %rax,0xe(%rsp)
call   1030 <strlen@plt>
lea    0x16(%rax),%r15
mov    %r15,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1050 <memset@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rbx,1),%rdi
mov    %rsp,%rsi
mov    $0x16,%edx
call   1070 <memcpy@plt>
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.lti_version_information.VERSION = [22 x i8] c"LIB TO INTERFACE v0.2\00"
@.str = [21 x i8] c"allocated string %p\0A\00"
define i8* @lti_version_information(i8* %0) {
%2 = alloca i8*
%3 = alloca [22 x i8]
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
%6 = bitcast [22 x i8]* %3 to i8*
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add i64 22, %8
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* null, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %5
%18 = load i64, i64* %4
%19 = call i32 @memset(i8* %17, i32 0, i64 %18)
%20 = load i8*, i8** %5
%21 = load i8*, i8** %2
%22 = load i8*, i8** %2
%23 = call i64 @strlen(i8* %22)
%24 = trunc i64 %23 to i32
%25 = call i32 @memcpy(i8* %20, i8* %21, i32 %24)
%26 = load i8*, i8** %5
%27 = load i8*, i8** %2
%28 = call i64 @strlen(i8* %27)
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%31 = call i32 @memcpy(i8* %29, i8* %30, i32 22)
%32 = load i8*, i8** %5
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %5
ret i8* %34
}

LLVM IR (-O2):
@__const.lti_version_information.VERSION = [22 x i8] c"LIB TO INTERFACE v0.2\00"
@.str = [21 x i8] c"allocated string %p\0A\00"
define i8* @lti_version_information(i8* %0) {
%2 = alloca [22 x i8]
%3 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add i64 %4, 22
%6 = tail call i64 @malloc(i64 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp ne i64 %6, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @memset(i8* %7, i32 0, i64 %5)
%12 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%13 = trunc i64 %12 to i32
%14 = tail call i32 @memcpy(i8* %7, i8* %0, i32 %13)
%15 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%16 = getelementptr inbounds i8, i8* %7, i64 %15
%17 = call i32 @memcpy(i8* %16, i8* %3, i32 22)
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7)
ret i8* %7
}