#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 *EBADMSG;
char *errno;
char *strchr(char *, char);
char *strstr(char *, char *);
char *libqwaitclient_login_information_grep(char *restrict message,
                                            size_t message_length) {
  char *substr;
  message[message_length - 1] = '\0';
  substr = strstr(message, "<![CDATA[");
  if (substr == NULL)
    return errno = EBADMSG, NULL;
  substr = strstr(substr, "return");
  if (substr == NULL)
    return errno = EBADMSG, NULL;
  substr = strchr(substr, '{');
  if (substr == NULL)
    return errno = EBADMSG, NULL;
  return substr;
}


x86 assembly (clang, -O0):
<libqwaitclient_login_information_grep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1180 <libqwaitclient_login_information_grep+0x60>
mov    0x2e82(%rip),%rax
mov    (%rax),%rcx
mov    0x2e68(%rip),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1206 <libqwaitclient_login_information_grep+0xe6>
mov    -0x20(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c0 <libqwaitclient_login_information_grep+0xa0>
mov    0x2e42(%rip),%rax
mov    (%rax),%rcx
mov    0x2e28(%rip),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1206 <libqwaitclient_login_information_grep+0xe6>
mov    -0x20(%rbp),%rdi
mov    $0x7b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fe <libqwaitclient_login_information_grep+0xde>
mov    0x2e04(%rip),%rax
mov    (%rax),%rcx
mov    0x2dea(%rip),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1206 <libqwaitclient_login_information_grep+0xe6>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libqwaitclient_login_information_grep>:
push   %rax
movb   $0x0,-0x1(%rsi,%rdi,1)
lea    0xed3(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     115f <libqwaitclient_login_information_grep+0x3f>
lea    0xecc(%rip),%rsi
mov    %rax,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     115f <libqwaitclient_login_information_grep+0x3f>
mov    %rax,%rdi
mov    $0x7b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115f <libqwaitclient_login_information_grep+0x3f>
pop    %rcx
ret
mov    0x2e82(%rip),%rax
mov    (%rax),%rax
mov    0x2e68(%rip),%rcx
mov    %rax,(%rcx)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"<![CDATA[\00"
@EBADMSG = global i8* null
@errno = global i8* null
@.str.1 = [7 x i8] c"return\00"
define i8* @libqwaitclient_login_information_grep(i8* noalias %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i8*, i8** %4
%8 = load i64, i64* %5
%9 = sub i64 %8, 1
%10 = getelementptr inbounds i8, i8* %7, i64 %9
store i8 0, i8* %10
%11 = load i8*, i8** %4
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i8*, i8** @EBADMSG
store i8* %16, i8** @errno
store i8* null, i8** %3
br label %33
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i8* @strstr(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i8*, i8** @EBADMSG
store i8* %23, i8** @errno
store i8* null, i8** %3
br label %33
24: ; preds = %17
%25 = load i8*, i8** %6
%26 = call i8* @strchr(i8* %25, i8 signext 123)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i8*, i8** @EBADMSG
store i8* %30, i8** @errno
store i8* null, i8** %3
br label %33
31: ; preds = %24
%32 = load i8*, i8** %6
store i8* %32, i8** %3
br label %33
33: ; preds = %31, %29, %22, %15
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@.str = [10 x i8] c"<![CDATA[\00"
@EBADMSG = global i8* null
@errno = global i8* null
@.str.1 = [7 x i8] c"return\00"
define i8* @libqwaitclient_login_information_grep(i8* noalias %0, i64 %1) {
%3 = add i64 %1, -1
%4 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 0, i8* %4
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = tail call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i8* @strchr(i8* %8, i8 signext 123)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10, %7, %2
%14 = load i8*, i8** @EBADMSG
store i8* %14, i8** @errno
br label %15
15: ; preds = %13, %10
%16 = phi i8* [ %11, %10 ], [ null, %13 ]
ret i8* %16
}