#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*/ BTIC2D_TransDCT_Stride4(int *, int *, int, int);
void BTIC2D_TransDCT4(int *iblk, int *oblk) {
  int s[16], t[16];
  int i, j;
  BTIC2D_TransDCT_Stride4(iblk + 4 * 0, s + 4 * 0, 1, 1);
  BTIC2D_TransDCT_Stride4(iblk + 4 * 1, s + 4 * 1, 1, 1);
  BTIC2D_TransDCT_Stride4(iblk + 4 * 2, s + 4 * 2, 1, 1);
  BTIC2D_TransDCT_Stride4(iblk + 4 * 3, s + 4 * 3, 1, 1);
  BTIC2D_TransDCT_Stride4(s + 0, t + 0, 4, 4);
  BTIC2D_TransDCT_Stride4(s + 1, t + 1, 4, 4);
  BTIC2D_TransDCT_Stride4(s + 2, t + 2, 4, 4);
  BTIC2D_TransDCT_Stride4(s + 3, t + 3, 4, 4);
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      oblk[i * 4 + j] = (t[i * 4 + j] + 32768) >> 16;
    }
}


x86 assembly (clang, -O0):
<BTIC2D_TransDCT4>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
lea    -0x50(%rbp),%rsi
add    $0x10,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
lea    -0x50(%rbp),%rsi
add    $0x20,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
lea    -0x50(%rbp),%rsi
add    $0x30,%rsi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x4,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    -0x50(%rbp),%rdi
add    $0x4,%rdi
lea    -0x90(%rbp),%rsi
add    $0x4,%rsi
mov    $0x4,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    -0x50(%rbp),%rdi
add    $0x8,%rdi
lea    -0x90(%rbp),%rsi
add    $0x8,%rsi
mov    $0x4,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    -0x50(%rbp),%rdi
add    $0xc,%rdi
lea    -0x90(%rbp),%rsi
add    $0xc,%rsi
mov    $0x4,%ecx
mov    %ecx,%edx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x4,-0x94(%rbp)
jge    1294 <BTIC2D_TransDCT4+0x184>
movl   $0x0,-0x98(%rbp)
cmpl   $0x4,-0x98(%rbp)
jge    127b <BTIC2D_TransDCT4+0x16b>
mov    -0x94(%rbp),%eax
shl    $0x2,%eax
add    -0x98(%rbp),%eax
cltq
mov    -0x90(%rbp,%rax,4),%edx
add    $0x8000,%edx
sar    $0x10,%edx
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
shl    $0x2,%ecx
add    -0x98(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1220 <BTIC2D_TransDCT4+0x110>
jmp    1280 <BTIC2D_TransDCT4+0x170>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1209 <BTIC2D_TransDCT4+0xf9>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BTIC2D_TransDCT4>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x40(%rsp),%r14
mov    %r14,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    0x10(%rbx),%rdi
lea    0x50(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    0x20(%rbx),%rdi
lea    0x60(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
add    $0x30,%rbx
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x4,%edx
mov    $0x4,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    0x44(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    0x48(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
lea    0x4c(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
call   1030 <BTIC2D_TransDCT_Stride4@plt>
movdqa 0xe14(%rip),%xmm0
movdqa (%rsp),%xmm1
paddd  %xmm0,%xmm1
psrad  $0x10,%xmm1
movdqu %xmm1,(%r15)
movdqa 0x10(%rsp),%xmm1
paddd  %xmm0,%xmm1
psrad  $0x10,%xmm1
movdqu %xmm1,0x10(%r15)
movdqa 0x20(%rsp),%xmm1
paddd  %xmm0,%xmm1
psrad  $0x10,%xmm1
movdqu %xmm1,0x20(%r15)
paddd  0x30(%rsp),%xmm0
psrad  $0x10,%xmm0
movdqu %xmm0,0x30(%r15)
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @BTIC2D_TransDCT4(i32* %0, i32* nocapture writeonly %1) {
%3 = alloca [16 x i32]
%4 = alloca [16 x i32]
%5 = bitcast [16 x i32]* %3 to i8*
%6 = bitcast [16 x i32]* %4 to i8*
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%8 = call i32 @BTIC2D_TransDCT_Stride4(i32* %0, i32* %7, i32 1, i32 1)
%9 = getelementptr inbounds i32, i32* %0, i64 4
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 4
%11 = call i32 @BTIC2D_TransDCT_Stride4(i32* %9, i32* %10, i32 1, i32 1)
%12 = getelementptr inbounds i32, i32* %0, i64 8
%13 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 8
%14 = call i32 @BTIC2D_TransDCT_Stride4(i32* %12, i32* %13, i32 1, i32 1)
%15 = getelementptr inbounds i32, i32* %0, i64 12
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 12
%17 = call i32 @BTIC2D_TransDCT_Stride4(i32* %15, i32* %16, i32 1, i32 1)
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%19 = call i32 @BTIC2D_TransDCT_Stride4(i32* %7, i32* %18, i32 4, i32 4)
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 1
%22 = call i32 @BTIC2D_TransDCT_Stride4(i32* %20, i32* %21, i32 4, i32 4)
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 2
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 2
%25 = call i32 @BTIC2D_TransDCT_Stride4(i32* %23, i32* %24, i32 4, i32 4)
%26 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 3
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 3
%28 = call i32 @BTIC2D_TransDCT_Stride4(i32* %26, i32* %27, i32 4, i32 4)
%29 = bitcast [16 x i32]* %4 to <4 x i32>*
%30 = load <4 x i32>, <4 x i32>* %29
%31 = add nsw <4 x i32> %30, <i32 32768, i32 32768, i32 32768, i32 32768>
%32 = ashr <4 x i32> %31, <i32 16, i32 16, i32 16, i32 16>
%33 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> %32, <4 x i32>* %33
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 4
%35 = getelementptr inbounds i32, i32* %1, i64 4
%36 = bitcast i32* %34 to <4 x i32>*
%37 = load <4 x i32>, <4 x i32>* %36
%38 = add nsw <4 x i32> %37, <i32 32768, i32 32768, i32 32768, i32 32768>
%39 = ashr <4 x i32> %38, <i32 16, i32 16, i32 16, i32 16>
%40 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %39, <4 x i32>* %40
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 8
%42 = getelementptr inbounds i32, i32* %1, i64 8
%43 = bitcast i32* %41 to <4 x i32>*
%44 = load <4 x i32>, <4 x i32>* %43
%45 = add nsw <4 x i32> %44, <i32 32768, i32 32768, i32 32768, i32 32768>
%46 = ashr <4 x i32> %45, <i32 16, i32 16, i32 16, i32 16>
%47 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %46, <4 x i32>* %47
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 12
%49 = getelementptr inbounds i32, i32* %1, i64 12
%50 = bitcast i32* %48 to <4 x i32>*
%51 = load <4 x i32>, <4 x i32>* %50
%52 = add nsw <4 x i32> %51, <i32 32768, i32 32768, i32 32768, i32 32768>
%53 = ashr <4 x i32> %52, <i32 16, i32 16, i32 16, i32 16>
%54 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> %53, <4 x i32>* %54
ret void
}