#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 pow(double, unsigned int);
double HodnotaFunkce(unsigned int aRad, double aKoef[], double aX) {
  double value = aKoef[0];
  for (; aRad; aRad--)
    value += aKoef[aRad] * pow(aX, aRad);
  return value;
}


x86 assembly (clang, -O0):
<HodnotaFunkce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1181 <HodnotaFunkce+0x71>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x4(%rbp),%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1131 <HodnotaFunkce+0x21>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HodnotaFunkce>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  (%rsi),%xmm1
test   %edi,%edi
je     123a <HodnotaFunkce+0x12a>
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edi,%ebx
lea    -0x1(%r15),%ebp
and    $0x3,%r15d
movsd  %xmm0,0x10(%rsp)
je     1177 <HodnotaFunkce+0x67>
xchg   %ax,%ax
movsd  %xmm1,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm0
addsd  %xmm0,%xmm1
add    $0xffffffffffffffff,%rbx
add    $0xffffffff,%r15d
jne    1140 <HodnotaFunkce+0x30>
cmp    $0x3,%ebp
jb     123a <HodnotaFunkce+0x12a>
movsd  %xmm1,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  -0x8(%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
lea    -0x1(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  -0x10(%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
lea    -0x2(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  -0x18(%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
lea    -0x3(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
movapd %xmm0,%xmm1
mulsd  (%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
add    $0xfffffffffffffffc,%rbx
test   %ebx,%ebx
jne    1180 <HodnotaFunkce+0x70>
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @HodnotaFunkce(i32 %0, double* %1, double %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double %2, double* %6
%8 = load double*, double** %5
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
store double %10, double* %7
br label %11
11: ; preds = %25, %3
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load double*, double** %5
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double, double* %6
%21 = load i32, i32* %4
%22 = call double @pow(double %20, i32 %21)
%23 = load double, double* %7
%24 = call double @llvm.fmuladd.f64(double %19, double %22, double %23)
store double %24, double* %7
br label %25
25: ; preds = %14
%26 = load i32, i32* %4
%27 = add i32 %26, -1
store i32 %27, i32* %4
br label %11
28: ; preds = %11
%29 = load double, double* %7
ret double %29
}

LLVM IR (-O2):
define double @HodnotaFunkce(i32 %0, double* nocapture %1, double %2) {
%4 = load double, double* %1
%5 = icmp eq i32 %0, 0
br i1 %5, label %57, label %6
6: ; preds = %3
%7 = zext i32 %0 to i64
%8 = add i32 %0, -1
%9 = and i32 %0, 3
%10 = icmp eq i32 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %6, %11
%12 = phi i64 [ %20, %11 ], [ %7, %6 ]
%13 = phi double [ %19, %11 ], [ %4, %6 ]
%14 = phi i32 [ %21, %11 ], [ 0, %6 ]
%15 = getelementptr inbounds double, double* %1, i64 %12
%16 = load double, double* %15
%17 = trunc i64 %12 to i32
%18 = tail call double @pow(double %2, i32 %17)
%19 = tail call double @llvm.fmuladd.f64(double %16, double %18, double %13)
%20 = add nsw i64 %12, -1
%21 = add i32 %14, 1
%22 = icmp eq i32 %21, %9
br i1 %22, label %23, label %11
23: ; preds = %11, %6
%24 = phi double [ undef, %6 ], [ %19, %11 ]
%25 = phi i64 [ %7, %6 ], [ %20, %11 ]
%26 = phi double [ %4, %6 ], [ %19, %11 ]
%27 = icmp ult i32 %8, 3
br i1 %27, label %57, label %28
28: ; preds = %23, %28
%29 = phi i64 [ %54, %28 ], [ %25, %23 ]
%30 = phi double [ %53, %28 ], [ %26, %23 ]
%31 = getelementptr inbounds double, double* %1, i64 %29
%32 = load double, double* %31
%33 = trunc i64 %29 to i32
%34 = tail call double @pow(double %2, i32 %33)
%35 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %30)
%36 = add nsw i64 %29, -1
%37 = getelementptr inbounds double, double* %1, i64 %36
%38 = load double, double* %37
%39 = trunc i64 %36 to i32
%40 = tail call double @pow(double %2, i32 %39)
%41 = tail call double @llvm.fmuladd.f64(double %38, double %40, double %35)
%42 = add nsw i64 %29, -2
%43 = getelementptr inbounds double, double* %1, i64 %42
%44 = load double, double* %43
%45 = trunc i64 %42 to i32
%46 = tail call double @pow(double %2, i32 %45)
%47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %41)
%48 = add nsw i64 %29, -3
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = load double, double* %49
%51 = trunc i64 %48 to i32
%52 = tail call double @pow(double %2, i32 %51)
%53 = tail call double @llvm.fmuladd.f64(double %50, double %52, double %47)
%54 = add nsw i64 %29, -4
%55 = trunc i64 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %28
57: ; preds = %23, %28, %3
%58 = phi double [ %4, %3 ], [ %24, %23 ], [ %53, %28 ]
ret double %58
}