#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, char *);
int strlen(char *);
void SetStackString4(char **ppchStack, int inStackNo, double doValue1,
                     char *pchValue2) {
  char *pchStack = ppchStack[inStackNo];
  if (pchValue2 != NULL) {
    int inLength = 32 + strlen(pchValue2);
    ppchStack[inStackNo] = malloc(inLength + 1);
    sprintf(ppchStack[inStackNo], "%d%s", (int)doValue1, pchValue2);
  } else {
    ppchStack[inStackNo] = NULL;
  }
  if (pchStack != NULL) {
    free(pchStack);
    pchStack = NULL;
  }
}


x86 assembly (clang, -O0):
<SetStackString4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c2 <SetStackString4+0x82>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x20,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
cvttsd2si -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe48(%rip),%rsi
call   1060 <sprintf@plt>
jmp    11d2 <SetStackString4+0x92>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x28(%rbp)
je     11ee <SetStackString4+0xae>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetStackString4>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
movslq %esi,%rbx
mov    (%rdi,%rbx,8),%r14
test   %rdx,%rdx
je     11a2 <SetStackString4+0x62>
mov    %rdx,%r15
mov    %rdx,%rdi
movsd  %xmm0,(%rsp)
call   1040 <strlen@plt>
lea    0x21(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
cvttsd2si (%rsp),%edx
lea    0xe81(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rcx
call   1060 <sprintf@plt>
test   %r14,%r14
je     11af <SetStackString4+0x6f>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
movq   $0x0,(%r12,%rbx,8)
test   %r14,%r14
jne    118f <SetStackString4+0x4f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%s\00"
define void @SetStackString4(i8** %0, i32 %1, double %2, i8* %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store double %2, double* %7
store i8* %3, i8** %8
%11 = load i8**, i8*** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
store i8* %15, i8** %9
%16 = load i8*, i8** %8
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %38
18: ; preds = %4
%19 = load i8*, i8** %8
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 32, %20
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 1
%24 = call i8* @malloc(i32 %23)
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
store i8* %24, i8** %28
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load double, double* %7
%35 = fptosi double %34 to i32
%36 = load i8*, i8** %8
%37 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %35, i8* %36)
br label %43
38: ; preds = %4
%39 = load i8**, i8*** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
store i8* null, i8** %42
br label %43
43: ; preds = %38, %18
%44 = load i8*, i8** %9
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i8*, i8** %9
%48 = call i32 @free(i8* %47)
store i8* null, i8** %9
br label %49
49: ; preds = %46, %43
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%s\00"
define void @SetStackString4(i8** nocapture %0, i32 %1, double %2, i8* %3) {
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i8*, i8** %0, i64 %5
%7 = load i8*, i8** %6
%8 = icmp eq i8* %3, null
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = tail call i32 @strlen(i8* %3)
%11 = add nsw i32 %10, 33
%12 = tail call i8* @malloc(i32 %11)
store i8* %12, i8** %6
%13 = fptosi double %2 to i32
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %3)
br label %16
15: ; preds = %4
store i8* null, i8** %6
br label %16
16: ; preds = %15, %9
%17 = icmp eq i8* %7, null
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = tail call i32 @free(i8* %7)
br label %20
20: ; preds = %18, %16
ret void
}