#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 */
size_t strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, size_t);
int isConnectRequest(char *request, int size) {
  if (size <= 64)
    if ((!strncmp(request, "CONNECT", strlen("CONNECT"))) &&
        (request[strlen("CONNECT")] == ' ') && (request[size - 2] == ';') &&
        (request[size - 1] == '\n'))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isConnectRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jg     11d6 <isConnectRequest+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xeb8(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xea5(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d1 <isConnectRequest+0xb1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe88(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11d1 <isConnectRequest+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    11d1 <isConnectRequest+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11d1 <isConnectRequest+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    11dd <isConnectRequest+0xbd>
jmp    11d6 <isConnectRequest+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isConnectRequest>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x40,%esi
jg     114e <isConnectRequest+0x3e>
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    114e <isConnectRequest+0x3e>
cmpb   $0x20,0x7(%rbx)
jne    114e <isConnectRequest+0x3e>
movslq %ebp,%rcx
cmpb   $0x3b,-0x2(%rcx,%rbx,1)
jne    114e <isConnectRequest+0x3e>
mov    $0x1,%eax
cmpb   $0xa,-0x1(%rcx,%rbx,1)
je     1150 <isConnectRequest+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"CONNECT\00"
define i32 @isConnectRequest(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 65
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 32
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = add nsw i32 %1, -2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 59
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = add nsw i32 %1, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %24, label %23
23: ; preds = %4, %7, %11, %17, %2
br label %24
24: ; preds = %17, %23
%25 = phi i32 [ 0, %23 ], [ 1, %17 ]
ret i32 %25
}