#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 sin(double);
double Sinusoidal3D(double *coordinates) {
  double Lenght = 1;
  double Hight = 20;
  double Energy = 0.0;
  for (int i = 0; i < 3; i++) {
    Energy += Hight * sin(coordinates[i] / Lenght);
  }
  return Energy;
}


x86 assembly (clang, -O0):
<Sinusoidal3D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xee4(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1198 <Sinusoidal3D+0x88>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <Sinusoidal3D+0x35>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sinusoidal3D>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <sin@plt>
mulsd  0xed7(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0xeb7(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0xe99(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @Sinusoidal3D(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double* %0, double** %2
store double 1.000000e+00, double* %3
store double 2.000000e+01, double* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %6
br label %7
7: ; preds = %22, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load double, double* %4
%12 = load double*, double** %2
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double, double* %3
%18 = fdiv double %16, %17
%19 = call double @sin(double %18)
%20 = load double, double* %5
%21 = call double @llvm.fmuladd.f64(double %11, double %19, double %20)
store double %21, double* %5
br label %22
22: ; preds = %10
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %7
25: ; preds = %7
%26 = load double, double* %5
ret double %26
}

LLVM IR (-O2):
define double @Sinusoidal3D(double* nocapture %0) {
%2 = load double, double* %0
%3 = tail call double @sin(double %2)
%4 = tail call double @llvm.fmuladd.f64(double %3, double 2.000000e+01, double 0.000000e+00)
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = tail call double @sin(double %6)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+01, double %4)
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = tail call double @sin(double %10)
%12 = tail call double @llvm.fmuladd.f64(double %11, double 2.000000e+01, double %8)
ret double %12
}