#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 */
unsigned char Z_DEFLATED;
int is_zlib(unsigned char *buf) {
  int result = 0;
  if ((*buf & 0xf) == Z_DEFLATED)
    if ((*buf >> 4) + 8 <= 15)
      if (!(((*buf << 8) + *(buf + 1)) % 31))
        result = 1;
  return result;
}


x86 assembly (clang, -O0):
<is_zlib>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
mov    0x2ec0(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1177 <is_zlib+0x77>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
add    $0x8,%eax
cmp    $0xf,%eax
jg     1172 <is_zlib+0x72>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
mov    $0x1f,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116d <is_zlib+0x6d>
movl   $0x1,-0xc(%rbp)
jmp    1172 <is_zlib+0x72>
jmp    1177 <is_zlib+0x77>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_zlib>:
mov    (%rdi),%dl
movzbl %dl,%ecx
mov    %ecx,%esi
and    $0xf,%esi
mov    0x2ecf(%rip),%rax
movzbl (%rax),%r8d
xor    %eax,%eax
cmp    %r8d,%esi
jne    113a <is_zlib+0x3a>
test   %dl,%dl
js     113a <is_zlib+0x3a>
shl    $0x8,%ecx
movzbl 0x1(%rdi),%eax
or     %ecx,%eax
imul   $0xbdef7bdf,%eax,%ecx
xor    %eax,%eax
cmp    $0x8421085,%ecx
setb   %al
ret

LLVM IR (-O0):
@Z_DEFLATED = global i8 0
define i32 @is_zlib(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = and i32 %6, 15
%8 = load i8, i8* @Z_DEFLATED
%9 = zext i8 %8 to i32
%10 = icmp eq i32 %7, %9
br i1 %10, label %11, label %33
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 4
%16 = add nsw i32 %15, 8
%17 = icmp sle i32 %16, 15
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = shl i32 %21, 8
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = add nsw i32 %22, %26
%28 = srem i32 %27, 31
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %18
store i32 1, i32* %3
br label %31
31: ; preds = %30, %18
br label %32
32: ; preds = %31, %11
br label %33
33: ; preds = %32, %1
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@Z_DEFLATED = global i8 0
define i32 @is_zlib(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = and i32 %3, 15
%5 = load i8, i8* @Z_DEFLATED
%6 = zext i8 %5 to i32
%7 = icmp eq i32 %4, %6
%8 = icmp sgt i8 %2, -1
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = shl nuw nsw i32 %3, 8
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = or i32 %11, %14
%16 = urem i32 %15, 31
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %10, %1
%20 = phi i32 [ 0, %1 ], [ %18, %10 ]
ret i32 %20
}