#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>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    127a <idct_1D_double+0x15a>
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    11ce <idct_1D_double+0xae>
jp     11ce <idct_1D_double+0xae>
jmp    125f <idct_1D_double+0x13f>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    125a <idct_1D_double+0x13a>
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  0xe06(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf2(%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    11d5 <idct_1D_double+0xb5>
jmp    125f <idct_1D_double+0x13f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  0xda0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    118f <idct_1D_double+0x6f>
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)
movq   $0x0,(%rdx,%rcx,8)
lea    (%rcx,%rcx,1),%rsi
mov    %rcx,%rax
shl    $0x4,%rax
movq   $0x0,(%rdx,%rax,1)
lea    (%rcx,%rcx,2),%rax
mov    %rax,0x50(%rsp)
movq   $0x0,(%rdx,%rax,8)
lea    0x0(,%rcx,4),%rax
mov    %rax,0x48(%rsp)
mov    %rcx,%rax
shl    $0x5,%rax
movq   $0x0,(%rdx,%rax,1)
lea    (%rcx,%rcx,4),%rax
mov    %rax,0x40(%rsp)
movq   $0x0,(%rdx,%rax,8)
mov    %rsi,0x58(%rsp)
lea    (%rsi,%rsi,2),%rax
mov    %rax,0x38(%rsp)
movq   $0x0,(%rdx,%rax,8)
lea    0x0(,%rcx,8),%rax
mov    %rcx,0x60(%rsp)
sub    %rcx,%rax
mov    %rdx,0x68(%rsp)
mov    %rax,0x30(%rsp)
movq   $0x0,(%rdx,%rax,8)
mov    $0x2,%edi
call   1040 <sqrt@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovae %edx,%eax
cvtsi2sd %eax,%xmm2
movslq %ebx,%rax
shl    $0x3,%rax
mov    $0xffffffffffffffe8,%rcx
xorpd  %xmm0,%xmm0
movsd  0xe0f(%rip),%xmm1
xor    %esi,%esi
xor    %r12d,%r12d
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r13d,%r13d
mov    %rax,0x28(%rsp)
jmp    124a <idct_1D_double+0x12a>
nopl   0x0(%rax,%rax,1)
add    $0xf,%r13d
add    $0xd,%r15d
add    $0xb,%ebx
add    $0x9,%r14d
add    $0x7,%r12d
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  0xd9a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd96(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    %edx,0x1c(%rsp)
mov    %rcx,0x20(%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  0xd31(%rip),%xmm0
mulsd  0xd31(%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  0xcf2(%rip),%xmm0
mulsd  0xcf2(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x58(%rsp),%rax
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  0xcb4(%rip),%xmm0
mulsd  0xcb4(%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 %r14d,%xmm0
mulsd  0xc76(%rip),%xmm0
mulsd  0xc76(%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 %ebx,%xmm0
mulsd  0xc39(%rip),%xmm0
mulsd  0xc39(%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 %r15d,%xmm0
mulsd  0xbfb(%rip),%xmm0
mulsd  0xbfb(%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 %r13d,%xmm0
mulsd  0xbbd(%rip),%xmm0
mulsd  0xbbd(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    0x18(%rsp),%esi
movsd  0xbb0(%rip),%xmm1
mov    0x20(%rsp),%rcx
mov    0x1c(%rsp),%edx
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    0x30(%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 = sdiv i32 1, %28
%30 = sitofp i32 %29 to double
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 = add i32 %19, 1
%21 = icmp ult i32 %20, 3
%22 = select i1 %21, i32 %19, i32 0
%23 = sitofp i32 %22 to double
%24 = sext i32 %1 to i64
br label %26
25: ; preds = %113
ret void
26: ; preds = %4, %113
%27 = phi i64 [ 0, %4 ], [ %114, %113 ]
%28 = phi double [ %23, %4 ], [ 1.000000e+00, %113 ]
%29 = mul nsw i64 %27, %24
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %113, label %33
33: ; preds = %26
%34 = trunc i64 %27 to i32
%35 = sitofp i32 %34 to double
%36 = fmul double %35, 0x400921FB54442D18
%37 = fmul double %36, 6.250000e-02
%38 = fptosi double %37 to i32
%39 = tail call double @cos(i32 %38)
%40 = fmul double %28, %39
%41 = load double, double* %2
%42 = tail call double @llvm.fmuladd.f64(double %40, double %31, double %41)
store double %42, double* %2
%43 = trunc i64 %27 to i32
%44 = mul i32 %43, 3
%45 = sitofp i32 %44 to double
%46 = fmul double %45, 0x400921FB54442D18
%47 = fmul double %46, 6.250000e-02
%48 = fptosi double %47 to i32
%49 = tail call double @cos(i32 %48)
%50 = fmul double %28, %49
%51 = load double, double* %6
%52 = tail call double @llvm.fmuladd.f64(double %50, double %31, double %51)
store double %52, double* %6
%53 = trunc i64 %27 to i32
%54 = mul i32 %53, 5
%55 = sitofp i32 %54 to double
%56 = fmul double %55, 0x400921FB54442D18
%57 = fmul double %56, 6.250000e-02
%58 = fptosi double %57 to i32
%59 = tail call double @cos(i32 %58)
%60 = fmul double %28, %59
%61 = load double, double* %8
%62 = tail call double @llvm.fmuladd.f64(double %60, double %31, double %61)
store double %62, double* %8
%63 = trunc i64 %27 to i32
%64 = mul i32 %63, 7
%65 = sitofp i32 %64 to double
%66 = fmul double %65, 0x400921FB54442D18
%67 = fmul double %66, 6.250000e-02
%68 = fptosi double %67 to i32
%69 = tail call double @cos(i32 %68)
%70 = fmul double %28, %69
%71 = load double, double* %10
%72 = tail call double @llvm.fmuladd.f64(double %70, double %31, double %71)
store double %72, double* %10
%73 = trunc i64 %27 to i32
%74 = mul i32 %73, 9
%75 = sitofp i32 %74 to double
%76 = fmul double %75, 0x400921FB54442D18
%77 = fmul double %76, 6.250000e-02
%78 = fptosi double %77 to i32
%79 = tail call double @cos(i32 %78)
%80 = fmul double %28, %79
%81 = load double, double* %12
%82 = tail call double @llvm.fmuladd.f64(double %80, double %31, double %81)
store double %82, double* %12
%83 = trunc i64 %27 to i32
%84 = mul i32 %83, 11
%85 = sitofp i32 %84 to double
%86 = fmul double %85, 0x400921FB54442D18
%87 = fmul double %86, 6.250000e-02
%88 = fptosi double %87 to i32
%89 = tail call double @cos(i32 %88)
%90 = fmul double %28, %89
%91 = load double, double* %14
%92 = tail call double @llvm.fmuladd.f64(double %90, double %31, double %91)
store double %92, double* %14
%93 = trunc i64 %27 to i32
%94 = mul i32 %93, 13
%95 = sitofp i32 %94 to double
%96 = fmul double %95, 0x400921FB54442D18
%97 = fmul double %96, 6.250000e-02
%98 = fptosi double %97 to i32
%99 = tail call double @cos(i32 %98)
%100 = fmul double %28, %99
%101 = load double, double* %16
%102 = tail call double @llvm.fmuladd.f64(double %100, double %31, double %101)
store double %102, double* %16
%103 = trunc i64 %27 to i32
%104 = mul i32 %103, 15
%105 = sitofp i32 %104 to double
%106 = fmul double %105, 0x400921FB54442D18
%107 = fmul double %106, 6.250000e-02
%108 = fptosi double %107 to i32
%109 = tail call double @cos(i32 %108)
%110 = fmul double %28, %109
%111 = load double, double* %18
%112 = tail call double @llvm.fmuladd.f64(double %110, double %31, double %111)
store double %112, double* %18
br label %113
113: ; preds = %33, %26
%114 = add nuw nsw i64 %27, 1
%115 = icmp eq i64 %114, 8
br i1 %115, label %25, label %26
}