#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 sscanf(char *, char *, char *, char *, char *, char *);
char *strstr(char *, char *);
int matchData(unsigned char *data, size_t length) {
  char *user = strstr((char *)data, "USER ");
  char *nick = strstr((char *)data, "NICK ");
  char u0[65], u1[65], u2[65], u3[65];
  if (user && nick) {
    if (sscanf(user, "USER %64s \"%64[^\"]\" \"%64[^\"]\" :%64s\r\n", u0, u1,
               u2, u3) == 4)
      return 1;
    else if (sscanf(user, "USER %64s %64s %64s :%64[^\r\n]\r\n", u0, u1, u2,
                    u3) == 4)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<matchData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f7 <matchData+0xd7>
cmpq   $0x0,-0x28(%rbp)
je     11f7 <matchData+0xd7>
mov    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    -0x110(%rbp),%r8
lea    -0x160(%rbp),%r9
lea    0xe77(%rip),%rsi
call   1030 <sscanf@plt>
cmp    $0x4,%eax
jne    11af <matchData+0x8f>
movl   $0x1,-0x4(%rbp)
jmp    11fe <matchData+0xde>
mov    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    -0x110(%rbp),%r8
lea    -0x160(%rbp),%r9
lea    0xe5f(%rip),%rsi
call   1030 <sscanf@plt>
cmp    $0x4,%eax
jne    11ed <matchData+0xcd>
movl   $0x1,-0x4(%rbp)
jmp    11fe <matchData+0xde>
jmp    11f2 <matchData+0xd2>
jmp    11f7 <matchData+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchData>:
push   %rbp
push   %rbx
sub    $0x138,%rsp
mov    %rdi,%rbp
lea    0xecd(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,%rbx
lea    0xec4(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rbx,%rbx
je     11b1 <matchData+0x91>
test   %rax,%rax
je     11b1 <matchData+0x91>
lea    0xeb1(%rip),%rsi
lea    0xf0(%rsp),%rdx
lea    0xa0(%rsp),%rcx
lea    0x50(%rsp),%r8
mov    %rsp,%r9
mov    %rbx,%rdi
call   1030 <sscanf@plt>
mov    $0x1,%ebp
cmp    $0x4,%eax
je     11b3 <matchData+0x93>
lea    0xea6(%rip),%rsi
lea    0xf0(%rsp),%rdx
lea    0xa0(%rsp),%rcx
lea    0x50(%rsp),%r8
mov    %rsp,%r9
mov    %rbx,%rdi
call   1030 <sscanf@plt>
cmp    $0x4,%eax
je     11b3 <matchData+0x93>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x138,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"USER \00"
@.str.1 = [6 x i8] c"NICK \00"
@.str.2 = [38 x i8] c"USER %64s \22%64[^\22]\22 \22%64[^\22]\22 :%64s\0D\0A\00"
@.str.3 = [32 x i8] c"USER %64s %64s %64s :%64[^\0D\0A]\0D\0A\00"
define i32 @matchData(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [65 x i8]
%9 = alloca [65 x i8]
%10 = alloca [65 x i8]
%11 = alloca [65 x i8]
store i8* %0, i8** %4
store i64 %1, i64* %5
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %6
%14 = load i8*, i8** %4
%15 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %7
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %41
18: ; preds = %2
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %41
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%24 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [65 x i8], [65 x i8]* %10, i64 0, i64 0
%26 = getelementptr inbounds [65 x i8], [65 x i8]* %11, i64 0, i64 0
%27 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24, i8* %25, i8* %26)
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 1, i32* %3
br label %42
30: ; preds = %21
%31 = load i8*, i8** %6
%32 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%34 = getelementptr inbounds [65 x i8], [65 x i8]* %10, i64 0, i64 0
%35 = getelementptr inbounds [65 x i8], [65 x i8]* %11, i64 0, i64 0
%36 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %33, i8* %34, i8* %35)
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %39
38: ; preds = %30
store i32 1, i32* %3
br label %42
39: ; preds = %30
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40, %18, %2
store i32 0, i32* %3
br label %42
42: ; preds = %41, %38, %29
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"USER \00"
@.str.1 = [6 x i8] c"NICK \00"
@.str.2 = [38 x i8] c"USER %64s \22%64[^\22]\22 \22%64[^\22]\22 :%64s\0D\0A\00"
@.str.3 = [32 x i8] c"USER %64s %64s %64s :%64[^\0D\0A]\0D\0A\00"
define i32 @matchData(i8* %0, i64 %1) {
%3 = alloca [65 x i8]
%4 = alloca [65 x i8]
%5 = alloca [65 x i8]
%6 = alloca [65 x i8]
%7 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 0
%13 = icmp ne i8* %7, null
%14 = icmp ne i8* %8, null
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10, i8* %11, i8* %12)
%18 = icmp eq i32 %17, 4
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %10, i8* %11, i8* %12)
%21 = icmp eq i32 %20, 4
br i1 %21, label %23, label %22
22: ; preds = %19, %2
br label %23
23: ; preds = %19, %16, %22
%24 = phi i32 [ 0, %22 ], [ 1, %16 ], [ 1, %19 ]
ret i32 %24
}