#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*/ PostMultiply(int, int *);
int /*<<< orphan*/ PostMultiplyRescale(int, int *, int);
int /*<<< orphan*/ PreMultiply(int, int *);
int /*<<< orphan*/ PreMultiplyRescale(int, int *, int);
int /*<<< orphan*/ cook_R4FFT(int, int *);
void cook_DCT4(int tabidx, int *coef, int gb) {
  int es;
  if (gb < 4) {
    es = 4 - gb;
    PreMultiplyRescale(tabidx, coef, es);
    cook_R4FFT(tabidx, coef);
    PostMultiplyRescale(tabidx, coef, es);
  } else {
    PreMultiply(tabidx, coef);
    cook_R4FFT(tabidx, coef);
    PostMultiply(tabidx, coef);
  }
}


x86 assembly (clang, -O0):
<cook_DCT4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11a6 <cook_DCT4+0x56>
mov    $0x4,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <PreMultiplyRescale@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <cook_R4FFT@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1070 <PostMultiplyRescale@plt>
jmp    11ca <cook_DCT4+0x7a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <PreMultiply@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <cook_R4FFT@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <PostMultiply@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cook_DCT4>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x3,%edx
jg     118f <cook_DCT4+0x3f>
mov    $0x4,%r14d
sub    %edx,%r14d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <PreMultiplyRescale@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <cook_R4FFT@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <PostMultiplyRescale@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <PreMultiply@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <cook_R4FFT@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <PostMultiply@plt>

LLVM IR (-O0):
define void @cook_DCT4(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %24
10: ; preds = %3
%11 = load i32, i32* %6
%12 = sub nsw i32 4, %11
store i32 %12, i32* %7
%13 = load i32, i32* %4
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = call i32 @PreMultiplyRescale(i32 %13, i32* %14, i32 %15)
%17 = load i32, i32* %4
%18 = load i32*, i32** %5
%19 = call i32 @cook_R4FFT(i32 %17, i32* %18)
%20 = load i32, i32* %4
%21 = load i32*, i32** %5
%22 = load i32, i32* %7
%23 = call i32 @PostMultiplyRescale(i32 %20, i32* %21, i32 %22)
br label %34
24: ; preds = %3
%25 = load i32, i32* %4
%26 = load i32*, i32** %5
%27 = call i32 @PreMultiply(i32 %25, i32* %26)
%28 = load i32, i32* %4
%29 = load i32*, i32** %5
%30 = call i32 @cook_R4FFT(i32 %28, i32* %29)
%31 = load i32, i32* %4
%32 = load i32*, i32** %5
%33 = call i32 @PostMultiply(i32 %31, i32* %32)
br label %34
34: ; preds = %24, %10
ret void
}

LLVM IR (-O2):
define void @cook_DCT4(i32 %0, i32* %1, i32 %2) {
%4 = icmp slt i32 %2, 4
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = sub nsw i32 4, %2
%7 = tail call i32 @PreMultiplyRescale(i32 %0, i32* %1, i32 %6)
%8 = tail call i32 @cook_R4FFT(i32 %0, i32* %1)
%9 = tail call i32 @PostMultiplyRescale(i32 %0, i32* %1, i32 %6)
br label %14
10: ; preds = %3
%11 = tail call i32 @PreMultiply(i32 %0, i32* %1)
%12 = tail call i32 @cook_R4FFT(i32 %0, i32* %1)
%13 = tail call i32 @PostMultiply(i32 %0, i32* %1)
br label %14
14: ; preds = %10, %5
ret void
}