void idst(x, y, m, tab) double *x, *y, *tab;
int m;
{
  int n, n2, i;
  double *xp1, *xp2;
  double temp;
  n = 1 << m;
  n2 = n >> 1;
  xp1 = x;
  xp2 = x + n - 1;
  for (i = 0; i < n2; i++) {
    temp = *xp1;
    *xp1 = *xp2;
    *xp2 = temp;
    xp1++;
    xp2--;
  }
  idct(x, y, m, tab);
  xp1 = x + 1;
  for (i = 0; i < n2; i++) {
    *xp1 = -*xp1;
    xp1 += 2;
  }
}


x86 assembly (clang, -O0):
<idst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11bf <idst+0xaf>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1163 <idst+0x53>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1030 <idct@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1235 <idst+0x125>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e8 <idst+0xd8>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idst>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r8
mov    %rdi,%rbx
mov    $0x1,%r14d
mov    $0x1,%r12d
mov    %edx,%ecx
shl    %cl,%r12d
cmp    $0x1,%r12d
jle    115a <idst+0x4a>
mov    %r12d,%eax
sar    %eax
mov    %r12d,%ecx
lea    (%rbx,%rcx,8),%rdi
cmp    $0x2,%eax
cmovge %eax,%r14d
lea    -0x1(%r14),%r15d
cmp    $0x3,%r15d
jae    116f <idst+0x5f>
mov    %rbx,%rcx
jmp    11db <idst+0xcb>
mov    %rbx,%rdi
mov    %r8,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <idct@plt>
mov    %r14d,%eax
and    $0x7ffffffc,%eax
mov    %rbx,%rcx
nopw   0x0(%rax,%rax,1)
movsd  (%rcx),%xmm0
movsd  -0x8(%rdi),%xmm1
movsd  %xmm1,(%rcx)
movsd  %xmm0,-0x8(%rdi)
movsd  0x8(%rcx),%xmm0
movsd  -0x10(%rdi),%xmm1
movsd  %xmm1,0x8(%rcx)
movsd  %xmm0,-0x10(%rdi)
movsd  0x10(%rcx),%xmm0
movsd  -0x18(%rdi),%xmm1
movsd  %xmm1,0x10(%rcx)
movsd  %xmm0,-0x18(%rdi)
movsd  0x18(%rcx),%xmm0
movsd  -0x20(%rdi),%xmm1
movsd  %xmm1,0x18(%rcx)
movsd  %xmm0,-0x20(%rdi)
add    $0xffffffffffffffe0,%rdi
add    $0x20,%rcx
add    $0xfffffffc,%eax
jne    1180 <idst+0x70>
test   $0x3,%r14b
je     120e <idst+0xfe>
add    $0xfffffffffffffff8,%rdi
mov    %r14d,%eax
and    $0x3,%eax
xor    %ebp,%ebp
nopl   (%rax)
movsd  (%rcx,%rbp,8),%xmm0
movsd  (%rdi),%xmm1
movsd  %xmm1,(%rcx,%rbp,8)
movsd  %xmm0,(%rdi)
add    $0xfffffffffffffff8,%rdi
add    $0x1,%rbp
cmp    %ebp,%eax
jne    11f0 <idst+0xe0>
mov    %rbx,%rdi
mov    %r8,%rcx
xor    %eax,%eax
call   1030 <idct@plt>
cmp    $0x2,%r12d
jl     12a5 <idst+0x195>
add    $0x8,%rbx
cmp    $0x3,%r15d
jb     1277 <idst+0x167>
mov    %r14d,%eax
and    $0x7ffffffc,%eax
movaps 0xdc2(%rip),%xmm0
xchg   %ax,%ax
movsd  (%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
movsd  0x20(%rbx),%xmm3
movsd  0x30(%rbx),%xmm4
xorps  %xmm0,%xmm1
movlps %xmm1,(%rbx)
xorps  %xmm0,%xmm2
movlps %xmm2,0x10(%rbx)
xorps  %xmm0,%xmm3
movlps %xmm3,0x20(%rbx)
xorps  %xmm0,%xmm4
movlps %xmm4,0x30(%rbx)
add    $0x40,%rbx
add    $0xfffffffc,%eax
jne    1240 <idst+0x130>
test   $0x3,%r14b
je     12a5 <idst+0x195>
and    $0x3,%r14d
shl    $0x4,%r14
xor    %eax,%eax
movaps 0xd72(%rip),%xmm0
xchg   %ax,%ax
movsd  (%rbx,%rax,1),%xmm1
xorps  %xmm0,%xmm1
movlps %xmm1,(%rbx,%rax,1)
add    $0x10,%rax
cmp    %eax,%r14d
jne    1290 <idst+0x180>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @idst(double* %0, double* %1, i32 %2, double* %3) {
%5 = shl nuw i32 1, %2
%6 = icmp sgt i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 (double*, double*, i32, double*, ...) bitcast (i32 (...)* @idct to i32 (double*, double*, i32, double*, ...)*)(double* %0, double* %1, i32 %2, double* %3)
br label %91
9: ; preds = %4
%10 = ashr i32 %5, 1
%11 = zext i32 %5 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = call i32 @llvm.smax.i32(i32 %10, i32 1)
%14 = add nsw i32 %13, -1
%15 = and i32 %13, 3
%16 = icmp ult i32 %14, 3
br i1 %16, label %41, label %17
17: ; preds = %9
%18 = and i32 %13, 2147483644
br label %19
19: ; preds = %19, %17
%20 = phi double* [ %12, %17 ], [ %35, %19 ]
%21 = phi double* [ %0, %17 ], [ %38, %19 ]
%22 = phi i32 [ 0, %17 ], [ %39, %19 ]
%23 = getelementptr inbounds double, double* %20, i64 -1
%24 = load double, double* %21
%25 = load double, double* %23
store double %25, double* %21
store double %24, double* %23
%26 = getelementptr inbounds double, double* %21, i64 1
%27 = getelementptr inbounds double, double* %20, i64 -2
%28 = load double, double* %26
%29 = load double, double* %27
store double %29, double* %26
store double %28, double* %27
%30 = getelementptr inbounds double, double* %21, i64 2
%31 = getelementptr inbounds double, double* %20, i64 -3
%32 = load double, double* %30
%33 = load double, double* %31
store double %33, double* %30
store double %32, double* %31
%34 = getelementptr inbounds double, double* %21, i64 3
%35 = getelementptr inbounds double, double* %20, i64 -4
%36 = load double, double* %34
%37 = load double, double* %35
store double %37, double* %34
store double %36, double* %35
%38 = getelementptr inbounds double, double* %21, i64 4
%39 = add i32 %22, 4
%40 = icmp eq i32 %39, %18
br i1 %40, label %41, label %19
41: ; preds = %19, %9
%42 = phi double* [ %12, %9 ], [ %35, %19 ]
%43 = phi double* [ %0, %9 ], [ %38, %19 ]
%44 = icmp eq i32 %15, 0
br i1 %44, label %55, label %45
45: ; preds = %41, %45
%46 = phi double* [ %49, %45 ], [ %42, %41 ]
%47 = phi double* [ %52, %45 ], [ %43, %41 ]
%48 = phi i32 [ %53, %45 ], [ 0, %41 ]
%49 = getelementptr inbounds double, double* %46, i64 -1
%50 = load double, double* %47
%51 = load double, double* %49
store double %51, double* %47
store double %50, double* %49
%52 = getelementptr inbounds double, double* %47, i64 1
%53 = add i32 %48, 1
%54 = icmp eq i32 %53, %15
br i1 %54, label %55, label %45
55: ; preds = %45, %41
%56 = tail call i32 (double*, double*, i32, double*, ...) bitcast (i32 (...)* @idct to i32 (double*, double*, i32, double*, ...)*)(double* %0, double* %1, i32 %2, double* %3)
br i1 %6, label %57, label %91
57: ; preds = %55
%58 = getelementptr inbounds double, double* %0, i64 1
%59 = and i32 %13, 3
%60 = icmp ult i32 %14, 3
br i1 %60, label %80, label %61
61: ; preds = %57
%62 = and i32 %13, 2147483644
br label %63
63: ; preds = %63, %61
%64 = phi double* [ %58, %61 ], [ %77, %63 ]
%65 = phi i32 [ 0, %61 ], [ %78, %63 ]
%66 = load double, double* %64
%67 = fneg double %66
store double %67, double* %64
%68 = getelementptr inbounds double, double* %64, i64 2
%69 = load double, double* %68
%70 = fneg double %69
store double %70, double* %68
%71 = getelementptr inbounds double, double* %64, i64 4
%72 = load double, double* %71
%73 = fneg double %72
store double %73, double* %71
%74 = getelementptr inbounds double, double* %64, i64 6
%75 = load double, double* %74
%76 = fneg double %75
store double %76, double* %74
%77 = getelementptr inbounds double, double* %64, i64 8
%78 = add i32 %65, 4
%79 = icmp eq i32 %78, %62
br i1 %79, label %80, label %63
80: ; preds = %63, %57
%81 = phi double* [ %58, %57 ], [ %77, %63 ]
%82 = icmp eq i32 %59, 0
br i1 %82, label %91, label %83
83: ; preds = %80, %83
%84 = phi double* [ %88, %83 ], [ %81, %80 ]
%85 = phi i32 [ %89, %83 ], [ 0, %80 ]
%86 = load double, double* %84
%87 = fneg double %86
store double %87, double* %84
%88 = getelementptr inbounds double, double* %84, i64 2
%89 = add i32 %85, 1
%90 = icmp eq i32 %89, %59
br i1 %90, label %91, label %83
91: ; preds = %80, %83, %7, %55
ret void
}