#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 */
scalar_t__ malloc(int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char const *, char *);
char *getValue(const char *pKeyVal) {
  char *pValue = NULL;
  char *pPosColon = strstr(pKeyVal, ":") + 1;
  pValue = (char *)malloc(strlen(pPosColon));
  strncpy(pValue, pPosColon + 1, strlen(pPosColon) - 1);
  pValue[strlen(pPosColon) - 2] = '\0';
  return pValue;
}


x86 assembly (clang, -O0):
<getValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <strstr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getValue>:
push   %r15
push   %r14
push   %rbx
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
lea    0x1(%rax),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
add    $0x2,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x2(%rax,%r15,1)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i8* @getValue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
%18 = call i32 @strncpy(i8* %12, i8* %14, i32 %17)
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
store i8 0, i8* %24
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
define i8* @getValue(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 58)
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = tail call i32 @strlen(i8* %3)
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = getelementptr inbounds i8, i8* %2, i64 2
%8 = tail call i32 @strlen(i8* %3)
%9 = add nsw i32 %8, -1
%10 = tail call i32 @strncpy(i8* %6, i8* %7, i32 %9)
%11 = tail call i32 @strlen(i8* %3)
%12 = add nsw i32 %11, -2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %6, i64 %13
store i8 0, i8* %14
ret i8* %6
}