#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 */
double cos(int);
int sqrt(int);
void idct_1D_double(double *in, int instride, double *out, int outstride) {
  for (int x = 0; x < 8; x++)
    out[x * outstride] = 0;
  double Cu = 1. / sqrt(2.);
  for (int u = 0; u < 8; u++, Cu = 1) {
    double coeff = in[u * instride];
    if (coeff == 0)
      continue;
    for (int x = 0; x < 8; x++)
      out[x * outstride] +=
          Cu *
          cos((2 * x + 1) * u * 3.141592653589793238462643383279502884196 /
              16) *
          coeff;
  }
}


x86 assembly (clang, -O0):
<idct_1D_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jge    116b <idct_1D_double+0x4b>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <idct_1D_double+0x1d>
mov    $0x2,%edi
call   1040 <sqrt@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe7f(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    127c <idct_1D_double+0x15c>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d0 <idct_1D_double+0xb0>
jp     11d0 <idct_1D_double+0xb0>
jmp    1261 <idct_1D_double+0x141>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    125c <idct_1D_double+0x13c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
imul   -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe0c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d7 <idct_1D_double+0xb7>
jmp    1261 <idct_1D_double+0x141>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  0xd8e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1191 <idct_1D_double+0x71>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idct_1D_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %esi,%ebx
mov    %rdi,%rbp
movslq %ecx,%rcx
movq   $0x0,(%rdx)
lea    0x0(,%rcx,8),%rsi
movq   $0x0,(%rdx,%rcx,8)
lea    (%rcx,%rcx,1),%rdi
mov    %rcx,%rax
shl    $0x4,%rax
movq   $0x0,(%rdx,%rax,1)
lea    (%rcx,%rcx,2),%rax
mov    %rax,0x48(%rsp)
movq   $0x0,(%rdx,%rax,8)
lea    0x0(,%rcx,4),%rax
mov    %rax,0x40(%rsp)
mov    %rcx,%rax
shl    $0x5,%rax
movq   $0x0,(%rdx,%rax,1)
lea    (%rcx,%rcx,4),%rax
mov    %rax,0x38(%rsp)
movq   $0x0,(%rdx,%rax,8)
mov    %rdi,0x50(%rsp)
lea    (%rdi,%rdi,2),%rax
mov    %rax,0x30(%rsp)
movq   $0x0,(%rdx,%rax,8)
mov    %rcx,0x60(%rsp)
sub    %rcx,%rsi
mov    %rdx,0x68(%rsp)
mov    %rsi,0x58(%rsp)
movq   $0x0,(%rdx,%rsi,8)
mov    $0x2,%edi
call   1040 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe1c(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
movslq %ebx,%rax
shl    $0x3,%rax
mov    $0xffffffffffffffe8,%rcx
xor    %edx,%edx
xorpd  %xmm0,%xmm0
xor    %esi,%esi
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r12d,%r12d
mov    %rax,0x28(%rsp)
jmp    124a <idct_1D_double+0x12a>
nopw   0x0(%rax,%rax,1)
add    $0xf,%r12d
add    $0xd,%r15d
add    $0xb,%ebx
add    $0x9,%r14d
add    $0x7,%r13d
add    $0x5,%esi
add    $0x1,%edx
add    %rax,%rbp
movapd %xmm1,%xmm2
add    $0x3,%rcx
je     1499 <idct_1D_double+0x379>
movsd  0x0(%rbp),%xmm3
ucomisd %xmm0,%xmm3
jne    1257 <idct_1D_double+0x137>
jnp    1220 <idct_1D_double+0x100>
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  0xda2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    %rcx,0x20(%rsp)
mov    %edx,0x1c(%rsp)
mov    %esi,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm3,0x10(%rsp)
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    %rbp,0x70(%rsp)
mov    0x68(%rsp),%rbp
addsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x0(%rbp)
mov    0x20(%rsp),%rax
add    $0x18,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd39(%rip),%xmm0
mulsd  0xd39(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x60(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x18(%rsp),%xmm0
mulsd  0xcfa(%rip),%xmm0
mulsd  0xcfa(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x50(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mulsd  0xcbc(%rip),%xmm0
mulsd  0xcbc(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x48(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0xc7e(%rip),%xmm0
mulsd  0xc7e(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x40(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xc41(%rip),%xmm0
mulsd  0xc41(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x38(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0xc03(%rip),%xmm0
mulsd  0xc03(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x30(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  0xbc5(%rip),%xmm0
mulsd  0xbc5(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    0x18(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0x20(%rsp),%rcx
movsd  0xb97(%rip),%xmm1
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x58(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorpd  %xmm0,%xmm0
mov    0x28(%rsp),%rax
mov    0x70(%rsp),%rbp
jmp    1220 <idct_1D_double+0x100>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @idct_1D_double(double* %0, i32 %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %14
14: ; preds = %24, %4
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load double*, double** %7
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = mul nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %18, i64 %22
store double 0.000000e+00, double* %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %14
27: ; preds = %14
%28 = call i32 @sqrt(i32 2)
%29 = sitofp i32 %28 to double
%30 = fdiv double 1.000000e+00, %29
store double %30, double* %10
store i32 0, i32* %11
br label %31
31: ; preds = %75, %27
%32 = load i32, i32* %11
%33 = icmp slt i32 %32, 8
br i1 %33, label %34, label %78
34: ; preds = %31
%35 = load double*, double** %5
%36 = load i32, i32* %11
%37 = load i32, i32* %6
%38 = mul nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %35, i64 %39
%41 = load double, double* %40
store double %41, double* %12
%42 = load double, double* %12
%43 = fcmp oeq double %42, 0.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %34
br label %75
45: ; preds = %34
store i32 0, i32* %13
br label %46
46: ; preds = %71, %45
%47 = load i32, i32* %13
%48 = icmp slt i32 %47, 8
br i1 %48, label %49, label %74
49: ; preds = %46
%50 = load double, double* %10
%51 = load i32, i32* %13
%52 = mul nsw i32 2, %51
%53 = add nsw i32 %52, 1
%54 = load i32, i32* %11
%55 = mul nsw i32 %53, %54
%56 = sitofp i32 %55 to double
%57 = fmul double %56, 0x400921FB54442D18
%58 = fdiv double %57, 1.600000e+01
%59 = fptosi double %58 to i32
%60 = call double @cos(i32 %59)
%61 = fmul double %50, %60
%62 = load double, double* %12
%63 = load double*, double** %7
%64 = load i32, i32* %13
%65 = load i32, i32* %8
%66 = mul nsw i32 %64, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %63, i64 %67
%69 = load double, double* %68
%70 = call double @llvm.fmuladd.f64(double %61, double %62, double %69)
store double %70, double* %68
br label %71
71: ; preds = %49
%72 = load i32, i32* %13
%73 = add nsw i32 %72, 1
store i32 %73, i32* %13
br label %46
74: ; preds = %46
br label %75
75: ; preds = %74, %44
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
store double 1.000000e+00, double* %10
br label %31
78: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @idct_1D_double(double* nocapture %0, i32 %1, double* nocapture %2, i32 %3) {
%5 = sext i32 %3 to i64
store double 0.000000e+00, double* %2
%6 = getelementptr inbounds double, double* %2, i64 %5
store double 0.000000e+00, double* %6
%7 = shl nsw i64 %5, 1
%8 = getelementptr inbounds double, double* %2, i64 %7
store double 0.000000e+00, double* %8
%9 = mul nsw i64 %5, 3
%10 = getelementptr inbounds double, double* %2, i64 %9
store double 0.000000e+00, double* %10
%11 = shl nsw i64 %5, 2
%12 = getelementptr inbounds double, double* %2, i64 %11
store double 0.000000e+00, double* %12
%13 = mul nsw i64 %5, 5
%14 = getelementptr inbounds double, double* %2, i64 %13
store double 0.000000e+00, double* %14
%15 = mul nsw i64 %5, 6
%16 = getelementptr inbounds double, double* %2, i64 %15
store double 0.000000e+00, double* %16
%17 = mul nsw i64 %5, 7
%18 = getelementptr inbounds double, double* %2, i64 %17
store double 0.000000e+00, double* %18
%19 = tail call i32 @sqrt(i32 2)
%20 = sitofp i32 %19 to double
%21 = fdiv double 1.000000e+00, %20
%22 = sext i32 %1 to i64
br label %24
23: ; preds = %111
ret void
24: ; preds = %4, %111
%25 = phi i64 [ 0, %4 ], [ %112, %111 ]
%26 = phi double [ %21, %4 ], [ 1.000000e+00, %111 ]
%27 = mul nsw i64 %25, %22
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = load double, double* %28
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %111, label %31
31: ; preds = %24
%32 = trunc i64 %25 to i32
%33 = sitofp i32 %32 to double
%34 = fmul double %33, 0x400921FB54442D18
%35 = fmul double %34, 6.250000e-02
%36 = fptosi double %35 to i32
%37 = tail call double @cos(i32 %36)
%38 = fmul double %26, %37
%39 = load double, double* %2
%40 = tail call double @llvm.fmuladd.f64(double %38, double %29, double %39)
store double %40, double* %2
%41 = trunc i64 %25 to i32
%42 = mul i32 %41, 3
%43 = sitofp i32 %42 to double
%44 = fmul double %43, 0x400921FB54442D18
%45 = fmul double %44, 6.250000e-02
%46 = fptosi double %45 to i32
%47 = tail call double @cos(i32 %46)
%48 = fmul double %26, %47
%49 = load double, double* %6
%50 = tail call double @llvm.fmuladd.f64(double %48, double %29, double %49)
store double %50, double* %6
%51 = trunc i64 %25 to i32
%52 = mul i32 %51, 5
%53 = sitofp i32 %52 to double
%54 = fmul double %53, 0x400921FB54442D18
%55 = fmul double %54, 6.250000e-02
%56 = fptosi double %55 to i32
%57 = tail call double @cos(i32 %56)
%58 = fmul double %26, %57
%59 = load double, double* %8
%60 = tail call double @llvm.fmuladd.f64(double %58, double %29, double %59)
store double %60, double* %8
%61 = trunc i64 %25 to i32
%62 = mul i32 %61, 7
%63 = sitofp i32 %62 to double
%64 = fmul double %63, 0x400921FB54442D18
%65 = fmul double %64, 6.250000e-02
%66 = fptosi double %65 to i32
%67 = tail call double @cos(i32 %66)
%68 = fmul double %26, %67
%69 = load double, double* %10
%70 = tail call double @llvm.fmuladd.f64(double %68, double %29, double %69)
store double %70, double* %10
%71 = trunc i64 %25 to i32
%72 = mul i32 %71, 9
%73 = sitofp i32 %72 to double
%74 = fmul double %73, 0x400921FB54442D18
%75 = fmul double %74, 6.250000e-02
%76 = fptosi double %75 to i32
%77 = tail call double @cos(i32 %76)
%78 = fmul double %26, %77
%79 = load double, double* %12
%80 = tail call double @llvm.fmuladd.f64(double %78, double %29, double %79)
store double %80, double* %12
%81 = trunc i64 %25 to i32
%82 = mul i32 %81, 11
%83 = sitofp i32 %82 to double
%84 = fmul double %83, 0x400921FB54442D18
%85 = fmul double %84, 6.250000e-02
%86 = fptosi double %85 to i32
%87 = tail call double @cos(i32 %86)
%88 = fmul double %26, %87
%89 = load double, double* %14
%90 = tail call double @llvm.fmuladd.f64(double %88, double %29, double %89)
store double %90, double* %14
%91 = trunc i64 %25 to i32
%92 = mul i32 %91, 13
%93 = sitofp i32 %92 to double
%94 = fmul double %93, 0x400921FB54442D18
%95 = fmul double %94, 6.250000e-02
%96 = fptosi double %95 to i32
%97 = tail call double @cos(i32 %96)
%98 = fmul double %26, %97
%99 = load double, double* %16
%100 = tail call double @llvm.fmuladd.f64(double %98, double %29, double %99)
store double %100, double* %16
%101 = trunc i64 %25 to i32
%102 = mul i32 %101, 15
%103 = sitofp i32 %102 to double
%104 = fmul double %103, 0x400921FB54442D18
%105 = fmul double %104, 6.250000e-02
%106 = fptosi double %105 to i32
%107 = tail call double @cos(i32 %106)
%108 = fmul double %26, %107
%109 = load double, double* %18
%110 = tail call double @llvm.fmuladd.f64(double %108, double %29, double %109)
store double %110, double* %18
br label %111
111: ; preds = %31, %24
%112 = add nuw nsw i64 %25, 1
%113 = icmp eq i64 %112, 8
br i1 %113, label %23, label %24
}