char *buildname(pre, mid, suf)
char *pre;
char *mid;
char *suf;
{
  char *name;
  name = ourmalloc(strlen(pre) + strlen(mid) + strlen(suf) + 1);
  strcpy(name, pre);
  strcat(name, mid);
  strcat(name, suf);
  return name;
}


x86 assembly (clang, -O0):
<buildname>:
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    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   1050 <ourmalloc@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildname>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r12,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
xor    %eax,%eax
call   1050 <ourmalloc@plt>
movslq %eax,%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>

LLVM IR (-O0):
define i8* @buildname(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = add i64 %9, %11
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = add i64 %12, %14
%16 = add i64 %15, 1
%17 = call i32 (i64, ...) bitcast (i32 (...)* @ourmalloc to i32 (i64, ...)*)(i64 %16)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = load i8*, i8** %4
%22 = call i8* @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = call i8* @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %7
%27 = load i8*, i8** %6
%28 = call i8* @strcat(i8* %26, i8* %27)
%29 = load i8*, i8** %7
ret i8* %29
}

LLVM IR (-O2):
define i8* @buildname(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%7 = add i64 %4, 1
%8 = add i64 %7, %5
%9 = add i64 %8, %6
%10 = tail call i32 (i64, ...) bitcast (i32 (...)* @ourmalloc to i32 (i64, ...)*)(i64 %9)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
%13 = tail call i8* @strcpy(i8* dereferenceable(1) %12, i8* dereferenceable(1) %0)
%14 = tail call i8* @strcat(i8* dereferenceable(1) %12, i8* dereferenceable(1) %1)
%15 = tail call i8* @strcat(i8* dereferenceable(1) %12, i8* dereferenceable(1) %2)
ret i8* %12
}