#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 const *, char);
int strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
char *cfg_getvalue(const char *key, const char *src) {
  char *peql;
  if ((peql = strchr(src, '=')) != NULL) {
    int keylen = strlen(key);
    if ((keylen == peql - src) && (strncmp(key, src, keylen) == 0))
      return peql + 1;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<cfg_getvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11b0 <cfg_getvalue+0x80>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jne    11ab <cfg_getvalue+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ab <cfg_getvalue+0x7b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <cfg_getvalue+0x88>
jmp    11b0 <cfg_getvalue+0x80>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_getvalue>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1178 <cfg_getvalue+0x48>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    %rbx,%rdx
sub    %r14,%rdx
cmp    %rcx,%rdx
jne    1178 <cfg_getvalue+0x48>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1183 <cfg_getvalue+0x53>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0x1,%rbx
jmp    117a <cfg_getvalue+0x4a>

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

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