#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*/ DecompressYHI(unsigned char *, unsigned char *, int *, int *,
                                 int const, int);
int Decompress420HiNoMMX(unsigned char *pIn, unsigned char *pOut, const int w,
                         const int h, const int inSize) {
  unsigned char *pY = pOut;
  unsigned char *pU = pY + w * h;
  unsigned char *pV = pU + w * h / 4;
  int xY, xUV, iY, iU, iV, iIn, count;
  const int nBlocks = (w * h) / (32 * 8);
  iIn = 0;
  iY = iU = iV = 0;
  xY = xUV = 0;
  for (count = 0; count < nBlocks; count++) {
    DecompressYHI(pIn, pU, &iIn, &iU, w / 2, 2);
    DecompressYHI(pIn, pV, &iIn, &iV, w / 2, 2);
    xUV += 16;
    if (xUV >= w) {
      iU += (w * 7) / 2;
      iV += (w * 7) / 2;
      xUV = 0;
    }
    DecompressYHI(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    DecompressYHI(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    if (xY >= w) {
      iY += w * 7;
      xY = 0;
    }
    DecompressYHI(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    DecompressYHI(pIn, pY, &iIn, &iY, w, 1);
    xY += 8;
    if (xY >= w) {
      iY += w * 7;
      xY = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<Decompress420HiNoMMX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    133c <Decompress420HiNoMMX+0x22c>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
lea    -0x50(%rbp),%rdx
lea    -0x48(%rbp),%rcx
mov    $0x2,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
lea    -0x50(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
mov    $0x2,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x40(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     124f <Decompress420HiNoMMX+0x13f>
imul   $0x7,-0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
imul   $0x7,-0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%r8d
lea    -0x50(%rbp),%rdx
lea    -0x44(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%r8d
lea    -0x50(%rbp),%rdx
lea    -0x44(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     12bc <Decompress420HiNoMMX+0x1ac>
imul   $0x7,-0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%r8d
lea    -0x50(%rbp),%rdx
lea    -0x44(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%r8d
lea    -0x50(%rbp),%rdx
lea    -0x44(%rbp),%rcx
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1329 <Decompress420HiNoMMX+0x219>
imul   $0x7,-0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    132e <Decompress420HiNoMMX+0x21e>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11b1 <Decompress420HiNoMMX+0xa1>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Decompress420HiNoMMX>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r15d
imul   %edx,%ecx
lea    0x3(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
lea    0xff(%rcx),%edx
cmovns %ecx,%edx
movl   $0x0,0x24(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x4(%rsp)
cmp    $0x100,%ecx
jl     12d4 <Decompress420HiNoMMX+0x1c4>
mov    %rsi,%r14
mov    %rdi,%r12
movslq %ecx,%rcx
add    %rsi,%rcx
sar    $0x2,%eax
cltq
mov    %rcx,0x30(%rsp)
add    %rcx,%rax
mov    %rax,0x28(%rsp)
sar    $0x8,%edx
mov    %r15d,%eax
shr    $0x1f,%eax
add    %r15d,%eax
sar    %eax
mov    %eax,0x1c(%rsp)
lea    0x0(,%r15,8),%eax
sub    %r15d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
mov    %eax,0x8(%rsp)
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x18(%rsp)
xor    %r13d,%r13d
lea    0x24(%rsp),%rbx
movl   $0x0,0xc(%rsp)
jmp    11cd <Decompress420HiNoMMX+0xbd>
nop
mov    0x20(%rsp),%edx
add    $0xffffffff,%edx
je     12d4 <Decompress420HiNoMMX+0x1c4>
mov    %edx,0x20(%rsp)
mov    %r14,%rbp
mov    %r12,%rdi
mov    0x30(%rsp),%rsi
mov    %rbx,%rdx
lea    0x14(%rsp),%rcx
mov    0x1c(%rsp),%r14d
mov    %r14d,%r8d
mov    $0x2,%r9d
call   1030 <DecompressYHI@plt>
mov    %r12,%rdi
mov    0x28(%rsp),%rsi
mov    %rbx,%rdx
lea    0x10(%rsp),%rcx
mov    %r14d,%r8d
mov    $0x2,%r9d
call   1030 <DecompressYHI@plt>
mov    0xc(%rsp),%eax
add    $0x10,%eax
cmp    %r15d,%eax
jl     122f <Decompress420HiNoMMX+0x11f>
mov    0x18(%rsp),%eax
add    %eax,0x14(%rsp)
add    %eax,0x10(%rsp)
xor    %eax,%eax
mov    %eax,0xc(%rsp)
mov    %r12,%rdi
mov    %rbp,%r14
mov    %rbp,%rsi
mov    %rbx,%rdx
lea    0x4(%rsp),%rbp
mov    %rbp,%rcx
mov    %r15d,%r8d
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r15d,%r8d
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
add    $0x10,%r13d
cmp    %r15d,%r13d
jl     1283 <Decompress420HiNoMMX+0x173>
mov    0x8(%rsp),%eax
add    %eax,0x4(%rsp)
xor    %r13d,%r13d
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r15d,%r8d
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r15d,%r8d
mov    $0x1,%r9d
call   1030 <DecompressYHI@plt>
add    $0x10,%r13d
cmp    %r15d,%r13d
jl     11c0 <Decompress420HiNoMMX+0xb0>
mov    0x8(%rsp),%eax
add    %eax,0x4(%rsp)
xor    %r13d,%r13d
jmp    11c0 <Decompress420HiNoMMX+0xb0>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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