#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 */
scalar_t__ memcmp(unsigned char *, char *, int);
int find_lzma_header(unsigned char *buf) {
  return (buf[0] < 0xE1 && buf[0] == 0x5d && buf[4] < 0x20 &&
          (memcmp(buf + 10, "\x00\x00\x00", 3) == 0 ||
           (memcmp(buf + 5, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8) == 0)));
}


x86 assembly (clang, -O0):
<find_lzma_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xe1,%ecx
mov    %al,-0x9(%rbp)
jge    11b3 <find_lzma_header+0xa3>
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5d,%ecx
mov    %al,-0x9(%rbp)
jne    11b3 <find_lzma_header+0xa3>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x9(%rbp)
jge    11b3 <find_lzma_header+0xa3>
mov    -0x8(%rbp),%rdi
add    $0xa,%rdi
lea    0xe92(%rip),%rsi
mov    $0x3,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xa(%rbp)
je     11ad <find_lzma_header+0x9d>
mov    -0x8(%rbp),%rdi
add    $0x5,%rdi
lea    0xe6b(%rip),%rsi
mov    $0x8,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_lzma_header>:
push   %rbx
xor    %eax,%eax
cmpb   $0x5d,(%rdi)
jne    115e <find_lzma_header+0x4e>
mov    %rdi,%rbx
cmpb   $0x1f,0x4(%rdi)
ja     115e <find_lzma_header+0x4e>
lea    0xa(%rbx),%rdi
lea    0xed4(%rip),%rsi
mov    $0x3,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1160 <find_lzma_header+0x50>
add    $0x5,%rbx
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] zeroinitializer
@.str.1 = [9 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\00"
define i32 @find_lzma_header(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = icmp slt i32 %6, 225
br i1 %7, label %8, label %32
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 93
br i1 %13, label %14, label %32
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 4
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %32
20: ; preds = %14
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 10
%23 = call i64 @memcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 5
%28 = call i64 @memcmp(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%29 = icmp eq i64 %28, 0
br label %30
30: ; preds = %25, %20
%31 = phi i1 [ true, %20 ], [ %29, %25 ]
br label %32
32: ; preds = %30, %14, %8, %1
%33 = phi i1 [ false, %14 ], [ false, %8 ], [ false, %1 ], [ %31, %30 ]
%34 = zext i1 %33 to i32
ret i32 %34
}

LLVM IR (-O2):
@.str = [4 x i8] zeroinitializer
@.str.1 = [9 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\00"
define i32 @find_lzma_header(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 93
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 4
%6 = load i8, i8* %5
%7 = icmp ult i8 %6, 32
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 10
%10 = tail call i64 @memcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 5
%14 = tail call i64 @memcmp(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %8, %12, %4, %1
%18 = phi i32 [ 0, %4 ], [ 0, %1 ], [ 1, %8 ], [ %16, %12 ]
ret i32 %18
}