#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 */
int /*<<< orphan*/ decomp_8x8(unsigned char *, unsigned char *, int *, int *,
                              int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ stderr;
int ov511_decomp_420(unsigned char *pIn, unsigned char *pOut,
                     unsigned char *pTmp, int w, int h, int inSize) {
  int numpix = w * h;
  unsigned char *pY = pOut;
  unsigned char *pU = pY + numpix;
  unsigned char *pV = pU + numpix / 4;
  int b, xY = 0, xUV = 0, iY = 0, iU = 0, iV = 0, iIn = 0;
  const int nBlocks = (w * h) / (32 * 8);
  fprintf(stderr, "decomp_420 : w=%d h=%d\n", w, h);
  for (b = 0; b < nBlocks; b++) {
    decomp_8x8(pIn, pU, &iIn, &iU, w / 2, 2);
    decomp_8x8(pIn, pV, &iIn, &iV, w / 2, 2);
    xUV += 16;
    if (xUV >= w) {
      iU += (w * 7) / 2;
      iV += (w * 7) / 2;
      xUV = 0;
    }
    decomp_8x8(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    decomp_8x8(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    if (xY >= w) {
      iY += w * 7;
      xY = 0;
    }
    decomp_8x8(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    decomp_8x8(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    if (xY >= w) {
      iY += w * 7;
      xY = 0;
    }
  }
  return (numpix * 3 / 2);
}


x86 assembly (clang, -O0):
<ov511_decomp_420>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0x60(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x60(%rbp),%eax
jge    136c <ov511_decomp_420+0x24c>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x54(%rbp),%rcx
mov    $0x2,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x58(%rbp),%rcx
mov    $0x2,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x4c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     127f <ov511_decomp_420+0x15f>
imul   $0x7,-0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
imul   $0x7,-0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     12ec <ov511_decomp_420+0x1cc>
imul   $0x7,-0x1c(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
lea    -0x5c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1359 <ov511_decomp_420+0x239>
imul   $0x7,-0x1c(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x48(%rbp)
jmp    135e <ov511_decomp_420+0x23e>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11e1 <ov511_decomp_420+0xc1>
imul   $0x3,-0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ov511_decomp_420>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,0x40(%rsp)
mov    %rdi,%r13
mov    %r8d,%r12d
imul   %ecx,%r12d
lea    0x3(%r12),%r14d
lea    0xff(%r12),%ebx
test   %r12d,%r12d
cmovns %r12d,%r14d
cmovns %r12d,%ebx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x2c(%rsp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %rcx,0x38(%rsp)
mov    %ecx,%edx
mov    %r8d,%ecx
call   1040 <fprintf@plt>
mov    %r12,%rax
mov    %r12,0x30(%rsp)
cmp    $0x100,%r12d
jl     1321 <ov511_decomp_420+0x201>
movslq 0x30(%rsp),%rax
add    0x40(%rsp),%rax
sar    $0x2,%r14d
movslq %r14d,%rcx
mov    %rax,0x50(%rsp)
add    %rax,%rcx
mov    %rcx,0x48(%rsp)
sar    $0x8,%ebx
mov    0x38(%rsp),%rcx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
mov    %eax,0x20(%rsp)
lea    0x0(,%rcx,8),%eax
sub    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
mov    %eax,0x10(%rsp)
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x1c(%rsp)
xor    %ebp,%ebp
lea    0x2c(%rsp),%r15
xor    %r14d,%r14d
mov    0x40(%rsp),%r12
jmp    1221 <ov511_decomp_420+0x101>
nopw   0x0(%rax,%rax,1)
mov    0x28(%rsp),%ebx
add    $0xffffffff,%ebx
mov    0x24(%rsp),%ebp
je     1321 <ov511_decomp_420+0x201>
mov    %ebx,0x28(%rsp)
mov    %r13,%rdi
mov    0x50(%rsp),%rsi
mov    %r15,%rdx
lea    0x18(%rsp),%rcx
mov    0x20(%rsp),%ebx
mov    %ebx,%r8d
mov    $0x2,%r9d
call   1030 <decomp_8x8@plt>
mov    %r13,%rdi
mov    0x48(%rsp),%rsi
mov    %r15,%rdx
lea    0x14(%rsp),%rcx
mov    %ebx,%r8d
mov    $0x2,%r9d
call   1030 <decomp_8x8@plt>
add    $0x10,%ebp
mov    0x38(%rsp),%rbx
cmp    %ebx,%ebp
jl     127f <ov511_decomp_420+0x15f>
mov    0x1c(%rsp),%eax
add    %eax,0x18(%rsp)
add    %eax,0x14(%rsp)
xor    %ebp,%ebp
mov    %ebp,0x24(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
lea    0xc(%rsp),%rbp
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
add    $0x10,%r14d
cmp    %ebx,%r14d
jl     12d0 <ov511_decomp_420+0x1b0>
mov    0x10(%rsp),%eax
add    %eax,0xc(%rsp)
xor    %r14d,%r14d
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    $0x1,%r9d
call   1030 <decomp_8x8@plt>
add    $0x10,%r14d
cmp    %ebx,%r14d
jl     1210 <ov511_decomp_420+0xf0>
mov    0x10(%rsp),%eax
add    %eax,0xc(%rsp)
xor    %r14d,%r14d
jmp    1210 <ov511_decomp_420+0xf0>
mov    0x30(%rsp),%rax
lea    (%rax,%rax,2),%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"decomp_420 : w=%d h=%d\0A\00"
define i32 @ov511_decomp_420(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = mul nsw i32 %25, %26
store i32 %27, i32* %13
%28 = load i8*, i8** %8
store i8* %28, i8** %14
%29 = load i8*, i8** %14
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8* %32, i8** %15
%33 = load i8*, i8** %15
%34 = load i32, i32* %13
%35 = sdiv i32 %34, 4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8* %37, i8** %16
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
%38 = load i32, i32* %10
%39 = load i32, i32* %11
%40 = mul nsw i32 %38, %39
%41 = sdiv i32 %40, 256
store i32 %41, i32* %24
%42 = load i32, i32* @stderr
%43 = load i32, i32* %10
%44 = load i32, i32* %11
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %44)
store i32 0, i32* %17
br label %46
46: ; preds = %120, %6
%47 = load i32, i32* %17
%48 = load i32, i32* %24
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %123
50: ; preds = %46
%51 = load i8*, i8** %7
%52 = load i8*, i8** %15
%53 = load i32, i32* %10
%54 = sdiv i32 %53, 2
%55 = call i32 @decomp_8x8(i8* %51, i8* %52, i32* %23, i32* %21, i32 %54, i32 2)
%56 = load i8*, i8** %7
%57 = load i8*, i8** %16
%58 = load i32, i32* %10
%59 = sdiv i32 %58, 2
%60 = call i32 @decomp_8x8(i8* %56, i8* %57, i32* %23, i32* %22, i32 %59, i32 2)
%61 = load i32, i32* %19
%62 = add nsw i32 %61, 16
store i32 %62, i32* %19
%63 = load i32, i32* %19
%64 = load i32, i32* %10
%65 = icmp sge i32 %63, %64
br i1 %65, label %66, label %77
66: ; preds = %50
%67 = load i32, i32* %10
%68 = mul nsw i32 %67, 7
%69 = sdiv i32 %68, 2
%70 = load i32, i32* %21
%71 = add nsw i32 %70, %69
store i32 %71, i32* %21
%72 = load i32, i32* %10
%73 = mul nsw i32 %72, 7
%74 = sdiv i32 %73, 2
%75 = load i32, i32* %22
%76 = add nsw i32 %75, %74
store i32 %76, i32* %22
store i32 0, i32* %19
br label %77
77: ; preds = %66, %50
%78 = load i8*, i8** %7
%79 = load i8*, i8** %14
%80 = load i32, i32* %10
%81 = call i32 @decomp_8x8(i8* %78, i8* %79, i32* %23, i32* %20, i32 %80, i32 1)
%82 = load i32, i32* %18
%83 = add nsw i32 %82, 8
store i32 %83, i32* %18
%84 = load i8*, i8** %7
%85 = load i8*, i8** %14
%86 = load i32, i32* %10
%87 = call i32 @decomp_8x8(i8* %84, i8* %85, i32* %23, i32* %20, i32 %86, i32 1)
%88 = load i32, i32* %18
%89 = add nsw i32 %88, 8
store i32 %89, i32* %18
%90 = load i32, i32* %18
%91 = load i32, i32* %10
%92 = icmp sge i32 %90, %91
br i1 %92, label %93, label %98
93: ; preds = %77
%94 = load i32, i32* %10
%95 = mul nsw i32 %94, 7
%96 = load i32, i32* %20
%97 = add nsw i32 %96, %95
store i32 %97, i32* %20
store i32 0, i32* %18
br label %98
98: ; preds = %93, %77
%99 = load i8*, i8** %7
%100 = load i8*, i8** %14
%101 = load i32, i32* %10
%102 = call i32 @decomp_8x8(i8* %99, i8* %100, i32* %23, i32* %20, i32 %101, i32 1)
%103 = load i32, i32* %18
%104 = add nsw i32 %103, 8
store i32 %104, i32* %18
%105 = load i8*, i8** %7
%106 = load i8*, i8** %14
%107 = load i32, i32* %10
%108 = call i32 @decomp_8x8(i8* %105, i8* %106, i32* %23, i32* %20, i32 %107, i32 1)
%109 = load i32, i32* %18
%110 = add nsw i32 %109, 8
store i32 %110, i32* %18
%111 = load i32, i32* %18
%112 = load i32, i32* %10
%113 = icmp sge i32 %111, %112
br i1 %113, label %114, label %119
114: ; preds = %98
%115 = load i32, i32* %10
%116 = mul nsw i32 %115, 7
%117 = load i32, i32* %20
%118 = add nsw i32 %117, %116
store i32 %118, i32* %20
store i32 0, i32* %18
br label %119
119: ; preds = %114, %98
br label %120
120: ; preds = %119
%121 = load i32, i32* %17
%122 = add nsw i32 %121, 1
store i32 %122, i32* %17
br label %46
123: ; preds = %46
%124 = load i32, i32* %13
%125 = mul nsw i32 %124, 3
%126 = sdiv i32 %125, 2
ret i32 %126
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"decomp_420 : w=%d h=%d\0A\00"
define i32 @ov511_decomp_420(i8* %0, i8* %1, i8* nocapture readnone %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = mul nsw i32 %4, %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = sdiv i32 %11, 4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%18 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%19 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%20 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%21 = sdiv i32 %11, 256
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%24 = icmp sgt i32 %11, 255
br i1 %24, label %25, label %64
25: ; preds = %6
%26 = sdiv i32 %3, 2
%27 = mul nsw i32 %3, 7
%28 = sdiv i32 %27, 2
br label %29
29: ; preds = %25, %60
%30 = phi i32 [ 0, %25 ], [ %62, %60 ]
%31 = phi i32 [ 0, %25 ], [ %43, %60 ]
%32 = phi i32 [ 0, %25 ], [ %61, %60 ]
%33 = call i32 @decomp_8x8(i8* %0, i8* %13, i32* %10, i32* %8, i32 %26, i32 2)
%34 = call i32 @decomp_8x8(i8* %0, i8* %16, i32* %10, i32* %9, i32 %26, i32 2)
%35 = add nsw i32 %31, 16
%36 = icmp slt i32 %35, %3
br i1 %36, label %42, label %37
37: ; preds = %29
%38 = load i32, i32* %8
%39 = add nsw i32 %38, %28
store i32 %39, i32* %8
%40 = load i32, i32* %9
%41 = add nsw i32 %40, %28
store i32 %41, i32* %9
br label %42
42: ; preds = %37, %29
%43 = phi i32 [ 0, %37 ], [ %35, %29 ]
%44 = call i32 @decomp_8x8(i8* %0, i8* %1, i32* %10, i32* %7, i32 %3, i32 1)
%45 = call i32 @decomp_8x8(i8* %0, i8* %1, i32* %10, i32* %7, i32 %3, i32 1)
%46 = add nsw i32 %32, 16
%47 = icmp slt i32 %46, %3
br i1 %47, label %51, label %48
48: ; preds = %42
%49 = load i32, i32* %7
%50 = add nsw i32 %49, %27
store i32 %50, i32* %7
br label %51
51: ; preds = %48, %42
%52 = phi i32 [ 0, %48 ], [ %46, %42 ]
%53 = call i32 @decomp_8x8(i8* %0, i8* %1, i32* %10, i32* %7, i32 %3, i32 1)
%54 = call i32 @decomp_8x8(i8* %0, i8* %1, i32* %10, i32* %7, i32 %3, i32 1)
%55 = add nsw i32 %52, 16
%56 = icmp slt i32 %55, %3
br i1 %56, label %60, label %57
57: ; preds = %51
%58 = load i32, i32* %7
%59 = add nsw i32 %58, %27
store i32 %59, i32* %7
br label %60
60: ; preds = %51, %57
%61 = phi i32 [ 0, %57 ], [ %55, %51 ]
%62 = add nuw nsw i32 %30, 1
%63 = icmp eq i32 %62, %21
br i1 %63, label %64, label %29
64: ; preds = %60, %6
%65 = mul nsw i32 %11, 3
%66 = sdiv i32 %65, 2
ret i32 %66
}