#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int isBadPayload(const char *pPayload, int numBytes) {
  int i = 0;
  fprintf(stderr, "Payload: checking %d bytes\n", numBytes);
  for (; i < numBytes; i++) {
    if (((pPayload[i] & 0x80) == 0x80) || (pPayload[i] == 0x7F) ||
        (pPayload[i] <= 0x1F))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isBadPayload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xec7(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11af <isBadPayload+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0x80,%eax
cmp    $0x80,%eax
je     1190 <isBadPayload+0x80>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
je     1190 <isBadPayload+0x80>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1f,%eax
jg     119c <isBadPayload+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <isBadPayload+0xa6>
jmp    11a1 <isBadPayload+0x91>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <isBadPayload+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBadPayload>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
lea    0xed8(%rip),%rsi
mov    %ebp,%edx
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    1155 <isBadPayload+0x45>
mov    %ebp,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movzbl (%rbx,%rcx,1),%edx
add    $0x81,%dl
cmp    $0xa0,%dl
jbe    1159 <isBadPayload+0x49>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1140 <isBadPayload+0x30>
xor    %eax,%eax
jmp    115e <isBadPayload+0x4e>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Payload: checking %d bytes\0A\00"
define i32 @isBadPayload(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* @stderr
%8 = load i32, i32* %5
%9 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %41, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %44
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = and i32 %20, 128
%22 = icmp eq i32 %21, 128
br i1 %22, label %39, label %23
23: ; preds = %14
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 127
br i1 %30, label %39, label %31
31: ; preds = %23
%32 = load i8*, i8** %4
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp sle i32 %37, 31
br i1 %38, label %39, label %40
39: ; preds = %31, %23, %14
store i32 1, i32* %3
br label %45
40: ; preds = %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %10
44: ; preds = %10
store i32 0, i32* %3
br label %45
45: ; preds = %44, %39
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Payload: checking %d bytes\0A\00"
define i32 @isBadPayload(i8* nocapture %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %16, %7
br i1 %9, label %17, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 0, %6 ], [ %16, %8 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = add i8 %13, -127
%15 = icmp ult i8 %14, -95
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %17, label %8
17: ; preds = %10, %8, %2
%18 = phi i32 [ 0, %2 ], [ 0, %8 ], [ 1, %10 ]
ret i32 %18
}