#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, size_t const);
int multiply_concat_prefix_and_name(char **full_name_out,
                                    size_t *full_name_len_out,
                                    const char *prefix, const size_t prefix_len,
                                    const char *name, const size_t name_len) {
  int ret = 0;
  char *full_name = NULL, *full_name_p;
  size_t full_name_len = 0;
  *full_name_out = NULL;
  *full_name_len_out = 0;
  if (prefix != NULL) {
    full_name_len = name_len + 2 + prefix_len;
    full_name = (char *)malloc(sizeof(char) * (full_name_len + 1));
    if (full_name == NULL) {
      goto fail;
    }
    full_name_p = full_name;
    memcpy(full_name_p, prefix, prefix_len);
    full_name_p += prefix_len;
    *full_name_p++ = ':';
    *full_name_p++ = ':';
    memcpy(full_name_p, name, name_len);
    full_name_p += name_len;
    *full_name_p++ = '\0';
  } else {
    full_name_len = name_len;
    full_name = (char *)malloc(sizeof(char) * full_name_len + 1);
    if (full_name == NULL) {
      goto fail;
    }
    full_name_p = full_name;
    memcpy(full_name_p, name, name_len);
    full_name_p += name_len;
    *full_name_p++ = '\0';
  }
  *full_name_out = full_name;
  *full_name_len_out = full_name_len;
fail:
  return ret;
}


x86 assembly (clang, -O0):
<multiply_concat_prefix_and_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     122c <multiply_concat_prefix_and_name+0x10c>
mov    -0x30(%rbp),%rax
add    $0x2,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11af <multiply_concat_prefix_and_name+0x8f>
jmp    12a8 <multiply_concat_prefix_and_name+0x188>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
movb   $0x3a,(%rax)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
movb   $0x3a,(%rax)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
movb   $0x0,(%rax)
jmp    1292 <multiply_concat_prefix_and_name+0x172>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    125b <multiply_concat_prefix_and_name+0x13b>
jmp    12a8 <multiply_concat_prefix_and_name+0x188>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x50(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiply_concat_prefix_and_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8,(%rsp)
mov    %rdi,0x8(%rsp)
movq   $0x0,(%rdi)
mov    %rsi,0x10(%rsp)
movq   $0x0,(%rsi)
test   %rdx,%rdx
je     1190 <multiply_concat_prefix_and_name+0x70>
mov    %rcx,%rbp
mov    %rdx,%r12
lea    (%rcx,%r13,1),%r15
add    $0x2,%r15
lea    0x1(%r15),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     11cb <multiply_concat_prefix_and_name+0xab>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <memcpy@plt>
movw   $0x3a3a,(%r14,%rbp,1)
lea    (%r14,%rbp,1),%rbx
add    $0x2,%rbx
jmp    11a7 <multiply_concat_prefix_and_name+0x87>
lea    0x1(%r13),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%r14
mov    %r13,%r15
test   %rax,%rax
je     11cb <multiply_concat_prefix_and_name+0xab>
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    %r13,%rdx
call   1030 <memcpy@plt>
movb   $0x0,(%rbx,%r13,1)
mov    0x8(%rsp),%rax
mov    %r14,(%rax)
mov    0x10(%rsp),%rax
mov    %r15,(%rax)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @multiply_concat_prefix_and_name(i8** %0, i64* %1, i8* %2, i64 %3, i8* %4, i64 %5) {
%7 = alloca i8**
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i64
store i8** %0, i8*** %7
store i64* %1, i64** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i64 %5, i64* %12
store i32 0, i32* %13
store i8* null, i8** %14
store i64 0, i64* %16
%17 = load i8**, i8*** %7
store i8* null, i8** %17
%18 = load i64*, i64** %8
store i64 0, i64* %18
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %57
21: ; preds = %6
%22 = load i64, i64* %12
%23 = add i64 %22, 2
%24 = load i64, i64* %10
%25 = add i64 %23, %24
store i64 %25, i64* %16
%26 = load i64, i64* %16
%27 = add i64 %26, 1
%28 = mul i64 1, %27
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %14
%32 = load i8*, i8** %14
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %21
br label %84
35: ; preds = %21
%36 = load i8*, i8** %14
store i8* %36, i8** %15
%37 = load i8*, i8** %15
%38 = load i8*, i8** %9
%39 = load i64, i64* %10
%40 = call i32 @memcpy(i8* %37, i8* %38, i64 %39)
%41 = load i64, i64* %10
%42 = load i8*, i8** %15
%43 = getelementptr inbounds i8, i8* %42, i64 %41
store i8* %43, i8** %15
%44 = load i8*, i8** %15
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %15
store i8 58, i8* %44
%46 = load i8*, i8** %15
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %15
store i8 58, i8* %46
%48 = load i8*, i8** %15
%49 = load i8*, i8** %11
%50 = load i64, i64* %12
%51 = call i32 @memcpy(i8* %48, i8* %49, i64 %50)
%52 = load i64, i64* %12
%53 = load i8*, i8** %15
%54 = getelementptr inbounds i8, i8* %53, i64 %52
store i8* %54, i8** %15
%55 = load i8*, i8** %15
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %15
store i8 0, i8* %55
br label %79
57: ; preds = %6
%58 = load i64, i64* %12
store i64 %58, i64* %16
%59 = load i64, i64* %16
%60 = mul i64 1, %59
%61 = add i64 %60, 1
%62 = trunc i64 %61 to i32
%63 = call i64 @malloc(i32 %62)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %14
%65 = load i8*, i8** %14
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %68
67: ; preds = %57
br label %84
68: ; preds = %57
%69 = load i8*, i8** %14
store i8* %69, i8** %15
%70 = load i8*, i8** %15
%71 = load i8*, i8** %11
%72 = load i64, i64* %12
%73 = call i32 @memcpy(i8* %70, i8* %71, i64 %72)
%74 = load i64, i64* %12
%75 = load i8*, i8** %15
%76 = getelementptr inbounds i8, i8* %75, i64 %74
store i8* %76, i8** %15
%77 = load i8*, i8** %15
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %15
store i8 0, i8* %77
br label %79
79: ; preds = %68, %35
%80 = load i8*, i8** %14
%81 = load i8**, i8*** %7
store i8* %80, i8** %81
%82 = load i64, i64* %16
%83 = load i64*, i64** %8
store i64 %82, i64* %83
br label %84
84: ; preds = %79, %67, %34
%85 = load i32, i32* %13
ret i32 %85
}

LLVM IR (-O2):
define i32 @multiply_concat_prefix_and_name(i8** nocapture writeonly %0, i64* nocapture writeonly %1, i8* %2, i64 %3, i8* %4, i64 %5) {
store i8* null, i8** %0
store i64 0, i64* %1
%7 = icmp eq i8* %2, null
br i1 %7, label %21, label %8
8: ; preds = %6
%9 = add i64 %3, 2
%10 = add i64 %9, %5
%11 = trunc i64 %10 to i32
%12 = add i32 %11, 1
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %33, label %16
16: ; preds = %8
%17 = tail call i32 @memcpy(i8* %14, i8* %2, i64 %3)
%18 = getelementptr inbounds i8, i8* %14, i64 %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 58, i8* %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 58, i8* %19
br label %27
21: ; preds = %6
%22 = trunc i64 %5 to i32
%23 = add i32 %22, 1
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = icmp eq i64 %24, 0
br i1 %26, label %33, label %27
27: ; preds = %21, %16
%28 = phi i8* [ %20, %16 ], [ %25, %21 ]
%29 = phi i8* [ %14, %16 ], [ %25, %21 ]
%30 = phi i64 [ %10, %16 ], [ %5, %21 ]
%31 = tail call i32 @memcpy(i8* %28, i8* %4, i64 %5)
%32 = getelementptr inbounds i8, i8* %28, i64 %5
store i8 0, i8* %32
store i8* %29, i8** %0
store i64 %30, i64* %1
br label %33
33: ; preds = %21, %8, %27
ret i32 0
}