#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 C(int);
double cos(int);
double DCT(int u, int v, double *komponenta) {
  int i, j;
  double sume = 0;
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      sume += komponenta[i * 8 + j] * cos(((2 * i + 1) * u * 3.141) / 16) *
              cos(((2 * j + 1) * v * 3.141) / 16);
    }
  }
  return sume * C(u) * C(v) * 0.25;
}


x86 assembly (clang, -O0):
<DCT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1226 <DCT+0x106>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1213 <DCT+0xf3>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
imul   -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe81(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
imul   -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe3e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <DCT+0x32>
jmp    1218 <DCT+0xf8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <DCT+0x21>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <C@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <C@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd9b(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DCT>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cvtsi2sd %esi,%xmm0
movsd  0xec6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec2(%rip),%xmm2
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x34(%rsp)
lea    (%rsi,%rsi,2),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x30(%rsp)
lea    (%rsi,%rsi,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,0x2c(%rsp)
lea    0x0(,%rsi,8),%ebp
sub    %esi,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,0x28(%rsp)
lea    (%rsi,%rsi,8),%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,0x24(%rsp)
lea    (%rsi,%rax,2),%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,0x20(%rsp)
mov    %rsi,0x40(%rsp)
lea    (%rsi,%rcx,4),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ecx
mov    %ecx,0x1c(%rsp)
lea    (%rax,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%r12d
mov    %rdx,%r13
lea    (%rdi,%rdi,1),%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %r14d,%r14d
mov    %rdi,0x38(%rsp)
mov    %edi,%r15d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0xdc0(%rip),%xmm0
mulsd  0xdc0(%rip),%xmm0
cvttsd2si %xmm0,%ebx
movsd  0x0(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x34(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x30(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2c(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x28(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x24(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x30(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x1c(%rsp),%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x38(%r13,%r14,1),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
add    %ebp,%r15d
add    $0x40,%r14
cmp    $0x200,%r14
jne    1230 <DCT+0x110>
mov    0x38(%rsp),%rdi
call   1030 <C@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x40(%rsp),%rdi
call   1030 <C@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0xbab(%rip),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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