#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 uint8_t;

/* Variables and functions */
bool checkjpg(uint8_t block[512]) {
  return (block[0] == 0xff && block[1] == 0xd8 && block[2] == 0xff &&
          (block[3] == 0xe0 || block[3] == 0xe1));
}


x86 assembly (clang, -O0):
<checkjpg>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpl   $0xff,(%rcx)
mov    %al,-0x9(%rbp)
jne    1176 <checkjpg+0x76>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpl   $0xd8,0x4(%rcx)
mov    %al,-0x9(%rbp)
jne    1176 <checkjpg+0x76>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpl   $0xff,0x8(%rcx)
mov    %al,-0x9(%rbp)
jne    1176 <checkjpg+0x76>
mov    -0x8(%rbp),%rcx
mov    $0x1,%al
cmpl   $0xe0,0xc(%rcx)
mov    %al,-0xa(%rbp)
je     1170 <checkjpg+0x70>
mov    -0x8(%rbp),%rax
cmpl   $0xe1,0xc(%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
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkjpg>:
xor    %eax,%eax
cmpl   $0xff,(%rdi)
jne    1137 <checkjpg+0x37>
cmpl   $0xd8,0x4(%rdi)
jne    1137 <checkjpg+0x37>
cmpl   $0xff,0x8(%rdi)
jne    1137 <checkjpg+0x37>
mov    0xc(%rdi),%ecx
mov    $0x1,%eax
cmp    $0xe0,%ecx
je     1137 <checkjpg+0x37>
xor    %eax,%eax
cmp    $0xe1,%ecx
sete   %al
ret

LLVM IR (-O0):
define i32 @checkjpg(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = getelementptr inbounds i32, i32* %3, i64 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 255
br i1 %6, label %7, label %29
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 216
br i1 %11, label %12, label %29
12: ; preds = %7
%13 = load i32*, i32** %2
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 255
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 3
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 224
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = load i32*, i32** %2
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 225
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ true, %17 ], [ %26, %22 ]
br label %29
29: ; preds = %27, %12, %7, %1
%30 = phi i1 [ false, %12 ], [ false, %7 ], [ false, %1 ], [ %28, %27 ]
%31 = zext i1 %30 to i32
ret i32 %31
}

LLVM IR (-O2):
define i32 @checkjpg(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 255
br i1 %3, label %4, label %19
4: ; preds = %1
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 216
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 255
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 224
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = icmp eq i32 %14, 225
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %12, %16, %8, %4, %1
%20 = phi i32 [ 0, %8 ], [ 0, %4 ], [ 0, %1 ], [ 1, %12 ], [ %18, %16 ]
ret i32 %20
}