#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 GetKeyIndex(char const **, char const *, unsigned int const);
char *malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void ProcessConfigElement(char **out, const char *szKey, const char *szValue,
                          const char **pKeyPool,
                          const unsigned int iKeyPoolLength) {
  signed int iIdx = GetKeyIndex(pKeyPool, szKey, iKeyPoolLength);
  if (iIdx != -1) {
    out[iIdx] = malloc(strlen(szValue) + 1);
    strcpy(out[iIdx], szValue);
  }
}


x86 assembly (clang, -O0):
<ProcessConfigElement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <GetKeyIndex@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
je     11b2 <ProcessConfigElement+0x72>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessConfigElement>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rcx,%rdi
mov    %r8d,%edx
call   1060 <GetKeyIndex@plt>
cmp    $0xffffffff,%eax
je     1183 <ProcessConfigElement+0x43>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
movslq %ebp,%rcx
mov    %rax,(%r14,%rcx,8)
mov    %rax,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <strcpy@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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