#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 int32_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ InverseDCTSubBlock(int *, int *);
int /*<<< orphan*/ MultSubBlocks(int *, int *, int const *, int /*<<< orphan*/);
int /*<<< orphan*/ TransposeSubBlock(int *, int *);
int /*<<< orphan*/ ZigZagSubBlock(int *, int *);
void decode_macroblock_ob(int16_t *macroblock, int32_t *y_dc, int32_t *u_dc,
                          int32_t *v_dc, const int16_t *qtable) {
  int sb;
  for (sb = 0; sb < 6; ++sb) {
    int16_t tmp_sb[64];
    int32_t dc = (int32_t)macroblock[0];
    switch (sb) {
    case 0:
    case 1:
    case 2:
    case 3:
      *y_dc += dc;
      macroblock[0] = *y_dc & 0xffff;
      break;
    case 4:
      *u_dc += dc;
      macroblock[0] = *u_dc & 0xffff;
      break;
    case 5:
      *v_dc += dc;
      macroblock[0] = *v_dc & 0xffff;
      break;
    }
    ZigZagSubBlock(tmp_sb, macroblock);
    if (qtable != NULL)
      MultSubBlocks(tmp_sb, tmp_sb, qtable, 0);
    TransposeSubBlock(macroblock, tmp_sb);
    InverseDCTSubBlock(macroblock, macroblock);
    macroblock += 64;
  }
}


x86 assembly (clang, -O0):
<decode_macroblock_ob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    1292 <decode_macroblock_ob+0x152>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x138(%rbp)
sub    $0x4,%eax
jb     11bb <decode_macroblock_ob+0x7b>
jmp    1193 <decode_macroblock_ob+0x53>
mov    -0x138(%rbp),%eax
sub    $0x4,%eax
je     11e0 <decode_macroblock_ob+0xa0>
jmp    11a7 <decode_macroblock_ob+0x67>
mov    -0x138(%rbp),%eax
sub    $0x5,%eax
je     1205 <decode_macroblock_ob+0xc5>
jmp    1225 <decode_macroblock_ob+0xe5>
mov    -0x134(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0xffff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1225 <decode_macroblock_ob+0xe5>
mov    -0x134(%rbp),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
and    $0xffff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1225 <decode_macroblock_ob+0xe5>
mov    -0x134(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
and    $0xffff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <ZigZagSubBlock@plt>
cmpq   $0x0,-0x28(%rbp)
je     1259 <decode_macroblock_ob+0x119>
lea    -0x130(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <MultSubBlocks@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1040 <TransposeSubBlock@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <InverseDCTSubBlock@plt>
mov    -0x8(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x8(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1166 <decode_macroblock_ob+0x26>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_macroblock_ob>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8,%r13
mov    %rcx,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %r14d,%r14d
lea    0x10(%rsp),%rbp
jmp    1197 <decode_macroblock_ob+0x57>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <TransposeSubBlock@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <InverseDCTSubBlock@plt>
add    $0x100,%rbx
add    $0x1,%r14d
cmp    $0x6,%r14d
je     11eb <decode_macroblock_ob+0xab>
mov    (%rbx),%eax
cmp    $0x4,%r14d
jae    11d0 <decode_macroblock_ob+0x90>
add    (%r12),%eax
mov    %eax,(%r12)
movzwl %ax,%eax
mov    %eax,(%rbx)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <ZigZagSubBlock@plt>
test   %r13,%r13
je     1170 <decode_macroblock_ob+0x30>
mov    %rbp,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
call   1030 <MultSubBlocks@plt>
jmp    1170 <decode_macroblock_ob+0x30>
xchg   %ax,%ax
je     11e3 <decode_macroblock_ob+0xa3>
cmp    $0x5,%r14d
jne    11ac <decode_macroblock_ob+0x6c>
mov    0x8(%rsp),%rcx
add    (%rcx),%eax
mov    %eax,(%rcx)
jmp    11a7 <decode_macroblock_ob+0x67>
add    (%r15),%eax
mov    %eax,(%r15)
jmp    11a7 <decode_macroblock_ob+0x67>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @decode_macroblock_ob(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca [64 x i32]
%13 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
store i32 0, i32* %11
br label %14
14: ; preds = %72, %5
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 6
br i1 %16, label %17, label %75
17: ; preds = %14
%18 = load i32*, i32** %6
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
store i32 %20, i32* %13
%21 = load i32, i32* %11
switch i32 %21, label %52 [
i32 0, label %22
i32 1, label %22
i32 2, label %22
i32 3, label %22
i32 4, label %32
i32 5, label %42
]
22: ; preds = %17, %17, %17, %17
%23 = load i32, i32* %13
%24 = load i32*, i32** %7
%25 = load i32, i32* %24
%26 = add nsw i32 %25, %23
store i32 %26, i32* %24
%27 = load i32*, i32** %7
%28 = load i32, i32* %27
%29 = and i32 %28, 65535
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 0
store i32 %29, i32* %31
br label %52
32: ; preds = %17
%33 = load i32, i32* %13
%34 = load i32*, i32** %8
%35 = load i32, i32* %34
%36 = add nsw i32 %35, %33
store i32 %36, i32* %34
%37 = load i32*, i32** %8
%38 = load i32, i32* %37
%39 = and i32 %38, 65535
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 0
store i32 %39, i32* %41
br label %52
42: ; preds = %17
%43 = load i32, i32* %13
%44 = load i32*, i32** %9
%45 = load i32, i32* %44
%46 = add nsw i32 %45, %43
store i32 %46, i32* %44
%47 = load i32*, i32** %9
%48 = load i32, i32* %47
%49 = and i32 %48, 65535
%50 = load i32*, i32** %6
%51 = getelementptr inbounds i32, i32* %50, i64 0
store i32 %49, i32* %51
br label %52
52: ; preds = %17, %42, %32, %22
%53 = getelementptr inbounds [64 x i32], [64 x i32]* %12, i64 0, i64 0
%54 = load i32*, i32** %6
%55 = call i32 @ZigZagSubBlock(i32* %53, i32* %54)
%56 = load i32*, i32** %10
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %63
58: ; preds = %52
%59 = getelementptr inbounds [64 x i32], [64 x i32]* %12, i64 0, i64 0
%60 = getelementptr inbounds [64 x i32], [64 x i32]* %12, i64 0, i64 0
%61 = load i32*, i32** %10
%62 = call i32 @MultSubBlocks(i32* %59, i32* %60, i32* %61, i32 0)
br label %63
63: ; preds = %58, %52
%64 = load i32*, i32** %6
%65 = getelementptr inbounds [64 x i32], [64 x i32]* %12, i64 0, i64 0
%66 = call i32 @TransposeSubBlock(i32* %64, i32* %65)
%67 = load i32*, i32** %6
%68 = load i32*, i32** %6
%69 = call i32 @InverseDCTSubBlock(i32* %67, i32* %68)
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 64
store i32* %71, i32** %6
br label %72
72: ; preds = %63
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %14
75: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @decode_macroblock_ob(i32* %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, i32* %4) {
%6 = alloca [64 x i32]
%7 = bitcast [64 x i32]* %6 to i8*
%8 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%9 = icmp eq i32* %4, null
br label %10
10: ; preds = %5, %30
%11 = phi i32* [ %0, %5 ], [ %33, %30 ]
%12 = phi i32 [ 0, %5 ], [ %34, %30 ]
%13 = load i32, i32* %11
switch i32 %12, label %26 [
i32 0, label %14
i32 1, label %14
i32 2, label %14
i32 3, label %14
i32 4, label %17
i32 5, label %20
]
14: ; preds = %10, %10, %10, %10
%15 = load i32, i32* %1
%16 = add nsw i32 %15, %13
store i32 %16, i32* %1
br label %23
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %13
store i32 %19, i32* %2
br label %23
20: ; preds = %10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %13
store i32 %22, i32* %3
br label %23
23: ; preds = %14, %17, %20
%24 = phi i32 [ %22, %20 ], [ %19, %17 ], [ %16, %14 ]
%25 = and i32 %24, 65535
store i32 %25, i32* %11
br label %26
26: ; preds = %23, %10
%27 = call i32 @ZigZagSubBlock(i32* %8, i32* %11)
br i1 %9, label %30, label %28
28: ; preds = %26
%29 = call i32 @MultSubBlocks(i32* %8, i32* %8, i32* %4, i32 0)
br label %30
30: ; preds = %28, %26
%31 = call i32 @TransposeSubBlock(i32* %11, i32* %8)
%32 = call i32 @InverseDCTSubBlock(i32* %11, i32* %11)
%33 = getelementptr inbounds i32, i32* %11, i64 64
%34 = add nuw nsw i32 %12, 1
%35 = icmp eq i32 %34, 6
br i1 %35, label %36, label %10
36: ; preds = %30
ret void
}