#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 */
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *xmalloc(scalar_t__);
char *xstrconcat4(const char *s, const char *t, const char *u, const char *v) {
  char *res;
  if (!s)
    s = "";
  if (!t)
    t = "";
  if (!u)
    u = "";
  if (!v)
    v = "";
  res = xmalloc(strlen(s) + strlen(t) + strlen(u) + strlen(v) + 1);
  strcpy(res, s);
  strcat(res, t);
  strcat(res, u);
  strcat(res, v);
  free((void *)s);
  return res;
}


x86 assembly (clang, -O0):
<xstrconcat4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117e <xstrconcat4+0x2e>
lea    0xe86(%rip),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <xstrconcat4+0x44>
lea    0xe70(%rip),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11aa <xstrconcat4+0x5a>
lea    0xe5a(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c0 <xstrconcat4+0x70>
lea    0xe44(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <xmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xstrconcat4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
lea    0xe98(%rip),%rbx
cmove  %rbx,%r14
mov    %rsi,%r12
test   %rsi,%rsi
cmove  %rbx,%r12
mov    %rdx,%r15
test   %rdx,%rdx
cmove  %rbx,%r15
test   %rcx,%rcx
cmovne %rcx,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    (%rsp),%rbp
add    %r13,%rbp
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
call   1060 <xmalloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @xstrconcat4(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
br label %13
13: ; preds = %12, %4
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
br label %17
17: ; preds = %16, %13
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %17
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
br label %21
21: ; preds = %20, %17
%22 = load i8*, i8** %8
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %21
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %25
25: ; preds = %24, %21
%26 = load i8*, i8** %5
%27 = call i64 @strlen(i8* %26)
%28 = load i8*, i8** %6
%29 = call i64 @strlen(i8* %28)
%30 = add nsw i64 %27, %29
%31 = load i8*, i8** %7
%32 = call i64 @strlen(i8* %31)
%33 = add nsw i64 %30, %32
%34 = load i8*, i8** %8
%35 = call i64 @strlen(i8* %34)
%36 = add nsw i64 %33, %35
%37 = add nsw i64 %36, 1
%38 = call i8* @xmalloc(i64 %37)
store i8* %38, i8** %9
%39 = load i8*, i8** %9
%40 = load i8*, i8** %5
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = load i8*, i8** %9
%43 = load i8*, i8** %6
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = load i8*, i8** %9
%46 = load i8*, i8** %7
%47 = call i32 @strcat(i8* %45, i8* %46)
%48 = load i8*, i8** %9
%49 = load i8*, i8** %8
%50 = call i32 @strcat(i8* %48, i8* %49)
%51 = load i8*, i8** %5
%52 = call i32 @free(i8* %51)
%53 = load i8*, i8** %9
ret i8* %53
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @xstrconcat4(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %0, null
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %0
%7 = icmp eq i8* %1, null
%8 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %1
%9 = icmp eq i8* %2, null
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %2
%11 = icmp eq i8* %3, null
%12 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %3
%13 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%14 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%15 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%16 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%17 = add i64 %13, 1
%18 = add i64 %17, %14
%19 = add i64 %18, %15
%20 = add i64 %19, %16
%21 = tail call i8* @xmalloc(i64 %20)
%22 = tail call i32 @strcpy(i8* %21, i8* %6)
%23 = tail call i32 @strcat(i8* %21, i8* %8)
%24 = tail call i32 @strcat(i8* %21, i8* %10)
%25 = tail call i32 @strcat(i8* %21, i8* %12)
%26 = tail call i32 @free(i8* %6)
ret i8* %21
}