#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(scalar_t__);
int /*<<< orphan*/ strcat(char *, char const *);
scalar_t__ strlen(char const *);
char *strstr(char const *, char *);
char *SearchKey(const char *fromWhere, const char *key) {
  char *found = NULL;
  char *ext_key;
  ext_key = (char *)malloc(1 + strlen(key) + 1 + 1);
  ext_key[0] = '\n';
  ext_key[1] = '\0';
  strcat(ext_key, key);
  found = strstr(fromWhere, ext_key);
  if (found)
    return found + 1;
  else
    return NULL;
}


x86 assembly (clang, -O0):
<SearchKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
add    $0x1,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c2 <SearchKey+0x82>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <SearchKey+0x8a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SearchKey>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    0x3(%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
movw   $0xa,(%rax)
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmovne %rcx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @SearchKey(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = add nsw i64 %3, 3
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
store i8 10, i8* %6
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8 0, i8* %7
%8 = tail call i32 @strcat(i8* %6, i8* %1)
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* %6)
%10 = icmp eq i8* %9, null
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = select i1 %10, i8* null, i8* %11
ret i8* %12
}