#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 *, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void decode_spca561(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) {
    for (i = 0; i < height; i++)
      memcpy(outbuf + i * width, tmpbuf + (i + 2) * (width + 6) + 3, width);
  }
}


x86 assembly (clang, -O0):
<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
jne    11b3 <decode_spca561+0x93>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ae <decode_spca561+0x8e>
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    0x2eaf(%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    115d <decode_spca561+0x3d>
jmp    11b3 <decode_spca561+0x93>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<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 <decode_spca561+0x6a>
test   %ebp,%ebp
jle    118a <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 <decode_spca561+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@decode_spca561.tmpbuf = internal global [318500 x i8] zeroinitializer
define void @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]* @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]* @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
}