#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 */
struct jpeg_parser {
  int dummy;
};

/* Variables and functions */
scalar_t__ jpeg_parser_get_marker(struct jpeg_parser *, unsigned char **,
                                  int *);
int jpeg_parser_get_APP4_marker(struct jpeg_parser *handle,
                                unsigned char **marker, int *marker_length) {
  while (jpeg_parser_get_marker(handle, marker, marker_length)) {
    if ((*marker)[0] == 0xFF && (*marker)[1] == 0xE4) {
      (*marker) += 4;
      (*marker_length) -= 4;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<jpeg_parser_get_APP4_marker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <jpeg_parser_get_marker@plt>
cmp    $0x0,%rax
je     1194 <jpeg_parser_get_APP4_marker+0x84>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    118f <jpeg_parser_get_APP4_marker+0x7f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movzbl 0x1(%rax),%eax
cmp    $0xe4,%eax
jne    118f <jpeg_parser_get_APP4_marker+0x7f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sub    $0x4,%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119b <jpeg_parser_get_APP4_marker+0x8b>
jmp    1124 <jpeg_parser_get_APP4_marker+0x14>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jpeg_parser_get_APP4_marker>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <jpeg_parser_get_marker@plt>
xor    %r15d,%r15d
jmp    113e <jpeg_parser_get_APP4_marker+0x2e>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <jpeg_parser_get_marker@plt>
test   %rax,%rax
je     1162 <jpeg_parser_get_APP4_marker+0x52>
mov    (%rbx),%rax
cmpb   $0xff,(%rax)
jne    1130 <jpeg_parser_get_APP4_marker+0x20>
cmpb   $0xe4,0x1(%rax)
jne    1130 <jpeg_parser_get_APP4_marker+0x20>
add    $0x4,%rax
mov    %rax,(%rbx)
addl   $0xfffffffc,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.jpeg_parser = type { i32 }
define i32 @jpeg_parser_get_APP4_marker(%struct.jpeg_parser* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca %struct.jpeg_parser*
%6 = alloca i8**
%7 = alloca i32*
store %struct.jpeg_parser* %0, %struct.jpeg_parser** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
br label %8
8: ; preds = %35, %3
%9 = load %struct.jpeg_parser*, %struct.jpeg_parser** %5
%10 = load i8**, i8*** %6
%11 = load i32*, i32** %7
%12 = call i64 @jpeg_parser_get_marker(%struct.jpeg_parser* %9, i8** %10, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %36
14: ; preds = %8
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 255
br i1 %20, label %21, label %35
21: ; preds = %14
%22 = load i8**, i8*** %6
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = icmp eq i32 %26, 228
br i1 %27, label %28, label %35
28: ; preds = %21
%29 = load i8**, i8*** %6
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 4
store i8* %31, i8** %29
%32 = load i32*, i32** %7
%33 = load i32, i32* %32
%34 = sub nsw i32 %33, 4
store i32 %34, i32* %32
store i32 1, i32* %4
br label %37
35: ; preds = %21, %14
br label %8
36: ; preds = %8
store i32 0, i32* %4
br label %37
37: ; preds = %36, %28
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
%struct.jpeg_parser = type { i32 }
define i32 @jpeg_parser_get_APP4_marker(%struct.jpeg_parser* %0, i8** %1, i32* %2) {
%4 = tail call i64 @jpeg_parser_get_marker(%struct.jpeg_parser* %0, i8** %1, i32* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3, %18
%7 = load i8*, i8** %1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, -1
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, -28
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %7, i64 4
store i8* %15, i8** %1
%16 = load i32, i32* %2
%17 = add nsw i32 %16, -4
store i32 %17, i32* %2
br label %21
18: ; preds = %10, %6
%19 = tail call i64 @jpeg_parser_get_marker(%struct.jpeg_parser* %0, i8** %1, i32* %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %18, %3, %14
%22 = phi i32 [ 1, %14 ], [ 0, %3 ], [ 0, %18 ]
ret i32 %22
}