#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 exp(double);
double sqrt(double);
double myvalue(double *x, int n) {
  double f, t;
  int i;
  f = 0.;
  for (i = 0; i < n; i++) {
    t = i + 1;
    t = sqrt(t);
    f += exp(x[i]) - t * x[i];
  }
  return (f);
}


x86 assembly (clang, -O0):
<myvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <myvalue+0xa6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <myvalue+0x1e>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myvalue>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    119e <myvalue+0x7e>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
jmp    117c <myvalue+0x5c>
nopl   (%rax)
call   1040 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%r15,%rbx,8),%xmm1
subsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %r12,%rbx
cmp    %r12,%r14
je     11a2 <myvalue+0x82>
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%r12
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
ucomisd 0xe6a(%rip),%xmm0
jb     1140 <myvalue+0x20>
sqrtsd %xmm0,%xmm0
jmp    1145 <myvalue+0x25>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @myvalue(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %7
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 1
%15 = sitofp i32 %14 to double
store double %15, double* %6
%16 = load double, double* %6
%17 = call double @sqrt(double %16)
store double %17, double* %6
%18 = load double*, double** %3
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = call double @exp(double %22)
%24 = load double, double* %6
%25 = load double*, double** %3
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fneg double %24
%31 = call double @llvm.fmuladd.f64(double %30, double %29, double %23)
%32 = load double, double* %5
%33 = fadd double %32, %31
store double %33, double* %5
br label %34
34: ; preds = %12
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %8
37: ; preds = %8
%38 = load double, double* %5
ret double %38
}

LLVM IR (-O2):
define double @myvalue(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %9, %6 ]
%8 = phi double [ 0.000000e+00, %4 ], [ %19, %6 ]
%9 = add nuw nsw i64 %7, 1
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to double
%12 = tail call double @sqrt(double %11)
%13 = getelementptr inbounds double, double* %0, i64 %7
%14 = load double, double* %13
%15 = tail call double @exp(double %14)
%16 = load double, double* %13
%17 = fneg double %12
%18 = tail call double @llvm.fmuladd.f64(double %17, double %16, double %15)
%19 = fadd double %8, %18
%20 = icmp eq i64 %9, %5
br i1 %20, label %21, label %6
21: ; preds = %6, %2
%22 = phi double [ 0.000000e+00, %2 ], [ %19, %6 ]
ret double %22
}