#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 e(char *);
int zget8();
int parse_zlib_header(void) {
  int cmf = zget8();
  int cm = cmf & 15;
  int flg = zget8();
  if ((cmf * 256 + flg) % 31 != 0)
    return e("bad zlib header");
  if (flg & 32)
    return e("no preset dict");
  if (cm != 8)
    return e("bad compression");
  return 1;
}


x86 assembly (clang, -O0):
<parse_zlib_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <zget8@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <zget8@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
add    -0x10(%rbp),%eax
mov    $0x1f,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1173 <parse_zlib_header+0x53>
lea    0xe9a(%rip),%rdi
call   1030 <e@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <parse_zlib_header+0x9b>
mov    -0x10(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1196 <parse_zlib_header+0x76>
lea    0xe87(%rip),%rdi
call   1030 <e@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <parse_zlib_header+0x9b>
cmpl   $0x8,-0xc(%rbp)
je     11b4 <parse_zlib_header+0x94>
lea    0xe78(%rip),%rdi
call   1030 <e@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <parse_zlib_header+0x9b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_zlib_header>:
push   %rbx
xor    %eax,%eax
call   1040 <zget8@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <zget8@plt>
mov    %ebx,%ecx
shl    $0x8,%ecx
add    %eax,%ecx
imul   $0xbdef7bdf,%ecx,%ecx
add    $0x4210842,%ecx
cmp    $0x8421084,%ecx
jbe    1159 <parse_zlib_header+0x39>
lea    0xead(%rip),%rdi
pop    %rbx
jmp    1030 <e@plt>
test   $0x20,%al
jne    116c <parse_zlib_header+0x4c>
and    $0xf,%ebx
cmp    $0x8,%ebx
jne    1179 <parse_zlib_header+0x59>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
pop    %rbx
jmp    1030 <e@plt>
lea    0xe9f(%rip),%rdi
pop    %rbx
jmp    1030 <e@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"bad zlib header\00"
@.str.1 = [15 x i8] c"no preset dict\00"
@.str.2 = [16 x i8] c"bad compression\00"
define i32 @parse_zlib_header() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @zget8()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 15
store i32 %7, i32* %3
%8 = call i32 (...) @zget8()
store i32 %8, i32* %4
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 256
%11 = load i32, i32* %4
%12 = add nsw i32 %10, %11
%13 = srem i32 %12, 31
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @e(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %1
br label %29
17: ; preds = %0
%18 = load i32, i32* %4
%19 = and i32 %18, 32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @e(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 %22, i32* %1
br label %29
23: ; preds = %17
%24 = load i32, i32* %3
%25 = icmp ne i32 %24, 8
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @e(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 %27, i32* %1
br label %29
28: ; preds = %23
store i32 1, i32* %1
br label %29
29: ; preds = %28, %26, %21, %15
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [16 x i8] c"bad zlib header\00"
@.str.1 = [15 x i8] c"no preset dict\00"
@.str.2 = [16 x i8] c"bad compression\00"
define i32 @parse_zlib_header() {
%1 = tail call i32 (...) @zget8()
%2 = and i32 %1, 15
%3 = tail call i32 (...) @zget8()
%4 = shl nsw i32 %1, 8
%5 = add nsw i32 %4, %3
%6 = srem i32 %5, 31
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = and i32 %3, 32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = icmp eq i32 %2, 8
br i1 %12, label %16, label %13
13: ; preds = %11, %8, %0
%14 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %11 ]
%15 = tail call i32 @e(i8* %14)
br label %16
16: ; preds = %13, %11
%17 = phi i32 [ 1, %11 ], [ %15, %13 ]
ret i32 %17
}