#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__ internal_spca561_decode(int, int, unsigned char const *,
                                   unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void v4lconvert_decode_spca561(const unsigned char *inbuf,
                               unsigned char *outbuf, int width, int height) {
  int i;
  static unsigned char tmpbuf[650 * 490];
  if (internal_spca561_decode(width, height, inbuf, tmpbuf) != 0)
    return;
  for (i = 0; i < height; i++)
    memcpy(outbuf + i * width, tmpbuf + (i + 2) * (width + 6) + 3, width);
}


x86 assembly (clang, -O0):
<v4lconvert_decode_spca561>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0x2ef9(%rip),%rcx
call   1030 <internal_spca561_decode@plt>
cmp    $0x0,%rax
je     115b <v4lconvert_decode_spca561+0x3b>
jmp    11b3 <v4lconvert_decode_spca561+0x93>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b3 <v4lconvert_decode_spca561+0x93>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    -0x14(%rbp),%ecx
add    $0x6,%ecx
imul   %ecx,%eax
cltq
lea    0x2eaa(%rip),%rsi
add    %rax,%rsi
add    $0x3,%rsi
mov    -0x14(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <v4lconvert_decode_spca561+0x42>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4lconvert_decode_spca561>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rdx
lea    0x2f03(%rip),%r15
mov    %r14d,%edi
mov    %ecx,%esi
mov    %r15,%rcx
call   1030 <internal_spca561_decode@plt>
test   %rax,%rax
jne    118a <v4lconvert_decode_spca561+0x6a>
test   %ebp,%ebp
jle    118a <v4lconvert_decode_spca561+0x6a>
movslq %r14d,%r12
lea    0x6(%r12),%r13
mov    %r15,%rax
mov    %ebp,%r15d
lea    (%rax,%r12,2),%rbp
add    $0xf,%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1040 <memcpy@plt>
add    %r13,%rbp
add    %r12,%rbx
add    $0xffffffffffffffff,%r15
jne    1170 <v4lconvert_decode_spca561+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@v4lconvert_decode_spca561.tmpbuf = internal global [318500 x i8] zeroinitializer
define void @v4lconvert_decode_spca561(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = load i8*, i8** %5
%13 = call i64 @internal_spca561_decode(i32 %10, i32 %11, i8* %12, i8* getelementptr inbounds ([318500 x i8], [318500 x i8]* @v4lconvert_decode_spca561.tmpbuf, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %4
br label %41
16: ; preds = %4
store i32 0, i32* %9
br label %17
17: ; preds = %38, %16
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = load i32, i32* %9
%24 = load i32, i32* %7
%25 = mul nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 2
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 6
%32 = mul nsw i32 %29, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* getelementptr inbounds ([318500 x i8], [318500 x i8]* @v4lconvert_decode_spca561.tmpbuf, i64 0, i64 0), i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 3
%36 = load i32, i32* %7
%37 = call i32 @memcpy(i8* %27, i8* %35, i32 %36)
br label %38
38: ; preds = %21
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %17
41: ; preds = %15, %17
ret void
}

LLVM IR (-O2):
@v4lconvert_decode_spca561.tmpbuf = internal global [318500 x i8] zeroinitializer
define void @v4lconvert_decode_spca561(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i64 @internal_spca561_decode(i32 %2, i32 %3, i8* %0, i8* getelementptr inbounds ([318500 x i8], [318500 x i8]* @v4lconvert_decode_spca561.tmpbuf, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = icmp sgt i32 %3, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %25
9: ; preds = %4
%10 = add nsw i32 %2, 6
%11 = sext i32 %2 to i64
%12 = sext i32 %10 to i64
%13 = zext i32 %3 to i64
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %23, %14 ]
%16 = mul nsw i64 %15, %11
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = add nuw nsw i64 %15, 2
%19 = mul nsw i64 %18, %12
%20 = getelementptr inbounds [318500 x i8], [318500 x i8]* @v4lconvert_decode_spca561.tmpbuf, i64 0, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 3
%22 = tail call i32 @memcpy(i8* %17, i8* %21, i32 %2)
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %25, label %14
25: ; preds = %14, %4
ret void
}