#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 char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ _wperror(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ wcscat(char *, char const *);
int /*<<< orphan*/ wcscpy(char *, char const *);
size_t wcslen(char const *);
wchar_t *concat3(const wchar_t *s, const wchar_t *t, const wchar_t *u) {
  const wchar_t *sNotNull;
  const wchar_t *tNotNull;
  const wchar_t *uNotNull;
  wchar_t *result;
  size_t length;
  if (s == NULL) {
    sNotNull = L"";
  } else {
    sNotNull = s;
  }
  if (t == NULL) {
    tNotNull = L"";
  } else {
    tNotNull = t;
  }
  if (u == NULL) {
    uNotNull = L"";
  } else {
    uNotNull = u;
  }
  length = wcslen(sNotNull) + wcslen(tNotNull) + wcslen(uNotNull);
  result = (wchar_t *)malloc((length + 1) * sizeof(wchar_t));
  if (result != NULL) {
    wcscpy(result, sNotNull);
    wcscat(result, tNotNull);
    wcscat(result, uNotNull);
  } else {
    _wperror(L"concat3");
  }
  return result;
}


x86 assembly (clang, -O0):
<concat3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117f <concat3+0x2f>
lea    0xea6(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <concat3+0x37>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a2 <concat3+0x52>
lea    0xe83(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11aa <concat3+0x5a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c5 <concat3+0x75>
lea    0xe60(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11cd <concat3+0x7d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1254 <concat3+0x104>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <wcscpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <wcscat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <wcscat@plt>
jmp    1260 <concat3+0x110>
lea    0xda5(%rip),%rdi
call   1070 <_wperror@plt>
mov    -0x38(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concat3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
test   %rdi,%rdi
lea    0xeb6(%rip),%rax
cmove  %rax,%r12
mov    %rsi,%r15
test   %rsi,%rsi
cmove  %rax,%r15
mov    %rdx,%r14
test   %rdx,%rdx
cmove  %rax,%r14
mov    %r12,%rdi
call   1040 <wcslen@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1040 <wcslen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <wcslen@plt>
add    %r13,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d7 <concat3+0x87>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <wcscpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <wcscat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <wcscat@plt>
jmp    11e3 <concat3+0x93>
lea    0xe22(%rip),%rdi
call   1070 <_wperror@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i32] zeroinitializer
@.str.1 = [8 x i32] [i32 99, i32 111, i32 110, i32 99, i32 97, i32 116, i32 51, i32 0]
define i8* @concat3(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i8* bitcast ([1 x i32]* @.str to i8*), i8** %7
br label %17
15: ; preds = %3
%16 = load i8*, i8** %4
store i8* %16, i8** %7
br label %17
17: ; preds = %15, %14
%18 = load i8*, i8** %5
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17
store i8* bitcast ([1 x i32]* @.str to i8*), i8** %8
br label %23
21: ; preds = %17
%22 = load i8*, i8** %5
store i8* %22, i8** %8
br label %23
23: ; preds = %21, %20
%24 = load i8*, i8** %6
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %23
store i8* bitcast ([1 x i32]* @.str to i8*), i8** %9
br label %29
27: ; preds = %23
%28 = load i8*, i8** %6
store i8* %28, i8** %9
br label %29
29: ; preds = %27, %26
%30 = load i8*, i8** %7
%31 = call i64 @wcslen(i8* %30)
%32 = load i8*, i8** %8
%33 = call i64 @wcslen(i8* %32)
%34 = add i64 %31, %33
%35 = load i8*, i8** %9
%36 = call i64 @wcslen(i8* %35)
%37 = add i64 %34, %36
store i64 %37, i64* %11
%38 = load i64, i64* %11
%39 = add i64 %38, 1
%40 = mul i64 %39, 1
%41 = call i64 @malloc(i64 %40)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %55
45: ; preds = %29
%46 = load i8*, i8** %10
%47 = load i8*, i8** %7
%48 = call i32 @wcscpy(i8* %46, i8* %47)
%49 = load i8*, i8** %10
%50 = load i8*, i8** %8
%51 = call i32 @wcscat(i8* %49, i8* %50)
%52 = load i8*, i8** %10
%53 = load i8*, i8** %9
%54 = call i32 @wcscat(i8* %52, i8* %53)
br label %57
55: ; preds = %29
%56 = call i32 @_wperror(i8* bitcast ([8 x i32]* @.str.1 to i8*))
br label %57
57: ; preds = %55, %45
%58 = load i8*, i8** %10
ret i8* %58
}

LLVM IR (-O2):
@.str = [1 x i32] zeroinitializer
@.str.1 = [8 x i32] [i32 99, i32 111, i32 110, i32 99, i32 97, i32 116, i32 51, i32 0]
define i8* @concat3(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
%5 = select i1 %4, i8* bitcast ([1 x i32]* @.str to i8*), i8* %0
%6 = icmp eq i8* %1, null
%7 = select i1 %6, i8* bitcast ([1 x i32]* @.str to i8*), i8* %1
%8 = icmp eq i8* %2, null
%9 = select i1 %8, i8* bitcast ([1 x i32]* @.str to i8*), i8* %2
%10 = tail call i64 @wcslen(i8* %5)
%11 = tail call i64 @wcslen(i8* %7)
%12 = tail call i64 @wcslen(i8* %9)
%13 = add i64 %10, 1
%14 = add i64 %13, %11
%15 = add i64 %14, %12
%16 = tail call i64 @malloc(i64 %15)
%17 = inttoptr i64 %16 to i8*
%18 = icmp eq i64 %16, 0
br i1 %18, label %23, label %19
19: ; preds = %3
%20 = tail call i32 @wcscpy(i8* %17, i8* %5)
%21 = tail call i32 @wcscat(i8* %17, i8* %7)
%22 = tail call i32 @wcscat(i8* %17, i8* %9)
br label %25
23: ; preds = %3
%24 = tail call i32 @_wperror(i8* bitcast ([8 x i32]* @.str.1 to i8*))
br label %25
25: ; preds = %23, %19
ret i8* %17
}