#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 */
float const cos(float const);
float const sin(float const);
float get_wave_height(const float pos[2], const float coef, const float freq1,
                      const float freq2, const float time) {
  return coef * sin((pos[0] + pos[1]) * freq1 + time) *
         cos((pos[0] - pos[1]) * freq2 + (time + 4));
  ;
}


x86 assembly (clang, -O0):
<get_wave_height>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addss  0x4(%rax),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  -0x14(%rbp),%xmm2
movss  0xe5f(%rip),%xmm1
addss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_wave_height>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm0,0x4(%rsp)
mov    %rdi,%rbx
movss  (%rdi),%xmm0
addss  0x4(%rdi),%xmm0
mulss  %xmm1,%xmm0
addss  %xmm3,%xmm0
call   1030 <sin@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  (%rbx),%xmm0
subss  0x4(%rbx),%xmm0
movss  0x8(%rsp),%xmm1
addss  0xe8d(%rip),%xmm1
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
call   1040 <cos@plt>
mulss  0x4(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @get_wave_height(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%11 = load float, float* %7
%12 = load float*, float** %6
%13 = getelementptr inbounds float, float* %12, i64 0
%14 = load float, float* %13
%15 = load float*, float** %6
%16 = getelementptr inbounds float, float* %15, i64 1
%17 = load float, float* %16
%18 = fadd float %14, %17
%19 = load float, float* %8
%20 = load float, float* %10
%21 = call float @llvm.fmuladd.f32(float %18, float %19, float %20)
%22 = call float @sin(float %21)
%23 = fmul float %11, %22
%24 = load float*, float** %6
%25 = getelementptr inbounds float, float* %24, i64 0
%26 = load float, float* %25
%27 = load float*, float** %6
%28 = getelementptr inbounds float, float* %27, i64 1
%29 = load float, float* %28
%30 = fsub float %26, %29
%31 = load float, float* %9
%32 = load float, float* %10
%33 = fadd float %32, 4.000000e+00
%34 = call float @llvm.fmuladd.f32(float %30, float %31, float %33)
%35 = call float @cos(float %34)
%36 = fmul float %23, %35
ret float %36
}

LLVM IR (-O2):
define float @get_wave_height(float* nocapture %0, float %1, float %2, float %3, float %4) {
%6 = load float, float* %0
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = fadd float %6, %8
%10 = tail call float @llvm.fmuladd.f32(float %9, float %2, float %4)
%11 = tail call float @sin(float %10)
%12 = fmul float %11, %1
%13 = load float, float* %0
%14 = load float, float* %7
%15 = fsub float %13, %14
%16 = fadd float %4, 4.000000e+00
%17 = tail call float @llvm.fmuladd.f32(float %15, float %3, float %16)
%18 = tail call float @cos(float %17)
%19 = fmul float %12, %18
ret float %19
}