#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*/ memcpy(char *, char *, int);
scalar_t__ strlen(char *);
void add_signature_to_variable(void *ptr, size_t size) {
  char *tmp = (char *)ptr;
  memcpy(tmp, "(D)(M).\0", ((int)(strlen("(D)(M).\0") + 1)));
  memcpy(tmp + ((int)(strlen("(D)(M).\0") + 1)) + size, "(D)(M).\0",
         ((int)(strlen("(D)(M).\0") + 1)));
}


x86 assembly (clang, -O0):
<add_signature_to_variable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    $0x1,%rax
mov    %eax,%edx
lea    0xea3(%rip),%rsi
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe8f(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    $0x1,%rcx
movslq %ecx,%rcx
add    %rcx,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe6a(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rax
mov    %eax,%edx
lea    0xe54(%rip),%rsi
call   1040 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_signature_to_variable>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xede(%rip),%r15
mov    %r15,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
lea    (%rbx,%r14,1),%rdi
add    $0x8,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"(D)(M).\00\00"
define void @add_signature_to_variable(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = call i64 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = add nsw i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call i32 @memcpy(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = add nsw i64 %13, 1
%15 = trunc i64 %14 to i32
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %12, i64 %16
%18 = load i64, i64* %4
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = call i64 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%21 = add nsw i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i32 @memcpy(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"(D)(M).\00\00"
define void @add_signature_to_variable(i8* %0, i64 %1) {
%3 = tail call i32 @memcpy(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = getelementptr inbounds i8, i8* %0, i64 8
%5 = getelementptr inbounds i8, i8* %4, i64 %1
%6 = tail call i32 @memcpy(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
ret void
}