#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 *__wxmalloc(size_t);
int /*<<< orphan*/ assert(char const *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
size_t strlen(char const *);
char *str_cat3(const char *str1, const char *str2, const char *str3) {
  assert(str1);
  assert(str2);
  assert(str3);
  size_t size1 = strlen(str1);
  size_t size2 = strlen(str2);
  size_t size3 = strlen(str3);
  char *newStr = __wxmalloc(size1 + size2 + size3 + 1);
  memcpy(newStr, str1, size1);
  memcpy(newStr + size1, str2, size2);
  memcpy(newStr + size1 + size2, str3, size3);
  newStr[size1 + size2 + size3] = 0;
  assert(newStr);
  return newStr;
}


x86 assembly (clang, -O0):
<str_cat3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
add    -0x28(%rbp),%rdi
add    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1030 <__wxmalloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rdi
add    -0x20(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_cat3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%r12
call   1050 <assert@plt>
mov    %rbp,%rdi
mov    %rbp,0x8(%rsp)
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r14,0x10(%rsp)
call   1050 <assert@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
lea    (%rbx,%r13,1),%r15
lea    (%rax,%r15,1),%rdi
add    $0x1,%rdi
add    %rax,%r15
call   1030 <__wxmalloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
add    %r14,%rbx
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %r13,%rdx
call   1060 <memcpy@plt>
add    %r13,%rbx
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
mov    %rbp,%rdx
call   1060 <memcpy@plt>
movb   $0x0,(%r14,%r15,1)
mov    %r14,%rdi
call   1050 <assert@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @str_cat3(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%11 = load i8*, i8** %4
%12 = call i32 @assert(i8* %11)
%13 = load i8*, i8** %5
%14 = call i32 @assert(i8* %13)
%15 = load i8*, i8** %6
%16 = call i32 @assert(i8* %15)
%17 = load i8*, i8** %4
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %7
%19 = load i8*, i8** %5
%20 = call i64 @strlen(i8* %19)
store i64 %20, i64* %8
%21 = load i8*, i8** %6
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %9
%23 = load i64, i64* %7
%24 = load i64, i64* %8
%25 = add i64 %23, %24
%26 = load i64, i64* %9
%27 = add i64 %25, %26
%28 = add i64 %27, 1
%29 = call i8* @__wxmalloc(i64 %28)
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = load i8*, i8** %4
%32 = load i64, i64* %7
%33 = call i32 @memcpy(i8* %30, i8* %31, i64 %32)
%34 = load i8*, i8** %10
%35 = load i64, i64* %7
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8*, i8** %5
%38 = load i64, i64* %8
%39 = call i32 @memcpy(i8* %36, i8* %37, i64 %38)
%40 = load i8*, i8** %10
%41 = load i64, i64* %7
%42 = getelementptr inbounds i8, i8* %40, i64 %41
%43 = load i64, i64* %8
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8*, i8** %6
%46 = load i64, i64* %9
%47 = call i32 @memcpy(i8* %44, i8* %45, i64 %46)
%48 = load i8*, i8** %10
%49 = load i64, i64* %7
%50 = load i64, i64* %8
%51 = add i64 %49, %50
%52 = load i64, i64* %9
%53 = add i64 %51, %52
%54 = getelementptr inbounds i8, i8* %48, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %10
%56 = call i32 @assert(i8* %55)
%57 = load i8*, i8** %10
ret i8* %57
}

LLVM IR (-O2):
define i8* @str_cat3(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @assert(i8* %1)
%6 = tail call i32 @assert(i8* %2)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%10 = add i64 %8, %7
%11 = add i64 %10, %9
%12 = add i64 %11, 1
%13 = tail call i8* @__wxmalloc(i64 %12)
%14 = tail call i32 @memcpy(i8* %13, i8* %0, i64 %7)
%15 = getelementptr inbounds i8, i8* %13, i64 %7
%16 = tail call i32 @memcpy(i8* %15, i8* %1, i64 %8)
%17 = getelementptr inbounds i8, i8* %15, i64 %8
%18 = tail call i32 @memcpy(i8* %17, i8* %2, i64 %9)
%19 = getelementptr inbounds i8, i8* %13, i64 %11
store i8 0, i8* %19
%20 = tail call i32 @assert(i8* %13)
ret i8* %13
}