#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 *lr_eval_string(char *);
int /*<<< orphan*/ lr_output_message(char *, char *);
int /*<<< orphan*/ lr_save_string(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
ConvertParamToString() {
  char String[500];
  lr_save_string("This is a test", "StringFromParam");
  sprintf(String, "%s", lr_eval_string("{StringFromParam}"));
  lr_output_message("New string is [%s]", String);
  return 0;
}


x86 assembly (clang, -O0):
<ConvertParamToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <lr_save_string@plt>
lea    -0x200(%rbp),%rax
mov    %rax,-0x208(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <lr_eval_string@plt>
mov    -0x208(%rbp),%rdi
mov    %rax,%rdx
lea    0xe96(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1040 <lr_output_message@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertParamToString>:
push   %rbx
sub    $0x200,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <lr_save_string@plt>
lea    0xebd(%rip),%rdi
call   1030 <lr_eval_string@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <lr_output_message@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"This is a test\00"
@.str.1 = [16 x i8] c"StringFromParam\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [18 x i8] c"{StringFromParam}\00"
@.str.4 = [19 x i8] c"New string is [%s]\00"
define i32 @ConvertParamToString() {
%1 = alloca [500 x i8]
%2 = call i32 @lr_save_string(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%4 = call i8* @lr_eval_string(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%7 = call i32 @lr_output_message(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"This is a test\00"
@.str.1 = [16 x i8] c"StringFromParam\00"
@.str.3 = [18 x i8] c"{StringFromParam}\00"
@.str.4 = [19 x i8] c"New string is [%s]\00"
define i32 @ConvertParamToString() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @lr_save_string(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @lr_eval_string(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%5 = call i8* @strcpy(i8* %2, i8* dereferenceable(1) %4)
%6 = call i32 @lr_output_message(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %2)
ret i32 0
}