#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 */
typedef int /*<<< orphan*/ q;

/* Variables and functions */
int /*<<< orphan*/ memset(short *, int /*<<< orphan*/, int);
int /*<<< orphan*/ vp8_dc_only_idct_add_c(short, unsigned char *, int,
                                          unsigned char *, int);
int /*<<< orphan*/ vp8_dequant_idct_add_c(short *, short *, unsigned char *,
                                          int);
void vp8_dequant_idct_add_y_block_c(short *q, short *dq, unsigned char *dst,
                                    int stride, char *eobs) {
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
        vp8_dequant_idct_add_c(q, dq, dst, stride);
      else {
        vp8_dc_only_idct_add_c(q[0] * dq[0], dst, stride, dst, stride);
        memset(q, 0, 2 * sizeof(q[0]));
      }
      q += 16;
      dst += 4;
    }
    dst += 4 * stride - 16;
  }
}


x86 assembly (clang, -O0):
<vp8_dequant_idct_add_y_block_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    1224 <vp8_dequant_idct_add_y_block_c+0xf4>
movl   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x30(%rbp)
jge    11ff <vp8_dequant_idct_add_y_block_c+0xcf>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%eax
cmp    $0x1,%eax
jle    11a1 <vp8_dequant_idct_add_y_block_c+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1050 <vp8_dequant_idct_add_c@plt>
jmp    11d9 <vp8_dequant_idct_add_y_block_c+0xa9>
mov    -0x8(%rbp),%rax
movswl (%rax),%eax
mov    -0x10(%rbp),%rcx
movswl (%rcx),%ecx
imul   %ecx,%eax
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
movswl %ax,%edi
call   1030 <vp8_dc_only_idct_add_c@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1163 <vp8_dequant_idct_add_y_block_c+0x33>
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x10,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1152 <vp8_dequant_idct_add_y_block_c+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp8_dequant_idct_add_y_block_c>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r15
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,0x8(%rsp)
mov    %rdi,%r13
lea    -0x10(,%r14,4),%eax
ff
cltq
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
jmp    11a4 <vp8_dequant_idct_add_y_block_c+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    %rcx,%rdx
mov    %r14d,%ecx
call   1050 <vp8_dequant_idct_add_c@plt>
mov    0x10(%rsp),%rax
add    %rax,%rbx
add    $0x10,%rbx
sub    $0xffffffffffffff80,%r12
add    $0x4,%r15
cmp    $0x200,%r12d
je     1306 <vp8_dequant_idct_add_y_block_c+0x1d6>
lea    (%r12,%r13,1),%rbp
cmpb   $0x2,(%r15)
jl     11d0 <vp8_dequant_idct_add_y_block_c+0xa0>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1050 <vp8_dequant_idct_add_c@plt>
jmp    1200 <vp8_dequant_idct_add_y_block_c+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rax
movzwl (%rax),%eax
imul   0x0(%rbp),%ax
movswl %ax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1030 <vp8_dc_only_idct_add_c@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    (%r12,%r13,1),%rbp
add    $0x20,%rbp
lea    0x4(%rbx),%rcx
cmpb   $0x1,0x1(%r15)
jle    1230 <vp8_dequant_idct_add_y_block_c+0x100>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    %rcx,%rdx
mov    %r14d,%ecx
call   1050 <vp8_dequant_idct_add_c@plt>
jmp    125d <vp8_dequant_idct_add_y_block_c+0x12d>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
movzwl (%rax),%eax
imul   0x0(%rbp),%ax
movswl %ax,%edi
mov    %rcx,%rsi
mov    %r14d,%edx
mov    %r14d,%r8d
call   1030 <vp8_dc_only_idct_add_c@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    (%r12,%r13,1),%rbp
add    $0x40,%rbp
lea    0x8(%rbx),%rcx
cmpb   $0x1,0x2(%r15)
jle    1290 <vp8_dequant_idct_add_y_block_c+0x160>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    %rcx,%rdx
mov    %r14d,%ecx
call   1050 <vp8_dequant_idct_add_c@plt>
jmp    12bd <vp8_dequant_idct_add_y_block_c+0x18d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rax
movzwl (%rax),%eax
imul   0x0(%rbp),%ax
movswl %ax,%edi
mov    %rcx,%rsi
mov    %r14d,%edx
mov    %r14d,%r8d
call   1030 <vp8_dc_only_idct_add_c@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    (%r12,%r13,1),%rbp
add    $0x60,%rbp
lea    0xc(%rbx),%rcx
cmpb   $0x1,0x3(%r15)
jg     1170 <vp8_dequant_idct_add_y_block_c+0x40>
mov    0x8(%rsp),%rax
movzwl (%rax),%eax
imul   0x0(%rbp),%ax
movswl %ax,%edi
mov    %rcx,%rsi
mov    %r14d,%edx
mov    %r14d,%r8d
call   1030 <vp8_dc_only_idct_add_c@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
jmp    1183 <vp8_dequant_idct_add_y_block_c+0x53>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vp8_dequant_idct_add_y_block_c(i16* %0, i16* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i16* %0, i16** %6
store i16* %1, i16** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
store i32 0, i32* %11
br label %13
13: ; preds = %65, %5
%14 = load i32, i32* %11
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %68
16: ; preds = %13
store i32 0, i32* %12
br label %17
17: ; preds = %55, %16
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %58
20: ; preds = %17
%21 = load i8*, i8** %10
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %10
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i16*, i16** %6
%28 = load i16*, i16** %7
%29 = load i8*, i8** %8
%30 = load i32, i32* %9
%31 = call i32 @vp8_dequant_idct_add_c(i16* %27, i16* %28, i8* %29, i32 %30)
br label %50
32: ; preds = %20
%33 = load i16*, i16** %6
%34 = getelementptr inbounds i16, i16* %33, i64 0
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = load i16*, i16** %7
%38 = getelementptr inbounds i16, i16* %37, i64 0
%39 = load i16, i16* %38
%40 = sext i16 %39 to i32
%41 = mul nsw i32 %36, %40
%42 = trunc i32 %41 to i16
%43 = load i8*, i8** %8
%44 = load i32, i32* %9
%45 = load i8*, i8** %8
%46 = load i32, i32* %9
%47 = call i32 @vp8_dc_only_idct_add_c(i16 signext %42, i8* %43, i32 %44, i8* %45, i32 %46)
%48 = load i16*, i16** %6
%49 = call i32 @memset(i16* %48, i32 0, i32 4)
br label %50
50: ; preds = %32, %26
%51 = load i16*, i16** %6
%52 = getelementptr inbounds i16, i16* %51, i64 16
store i16* %52, i16** %6
%53 = load i8*, i8** %8
%54 = getelementptr inbounds i8, i8* %53, i64 4
store i8* %54, i8** %8
br label %55
55: ; preds = %50
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
br label %17
58: ; preds = %17
%59 = load i32, i32* %9
%60 = mul nsw i32 4, %59
%61 = sub nsw i32 %60, 16
%62 = load i8*, i8** %8
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds i8, i8* %62, i64 %63
store i8* %64, i8** %8
br label %65
65: ; preds = %58
%66 = load i32, i32* %11
%67 = add nsw i32 %66, 1
store i32 %67, i32* %11
br label %13
68: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @vp8_dequant_idct_add_y_block_c(i16* %0, i16* %1, i8* %2, i32 %3, i8* nocapture %4) {
%6 = shl nsw i32 %3, 2
%7 = add nsw i32 %6, -16
%8 = sext i32 %7 to i64
br label %9
9: ; preds = %5, %66
%10 = phi i32 [ 0, %5 ], [ %71, %66 ]
%11 = phi i8* [ %4, %5 ], [ %69, %66 ]
%12 = phi i16* [ %0, %5 ], [ %67, %66 ]
%13 = phi i8* [ %2, %5 ], [ %70, %66 ]
%14 = getelementptr inbounds i8, i8* %11, i64 1
%15 = load i8, i8* %11
%16 = icmp sgt i8 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = tail call i32 @vp8_dequant_idct_add_c(i16* %12, i16* %1, i8* %13, i32 %3)
br label %25
19: ; preds = %9
%20 = load i16, i16* %12
%21 = load i16, i16* %1
%22 = mul i16 %21, %20
%23 = tail call i32 @vp8_dc_only_idct_add_c(i16 signext %22, i8* %13, i32 %3, i8* %13, i32 %3)
%24 = tail call i32 @memset(i16* %12, i32 0, i32 4)
br label %25
25: ; preds = %19, %17
%26 = getelementptr inbounds i16, i16* %12, i64 16
%27 = getelementptr inbounds i8, i8* %13, i64 4
%28 = getelementptr inbounds i8, i8* %11, i64 2
%29 = load i8, i8* %14
%30 = icmp sgt i8 %29, 1
br i1 %30, label %37, label %31
31: ; preds = %25
%32 = load i16, i16* %26
%33 = load i16, i16* %1
%34 = mul i16 %33, %32
%35 = tail call i32 @vp8_dc_only_idct_add_c(i16 signext %34, i8* %27, i32 %3, i8* %27, i32 %3)
%36 = tail call i32 @memset(i16* %26, i32 0, i32 4)
br label %39
37: ; preds = %25
%38 = tail call i32 @vp8_dequant_idct_add_c(i16* %26, i16* %1, i8* %27, i32 %3)
br label %39
39: ; preds = %37, %31
%40 = getelementptr inbounds i16, i16* %12, i64 32
%41 = getelementptr inbounds i8, i8* %13, i64 8
%42 = getelementptr inbounds i8, i8* %11, i64 3
%43 = load i8, i8* %28
%44 = icmp sgt i8 %43, 1
br i1 %44, label %51, label %45
45: ; preds = %39
%46 = load i16, i16* %40
%47 = load i16, i16* %1
%48 = mul i16 %47, %46
%49 = tail call i32 @vp8_dc_only_idct_add_c(i16 signext %48, i8* %41, i32 %3, i8* %41, i32 %3)
%50 = tail call i32 @memset(i16* %40, i32 0, i32 4)
br label %53
51: ; preds = %39
%52 = tail call i32 @vp8_dequant_idct_add_c(i16* %40, i16* %1, i8* %41, i32 %3)
br label %53
53: ; preds = %51, %45
%54 = getelementptr inbounds i16, i16* %12, i64 48
%55 = getelementptr inbounds i8, i8* %13, i64 12
%56 = load i8, i8* %42
%57 = icmp sgt i8 %56, 1
br i1 %57, label %64, label %58
58: ; preds = %53
%59 = load i16, i16* %54
%60 = load i16, i16* %1
%61 = mul i16 %60, %59
%62 = tail call i32 @vp8_dc_only_idct_add_c(i16 signext %61, i8* %55, i32 %3, i8* %55, i32 %3)
%63 = tail call i32 @memset(i16* %54, i32 0, i32 4)
br label %66
64: ; preds = %53
%65 = tail call i32 @vp8_dequant_idct_add_c(i16* %54, i16* %1, i8* %55, i32 %3)
br label %66
66: ; preds = %64, %58
%67 = getelementptr inbounds i16, i16* %12, i64 64
%68 = getelementptr inbounds i8, i8* %13, i64 16
%69 = getelementptr i8, i8* %11, i64 4
%70 = getelementptr inbounds i8, i8* %68, i64 %8
%71 = add nuw nsw i32 %10, 1
%72 = icmp eq i32 %71, 4
br i1 %72, label %73, label %9
73: ; preds = %66
ret void
}