#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 */
int /*<<< orphan*/ free(char *);
scalar_t__ strcasecmp(char const *, char *);
char *strchr(char const *, char);
char *strdup(char const *);
char *strtok_r(char *, char *, char **);
int gw_parse_line(const char *line, const char *pattern, char **return_msg) {
  int found = 0;
  char *pline, *token, *lasts;
  char delimiters[] = " =\t\n";
  *return_msg = NULL;
  pline = strdup(line);
  token = strtok_r(pline, delimiters, &lasts);
  if (token != NULL) {
    if (strcasecmp(pattern, token) == 0) {
      token = strchr(line, '=');
      if (token != NULL) {
        *return_msg = strdup(token + 1);
      } else
        *return_msg = NULL;
      found = 1;
    }
  }
  free(pline);
  return found;
}


x86 assembly (clang, -O0):
<gw_parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0xe8f(%rip),%eax
mov    %eax,-0x3d(%rbp)
mov    0xe8a(%rip),%al
mov    %al,-0x39(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x3d(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     121c <gw_parse_line+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1217 <gw_parse_line+0xc7>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1205 <gw_parse_line+0xb5>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1210 <gw_parse_line+0xc0>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    121c <gw_parse_line+0xcc>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gw_parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
movb   $0x0,0x4(%rsp)
movl   $0xa093d20,(%rsp)
movq   $0x0,(%rdx)
call   1070 <strdup@plt>
mov    %rax,%r15
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1060 <strtok_r@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11d1 <gw_parse_line+0x81>
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    11d1 <gw_parse_line+0x81>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11c7 <gw_parse_line+0x77>
add    $0x1,%rax
mov    %rax,%rdi
call   1070 <strdup@plt>
jmp    11c9 <gw_parse_line+0x79>
xor    %eax,%eax
mov    %rax,(%r14)
mov    $0x1,%ebp
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.gw_parse_line.delimiters = [5 x i8] c" =\09\0A\00"
define i32 @gw_parse_line(i8* %0, i8* nocapture %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = alloca [5 x i8]
%6 = bitcast i8** %4 to i8*
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
store i8* null, i8** %2
%8 = tail call i8* @strdup(i8* %0)
%9 = call i8* @strtok_r(i8* %8, i8* %7, i8** %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %22, label %11
11: ; preds = %3
%12 = call i64 @strcasecmp(i8* %1, i8* %9)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = call i8* @strdup(i8* %18)
br label %20
20: ; preds = %14, %17
%21 = phi i8* [ %19, %17 ], [ null, %14 ]
store i8* %21, i8** %2
br label %22
22: ; preds = %11, %20, %3
%23 = phi i32 [ 1, %20 ], [ 0, %11 ], [ 0, %3 ]
%24 = call i32 @free(i8* %8)
ret i32 %23
}