#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*/ strcpy(char *, char *);
int strlen(char *);
void SetStackString1(char **ppchStack, int inStackNo, char *pchValue) {
  char *pchStack = ppchStack[inStackNo];
  if (pchValue != NULL) {
    int inLength = strlen(pchValue);
    ppchStack[inStackNo] = malloc(inLength + 1);
    strcpy(ppchStack[inStackNo], pchValue);
  } else {
    ppchStack[inStackNo] = NULL;
  }
  if (pchStack != NULL) {
    free(pchStack);
    pchStack = NULL;
  }
}


x86 assembly (clang, -O0):
<SetStackString1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ae <SetStackString1+0x6e>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1060 <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
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11be <SetStackString1+0x7e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x20(%rbp)
je     11da <SetStackString1+0x9a>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetStackString1>:
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     1191 <SetStackString1+0x51>
mov    %rdx,%r15
mov    %rdx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
test   %r14,%r14
je     119e <SetStackString1+0x5e>
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    117e <SetStackString1+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @SetStackString1(i8** %0, i32 %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i8**, i8*** %4
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %9, i64 %11
%13 = load i8*, i8** %12
store i8* %13, i8** %7
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %33
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
%21 = call i8* @malloc(i32 %20)
%22 = load i8**, i8*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
store i8* %21, i8** %25
%26 = load i8**, i8*** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i8*, i8** %6
%32 = call i32 @strcpy(i8* %30, i8* %31)
br label %38
33: ; preds = %3
%34 = load i8**, i8*** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
store i8* null, i8** %37
br label %38
38: ; preds = %33, %16
%39 = load i8*, i8** %7
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %7
%43 = call i32 @free(i8* %42)
store i8* null, i8** %7
br label %44
44: ; preds = %41, %38
ret void
}

LLVM IR (-O2):
define void @SetStackString1(i8** nocapture %0, i32 %1, i8* %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8*, i8** %0, i64 %4
%6 = load i8*, i8** %5
%7 = icmp eq i8* %2, null
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i32 @strlen(i8* %2)
%10 = add nsw i32 %9, 1
%11 = tail call i8* @malloc(i32 %10)
store i8* %11, i8** %5
%12 = tail call i32 @strcpy(i8* %11, i8* %2)
br label %14
13: ; preds = %3
store i8* null, i8** %5
br label %14
14: ; preds = %13, %8
%15 = icmp eq i8* %6, null
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @free(i8* %6)
br label %18
18: ; preds = %16, %14
ret void
}