#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*/ strlcat(char *, char const *, size_t);
int /*<<< orphan*/ strlcpy(char *, char const *, size_t);
int strlen(char const *);
char *xmalloc(size_t);
char *concat3(const char *a, const char *b, const char *c) {
  size_t size = sizeof(char) * (strlen(a) + strlen(b) + strlen(c) + 1);
  char *s = xmalloc(size + 1);
  strlcpy(s, a, size);
  strlcat(s, b, size);
  strlcat(s, c, size);
  return s;
}


x86 assembly (clang, -O0):
<concat3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1050 <xmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <strlcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strlcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strlcat@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concat3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r12d,%ebp
add    %ebp,%eax
add    $0x1,%eax
movslq %eax,%rbp
lea    0x1(%rbp),%rdi
call   1050 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <strlcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <strlcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1030 <strlcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @concat3(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %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
%19 = mul i64 1, %18
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = add i64 %20, 1
%22 = call i8* @xmalloc(i64 %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load i8*, i8** %4
%25 = load i64, i64* %7
%26 = call i32 @strlcpy(i8* %23, i8* %24, i64 %25)
%27 = load i8*, i8** %8
%28 = load i8*, i8** %5
%29 = load i64, i64* %7
%30 = call i32 @strlcat(i8* %27, i8* %28, i64 %29)
%31 = load i8*, i8** %8
%32 = load i8*, i8** %6
%33 = load i64, i64* %7
%34 = call i32 @strlcat(i8* %31, i8* %32, i64 %33)
%35 = load i8*, i8** %8
ret i8* %35
}

LLVM IR (-O2):
define i8* @concat3(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 @strlen(i8* %2)
%7 = add i32 %4, 1
%8 = add i32 %7, %5
%9 = add i32 %8, %6
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, 1
%12 = tail call i8* @xmalloc(i64 %11)
%13 = tail call i32 @strlcpy(i8* %12, i8* %0, i64 %10)
%14 = tail call i32 @strlcat(i8* %12, i8* %1, i64 %10)
%15 = tail call i32 @strlcat(i8* %12, i8* %2, i64 %10)
ret i8* %12
}