#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 *FindNextWord(char *);
scalar_t__ IzSpace(char);
int /*<<< orphan*/ printf(char *, char *);
char *strchr(char *, char);
int strlen(char *);
char *FindStringCfgValue(char *str) {
  char *tmp;
  int lastpos;
  tmp = strchr(str, '=');
  if (tmp == NULL) {
    printf("Invalid config line, no '=' sign found: %s\n", str);
    return NULL;
  }
  tmp++;
  if (IzSpace(tmp[0])) {
    tmp = FindNextWord(tmp);
  }
  if (IzSpace(tmp[0]) || tmp[0] == '\0') {
    printf("Invalid config line, no value after '=': %s\n", str);
    return NULL;
  }
  lastpos = strlen(tmp) - 1;
  while (IzSpace(tmp[lastpos])) {
    tmp[lastpos--] = '\0';
  }
  return tmp;
}


x86 assembly (clang, -O0):
<FindStringCfgValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1196 <FindStringCfgValue+0x46>
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1060 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1255 <FindStringCfgValue+0x105>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1070 <IzSpace@plt>
cmp    $0x0,%rax
je     11c5 <FindStringCfgValue+0x75>
mov    -0x18(%rbp),%rdi
call   1040 <FindNextWord@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1070 <IzSpace@plt>
cmp    $0x0,%rax
jne    11eb <FindStringCfgValue+0x9b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1208 <FindStringCfgValue+0xb8>
mov    -0x10(%rbp),%rsi
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1255 <FindStringCfgValue+0x105>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <IzSpace@plt>
cmp    $0x0,%rax
je     124d <FindStringCfgValue+0xfd>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1217 <FindStringCfgValue+0xc7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindStringCfgValue>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e7 <FindStringCfgValue+0x97>
mov    %rax,%r15
add    $0x1,%r15
movsbl 0x1(%rax),%edi
call   1070 <IzSpace@plt>
test   %rax,%rax
je     118b <FindStringCfgValue+0x3b>
mov    %r15,%rdi
call   1040 <FindNextWord@plt>
mov    %rax,%r15
movsbl (%r15),%edi
call   1070 <IzSpace@plt>
lea    0xe91(%rip),%rdi
test   %rax,%rax
jne    11ee <FindStringCfgValue+0x9e>
cmpb   $0x0,(%r15)
je     11ee <FindStringCfgValue+0x9e>
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
movsbl -0x1(%rbx,%r15,1),%edi
call   1070 <IzSpace@plt>
test   %rax,%rax
je     11f9 <FindStringCfgValue+0xa9>
add    %r15,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1070 <IzSpace@plt>
test   %rax,%rax
jne    11d0 <FindStringCfgValue+0x80>
jmp    11f9 <FindStringCfgValue+0xa9>
lea    0xe12(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Invalid config line, no '=' sign found: %s\0A\00"
@.str.1 = [45 x i8] c"Invalid config line, no value after '=': %s\0A\00"
define i8* @FindStringCfgValue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strchr(i8* %6, i8 signext 61)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %11)
store i8* null, i8** %2
br label %59
13: ; preds = %1
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = call i64 @IzSpace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = call i8* @FindNextWord(i8* %22)
store i8* %23, i8** %4
br label %24
24: ; preds = %21, %13
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = call i64 @IzSpace(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30, %24
%37 = load i8*, i8** %3
%38 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %37)
store i8* null, i8** %2
br label %59
39: ; preds = %30
%40 = load i8*, i8** %4
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %5
br label %43
43: ; preds = %51, %39
%44 = load i8*, i8** %4
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = call i64 @IzSpace(i8 signext %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %43
%52 = load i8*, i8** %4
%53 = load i32, i32* %5
%54 = add nsw i32 %53, -1
store i32 %54, i32* %5
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 0, i8* %56
br label %43
57: ; preds = %43
%58 = load i8*, i8** %4
store i8* %58, i8** %2
br label %59
59: ; preds = %57, %36, %10
%60 = load i8*, i8** %2
ret i8* %60
}

LLVM IR (-O2):
@.str = [44 x i8] c"Invalid config line, no '=' sign found: %s\0A\00"
@.str.1 = [45 x i8] c"Invalid config line, no value after '=': %s\0A\00"
define i8* @FindStringCfgValue(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%3 = icmp eq i8* %2, null
br i1 %3, label %35, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = load i8, i8* %5
%7 = tail call i64 @IzSpace(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i8* @FindNextWord(i8* %5)
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ %10, %9 ], [ %5, %4 ]
%13 = load i8, i8* %12
%14 = tail call i64 @IzSpace(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %35
16: ; preds = %11
%17 = load i8, i8* %12
%18 = icmp eq i8 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %16
%20 = tail call i32 @strlen(i8* %12)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %12, i64 %22
%24 = load i8, i8* %23
%25 = tail call i64 @IzSpace(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %38, label %27
27: ; preds = %19, %27
%28 = phi i64 [ %30, %27 ], [ %22, %19 ]
%29 = phi i8* [ %31, %27 ], [ %23, %19 ]
store i8 0, i8* %29
%30 = add i64 %28, -1
%31 = getelementptr inbounds i8, i8* %12, i64 %30
%32 = load i8, i8* %31
%33 = tail call i64 @IzSpace(i8 signext %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %27
35: ; preds = %11, %16, %1
%36 = phi i8* [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), %16 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), %11 ]
%37 = tail call i32 @printf(i8* %36, i8* %0)
br label %38
38: ; preds = %27, %35, %19
%39 = phi i8* [ %12, %19 ], [ null, %35 ], [ %12, %27 ]
ret i8* %39
}