#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 */
char *calloc(scalar_t__, int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int, char const *,
                           char const *);
scalar_t__ strlen(char const *);
char *assemble_message(const char *msg, const char *srcfile,
                       const char *funname, int line) {
  char *msgbuffer = calloc(
      strlen(msg) + strlen(srcfile) + strlen(funname) + 10 + 8, sizeof(char));
  sprintf(msgbuffer, "%s:%d - %s() - %s", srcfile, line, funname, msg);
  return msgbuffer;
}


x86 assembly (clang, -O0):
<assemble_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0xa,%rdi
add    $0x8,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x8(%rbp),%r9
lea    0xe55(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assemble_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %rbp,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0x12,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
lea    0xe7f(%rip),%rsi
mov    %rax,%rdi
mov    %r13,%rdx
mov    %r14d,%ecx
mov    %r15,%r8
mov    %r12,%r9
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s:%d - %s() - %s\00"
define i8* @assemble_message(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = load i8*, i8** %6
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 %11, %13
%15 = load i8*, i8** %7
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %14, %16
%18 = add nsw i64 %17, 10
%19 = add nsw i64 %18, 8
%20 = call i8* @calloc(i64 %19, i32 1)
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i8*, i8** %6
%23 = load i32, i32* %8
%24 = load i8*, i8** %7
%25 = load i8*, i8** %5
%26 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23, i8* %24, i8* %25)
%27 = load i8*, i8** %9
ret i8* %27
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s:%d - %s() - %s\00"
define i8* @assemble_message(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%8 = add i64 %5, 18
%9 = add i64 %8, %6
%10 = add i64 %9, %7
%11 = tail call i8* @calloc(i64 %10, i32 1)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %3, i8* %2, i8* %0)
ret i8* %11
}