#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__ mem_equal(char const *, char const *, size_t);
int /*<<< orphan*/ strcspn(char const *, char *);
size_t strlen(char const *);
const char *find_var_value(const char *str, const char *name) {
  size_t len = strlen(name);
  for (;;) {
    if (mem_equal(str, name, len) && str[len] == '=') {
      return str + len + 1;
    }
    str += strcspn(str, "& \t\r\n");
    if (*str != '&')
      break;
    str++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_var_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <mem_equal@plt>
cmp    $0x0,%rax
je     1192 <find_var_value+0x62>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1192 <find_var_value+0x62>
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e0 <find_var_value+0xb0>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
je     11c7 <find_var_value+0x97>
jmp    11d8 <find_var_value+0xa8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <find_var_value+0x1d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_var_value>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
lea    0xeaf(%rip),%r13
xor    %r15d,%r15d
jmp    1178 <find_var_value+0x48>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcspn@plt>
cltq
cmpb   $0x26,(%rbx,%rax,1)
lea    0x1(%rbx,%rax,1),%rbx
jne    119a <find_var_value+0x6a>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <mem_equal@plt>
test   %rax,%rax
je     1160 <find_var_value+0x30>
cmpb   $0x3d,(%rbx,%r12,1)
jne    1160 <find_var_value+0x30>
lea    (%rbx,%r12,1),%r15
add    $0x1,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"& \09\0D\0A\00"
define i8* @find_var_value(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %6
br label %9
9: ; preds = %38, %2
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = call i64 @mem_equal(i8* %10, i8* %11, i64 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = load i64, i64* %6
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 61
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i8*, i8** %4
%24 = load i64, i64* %6
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %3
br label %42
27: ; preds = %15, %9
%28 = load i8*, i8** %4
%29 = call i32 @strcspn(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %4
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %4
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 38
br i1 %36, label %37, label %38
37: ; preds = %27
br label %41
38: ; preds = %27
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
br label %9
41: ; preds = %37
store i8* null, i8** %3
br label %42
42: ; preds = %41, %22
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"& \09\0D\0A\00"
define i8* @find_var_value(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
br label %4
4: ; preds = %15, %2
%5 = phi i8* [ %0, %2 ], [ %21, %15 ]
%6 = tail call i64 @mem_equal(i8* %5, i8* %1, i64 %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %5, i64 %3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 61
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %5, i64 %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
br label %22
15: ; preds = %8, %4
%16 = tail call i32 @strcspn(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %5, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 38
%21 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %20, label %4, label %22
22: ; preds = %15, %12
%23 = phi i8* [ %14, %12 ], [ null, %15 ]
ret i8* %23
}