#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 *strchr(char *, char);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char const *, char const *);
void getValue(const char *_str, const char *_key, char *_value) {
  char *beginning, *end;
  if ((beginning = strstr(_str, _key)) != NULL) {
    beginning += strlen(_key);
    end = strchr(beginning, '"');
    if (end) {
      strncpy(_value, beginning, end - beginning);
    }
  }
}


x86 assembly (clang, -O0):
<getValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c4 <getValue+0x84>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bf <getValue+0x7f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
jmp    11c4 <getValue+0x84>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getValue>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1060 <strstr@plt>
test   %rax,%rax
je     118b <getValue+0x4b>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     118b <getValue+0x4b>
sub    %ebx,%eax
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strncpy@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @getValue(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = tail call i8* @strchr(i8* %9, i8 signext 34)
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %6
%13 = ptrtoint i8* %10 to i64
%14 = ptrtoint i8* %9 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @strncpy(i8* %2, i8* %9, i32 %16)
br label %18
18: ; preds = %6, %12, %3
ret void
}