#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 usb_spca50x {
  int dummy;
};
struct spca50x_frame {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ PDEBUG(int, char *, int);
int zc3xx_sofdetect(struct usb_spca50x *spca50x, struct spca50x_frame *frame,
                    unsigned char *cdata, int *iPix, int seqnum,
                    int *datalength) {
  if (cdata[0] == 0xFF && cdata[1] == 0xD8) {
    *iPix = 2;
    *datalength -= *iPix;
    return 0;
    PDEBUG(5, "Zc301 header packet found datalength %d !!", *datalength);
  }
  *iPix = 0;
  return (seqnum + 1);
}


x86 assembly (clang, -O0):
<zc3xx_sofdetect>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    1167 <zc3xx_sofdetect+0x67>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xd8,%eax
jne    1167 <zc3xx_sofdetect+0x67>
mov    -0x28(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    117a <zc3xx_sofdetect+0x7a>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<zc3xx_sofdetect>:
mov    %r8d,%eax
cmpb   $0xff,(%rdx)
jne    111b <zc3xx_sofdetect+0x1b>
cmpb   $0xd8,0x1(%rdx)
jne    111b <zc3xx_sofdetect+0x1b>
movl   $0x2,(%rcx)
addl   $0xfffffffe,(%r9)
xor    %eax,%eax
ret
movl   $0x0,(%rcx)
add    $0x1,%eax
ret

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

LLVM IR (-O2):
%struct.usb_spca50x = type { i32 }
%struct.spca50x_frame = type { i32 }
define i32 @zc3xx_sofdetect(%struct.usb_spca50x* nocapture readnone %0, %struct.spca50x_frame* nocapture readnone %1, i8* nocapture %2, i32* nocapture writeonly %3, i32 %4, i32* nocapture %5) {
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, -1
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %2, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, -40
br i1 %12, label %13, label %16
13: ; preds = %9
store i32 2, i32* %3
%14 = load i32, i32* %5
%15 = add nsw i32 %14, -2
store i32 %15, i32* %5
br label %18
16: ; preds = %9, %6
store i32 0, i32* %3
%17 = add nsw i32 %4, 1
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ 0, %13 ], [ %17, %16 ]
ret i32 %19
}