#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int matchData(unsigned char *data, size_t length) {
  if (length > 4) {
    char buf[5];
    strncpy(buf, (char *)data, sizeof(buf));
    if (strcmp(buf, "HELO") == 0 || strcmp(buf, "EHLO") == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<matchData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x4,-0x18(%rbp)
jbe    1192 <matchData+0x72>
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x1d(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1181 <matchData+0x61>
lea    -0x1d(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118d <matchData+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    1199 <matchData+0x79>
jmp    1192 <matchData+0x72>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchData>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x5,%rsi
jb     116d <matchData+0x4d>
mov    %rdi,%rax
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1171 <matchData+0x51>
lea    0xea7(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1171 <matchData+0x51>
xor    %eax,%eax
jmp    1176 <matchData+0x56>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HELO\00"
@.str.1 = [5 x i8] c"EHLO\00"
define i32 @matchData(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [5 x i8]
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = icmp ugt i64 %7, 4
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @strncpy(i8* %10, i8* %11, i32 5)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %9
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16, %9
store i32 1, i32* %3
br label %23
21: ; preds = %16
br label %22
22: ; preds = %21, %2
store i32 0, i32* %3
br label %23
23: ; preds = %22, %20
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"HELO\00"
@.str.1 = [5 x i8] c"EHLO\00"
define i32 @matchData(i8* %0, i64 %1) {
%3 = alloca [5 x i8]
%4 = icmp ugt i64 %1, 4
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 @strncpy(i8* %6, i8* %0, i32 5)
%8 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %15
11: ; preds = %5
%12 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11, %2
br label %15
15: ; preds = %10, %11, %14
%16 = phi i32 [ 1, %11 ], [ 0, %14 ], [ 1, %10 ]
ret i32 %16
}