#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*/ uint16_t;

/* Variables and functions */
int ntohs(int /*<<< orphan*/ const);
int is_channel_msg_str(const unsigned char *buf, size_t blen) {
  return (buf && blen >= 4 &&
          ((ntohs(((const uint16_t *)buf)[0])) >= 0x4000 &&
           (ntohs(((const uint16_t *)buf)[0])) <= 0x7FFF));
}


x86 assembly (clang, -O0):
<is_channel_msg_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     117a <is_channel_msg_str+0x6a>
xor    %eax,%eax
cmpq   $0x4,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jb     117a <is_channel_msg_str+0x6a>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <ntohs@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4000,%ecx
mov    %al,-0x12(%rbp)
jl     1174 <is_channel_msg_str+0x64>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <ntohs@plt>
cmp    $0x7fff,%eax
setle  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_channel_msg_str>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1143 <is_channel_msg_str+0x33>
cmp    $0x4,%rsi
jb     1143 <is_channel_msg_str+0x33>
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <ntohs@plt>
cmp    $0x4000,%eax
jl     1143 <is_channel_msg_str+0x33>
mov    (%rbx),%edi
call   1030 <ntohs@plt>
xor    %ebp,%ebp
cmp    $0x8000,%eax
setl   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_channel_msg_str(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %26
7: ; preds = %2
%8 = load i64, i64* %4
%9 = icmp uge i64 %8, 4
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = bitcast i8* %11 to i32*
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = call i32 @ntohs(i32 %14)
%16 = icmp sge i32 %15, 16384
br i1 %16, label %17, label %24
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = bitcast i8* %18 to i32*
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = call i32 @ntohs(i32 %21)
%23 = icmp sle i32 %22, 32767
br label %24
24: ; preds = %17, %10
%25 = phi i1 [ false, %10 ], [ %23, %17 ]
br label %26
26: ; preds = %24, %7, %2
%27 = phi i1 [ false, %7 ], [ false, %2 ], [ %25, %24 ]
%28 = zext i1 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
define i32 @is_channel_msg_str(i8* %0, i64 %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ugt i64 %1, 3
%5 = and i1 %3, %4
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = bitcast i8* %0 to i32*
%8 = load i32, i32* %7
%9 = tail call i32 @ntohs(i32 %8)
%10 = icmp sgt i32 %9, 16383
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load i32, i32* %7
%13 = tail call i32 @ntohs(i32 %12)
%14 = icmp slt i32 %13, 32768
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %6, %11, %2
%17 = phi i32 [ 0, %2 ], [ 0, %6 ], [ %15, %11 ]
ret i32 %17
}