#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 */

/* Variables and functions */
char *malloc_wrap(size_t const);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *str_concat_wrap(const char *str1, const char *str2, const char *file,
                      unsigned int line) {
  const size_t len = strlen(str1) + strlen(str2) + 1;
  char *p, *str;
  p = str = malloc_wrap(len);
  strncpy(p, str1, strlen(str1));
  p += strlen(str1);
  strncpy(p, str2, strlen(str2));
  p += strlen(str2);
  *p = '\0';
  return str;
}


x86 assembly (clang, -O0):
<str_concat_wrap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <malloc_wrap@plt>
mov    %rax,-0x38(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_concat_wrap>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %r14d,%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1050 <malloc_wrap@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,(%rax,%rbx,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @str_concat_wrap(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
store i64 %18, i64* %9
%19 = load i64, i64* %9
%20 = call i8* @malloc_wrap(i64 %19)
store i8* %20, i8** %11
store i8* %20, i8** %10
%21 = load i8*, i8** %10
%22 = load i8*, i8** %5
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @strncpy(i8* %21, i8* %22, i32 %24)
%26 = load i8*, i8** %5
%27 = call i32 @strlen(i8* %26)
%28 = load i8*, i8** %10
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = load i8*, i8** %6
%33 = load i8*, i8** %6
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @strncpy(i8* %31, i8* %32, i32 %34)
%36 = load i8*, i8** %6
%37 = call i32 @strlen(i8* %36)
%38 = load i8*, i8** %10
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %10
%41 = load i8*, i8** %10
store i8 0, i8* %41
%42 = load i8*, i8** %11
ret i8* %42
}

LLVM IR (-O2):
define i8* @str_concat_wrap(i8* %0, i8* %1, i8* nocapture readnone %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = add i32 %5, 1
%8 = add i32 %7, %6
%9 = sext i32 %8 to i64
%10 = tail call i8* @malloc_wrap(i64 %9)
%11 = tail call i32 @strlen(i8* %0)
%12 = tail call i32 @strncpy(i8* %10, i8* %0, i32 %11)
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = tail call i32 @strlen(i8* %1)
%17 = tail call i32 @strncpy(i8* %15, i8* %1, i32 %16)
%18 = tail call i32 @strlen(i8* %1)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %15, i64 %19
store i8 0, i8* %20
ret i8* %10
}