#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 packet_byte(int, char *);
int is_interesting_packet(char *packet) {
  unsigned int command = packet[0];
  int i, ret;
  switch (command) {
  case 0x11:
    return 0;
  case 0x5D:
  case 0x63:
    for (i = 1, ret = 0; i < 6; i++) {
      ret |= packet_byte(i, packet);
    }
    return ret > 0;
  case 0xB1:
    if (packet_byte(1, packet) != 0xff) {
      return 1;
    } else {
      for (i = 2, ret = 0; i < 9; i++) {
        ret |= packet_byte(i, packet);
      }
      return ret > 0;
    }
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<is_interesting_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x11,%eax
je     116f <is_interesting_packet+0x5f>
jmp    113a <is_interesting_packet+0x2a>
mov    -0x20(%rbp),%eax
sub    $0x5d,%eax
je     117b <is_interesting_packet+0x6b>
jmp    114b <is_interesting_packet+0x3b>
mov    -0x20(%rbp),%eax
sub    $0x63,%eax
je     117b <is_interesting_packet+0x6b>
jmp    115c <is_interesting_packet+0x4c>
mov    -0x20(%rbp),%eax
sub    $0xb1,%eax
je     11c7 <is_interesting_packet+0xb7>
jmp    1238 <is_interesting_packet+0x128>
movl   $0x0,-0x4(%rbp)
jmp    123f <is_interesting_packet+0x12f>
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    11b3 <is_interesting_packet+0xa3>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <packet_byte@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1189 <is_interesting_packet+0x79>
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <is_interesting_packet+0x12f>
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
call   1030 <packet_byte@plt>
cmp    $0xff,%eax
je     11ec <is_interesting_packet+0xdc>
movl   $0x1,-0x4(%rbp)
jmp    123f <is_interesting_packet+0x12f>
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x18(%rbp)
jge    1224 <is_interesting_packet+0x114>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <packet_byte@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fa <is_interesting_packet+0xea>
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <is_interesting_packet+0x12f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_interesting_packet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsbl (%rdi),%eax
cmp    $0x11,%eax
je     118c <is_interesting_packet+0x7c>
mov    %rdi,%rbx
cmp    $0x63,%eax
je     112c <is_interesting_packet+0x1c>
cmp    $0x5d,%eax
jne    1190 <is_interesting_packet+0x80>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <packet_byte@plt>
mov    %eax,%r14d
mov    $0x2,%edi
mov    %rbx,%rsi
call   1030 <packet_byte@plt>
mov    %eax,%r15d
or     %r14d,%r15d
mov    $0x3,%edi
mov    %rbx,%rsi
call   1030 <packet_byte@plt>
mov    %eax,%r14d
mov    $0x4,%edi
mov    %rbx,%rsi
call   1030 <packet_byte@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %r15d,%ebp
mov    $0x5,%edi
mov    %rbx,%rsi
call   1030 <packet_byte@plt>
mov    %eax,%ecx
xor    %eax,%eax
or     %ebp,%ecx
setg   %al
jmp    1195 <is_interesting_packet+0x85>
xor    %eax,%eax
jmp    1195 <is_interesting_packet+0x85>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_interesting_packet(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %4
%11 = load i32, i32* %4
switch i32 %11, label %52 [
i32 17, label %12
i32 93, label %13
i32 99, label %13
i32 177, label %30
]
12: ; preds = %1
store i32 0, i32* %2
br label %53
13: ; preds = %1, %1
store i32 1, i32* %5
store i32 0, i32* %6
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 6
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i32, i32* %5
%19 = load i8*, i8** %3
%20 = call i32 @packet_byte(i32 %18, i8* %19)
%21 = load i32, i32* %6
%22 = or i32 %21, %20
store i32 %22, i32* %6
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %14
26: ; preds = %14
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
%29 = zext i1 %28 to i32
store i32 %29, i32* %2
br label %53
30: ; preds = %1
%31 = load i8*, i8** %3
%32 = call i32 @packet_byte(i32 1, i8* %31)
%33 = icmp ne i32 %32, 255
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %2
br label %53
35: ; preds = %30
store i32 2, i32* %5
store i32 0, i32* %6
br label %36
36: ; preds = %45, %35
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 9
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32, i32* %5
%41 = load i8*, i8** %3
%42 = call i32 @packet_byte(i32 %40, i8* %41)
%43 = load i32, i32* %6
%44 = or i32 %43, %42
store i32 %44, i32* %6
br label %45
45: ; preds = %39
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %36
48: ; preds = %36
%49 = load i32, i32* %6
%50 = icmp sgt i32 %49, 0
%51 = zext i1 %50 to i32
store i32 %51, i32* %2
br label %53
52: ; preds = %1
store i32 1, i32* %2
br label %53
53: ; preds = %52, %48, %34, %26, %12
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
define i32 @is_interesting_packet(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %16 [
i32 17, label %17
i32 93, label %4
i32 99, label %4
]
4: ; preds = %1, %1
%5 = tail call i32 @packet_byte(i32 1, i8* %0)
%6 = tail call i32 @packet_byte(i32 2, i8* %0)
%7 = or i32 %6, %5
%8 = tail call i32 @packet_byte(i32 3, i8* %0)
%9 = or i32 %8, %7
%10 = tail call i32 @packet_byte(i32 4, i8* %0)
%11 = or i32 %10, %9
%12 = tail call i32 @packet_byte(i32 5, i8* %0)
%13 = or i32 %12, %11
%14 = icmp sgt i32 %13, 0
%15 = zext i1 %14 to i32
br label %17
16: ; preds = %1
br label %17
17: ; preds = %1, %16, %4
%18 = phi i32 [ 1, %16 ], [ %15, %4 ], [ 0, %1 ]
ret i32 %18
}