#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*/ bs_strcpy(char *, char const *);
scalar_t__ malloc(int);
int strlen(char const *);
char *cat(const char *id, const char *addr) {
  int sz = strlen(id) + strlen(addr) + 2;
  char *res = (char *)malloc(sz);
  bs_strcpy(res, id);
  res[strlen(id)] = '@';
  bs_strcpy(res + strlen(id) + 1, addr);
  return res;
}


x86 assembly (clang, -O0):
<cat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <bs_strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
movb   $0x40,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <bs_strcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <bs_strcpy@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x40,(%rbx,%rax,1)
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1050 <bs_strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @cat(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = add nsw i32 %11, 2
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = load i8*, i8** %3
%18 = call i32 @bs_strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %6
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 64, i8* %23
%24 = load i8*, i8** %6
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8*, i8** %4
%31 = call i32 @bs_strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %6
ret i8* %32
}

LLVM IR (-O2):
define i8* @cat(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add i32 %3, 2
%6 = add i32 %5, %4
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @bs_strcpy(i8* %8, i8* %0)
%10 = tail call i32 @strlen(i8* %0)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 64, i8* %12
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %8, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @bs_strcpy(i8* %16, i8* %1)
ret i8* %8
}