#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*/ sprintf(char *, char *, char *);
char strlen(char *);
void mysprintf(char *temp) {
  char i = 0;
  char tmp[255];
  sprintf(&tmp[1], "%s", temp);
  tmp[0] = '\'';
  i = strlen(tmp);
  tmp[i] = '\'';
  tmp[i + 1] = 0x00;
  sprintf(temp, "%s", tmp);
}


x86 assembly (clang, -O0):
<mysprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
lea    -0x110(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb7(%rip),%rsi
call   1040 <sprintf@plt>
movb   $0x27,-0x110(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,-0x9(%rbp)
movsbq -0x9(%rbp),%rax
movb   $0x27,-0x110(%rbp,%rax,1)
27
movsbl -0x9(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe6c(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysprintf>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x27,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
movsbq %al,%rax
movw   $0x27,(%rsp,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @mysprintf(i8* %0) {
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 1
%5 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %0)
store i8 39, i8* %3
%6 = call signext i8 @strlen(i8* %3)
%7 = sext i8 %6 to i64
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %7
store i8 39, i8* %8
%9 = add nsw i64 %7, 1
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i8* @strcpy(i8* dereferenceable(1) %0, i8* %3)
ret void
}