#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 *parseChars(char const *, int, int);
int /*<<< orphan*/ strlen(char *);
char *strstr(char const *, char *);
char *parseSpecificAttrFromRequest(const char *request, char *attr,
                                   int maxlength) {
  char *startPos = strstr(request, attr);
  if (startPos != NULL) {
    startPos += strlen(attr);
    int pos = startPos - request;
    return parseChars(request, pos, maxlength);
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<parseSpecificAttrFromRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     119e <parseSpecificAttrFromRequest+0x6e>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <parseChars@plt>
mov    %rax,-0x8(%rbp)
jmp    11a6 <parseSpecificAttrFromRequest+0x76>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseSpecificAttrFromRequest>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <strstr@plt>
test   %rax,%rax
je     1170 <parseSpecificAttrFromRequest+0x40>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
sub    %ebx,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <parseChars@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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