#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 */
struct RVArray {
  int dummy;
};

/* Variables and functions */
double RVArrayGetElementAtIndex(struct RVArray const *, int);
int /*<<< orphan*/ RVArraySetElementAtIndex(struct RVArray *,
                                            int /*<<< orphan*/, double);
int sphere2(const struct RVArray *dv, struct RVArray *obj, void *data) {
  double x = RVArrayGetElementAtIndex(dv, 0);
  double y = RVArrayGetElementAtIndex(dv, 1);
  RVArraySetElementAtIndex(obj, 0, x * x + y * y);
  return 0;
}


x86 assembly (clang, -O0):
<sphere2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <RVArrayGetElementAtIndex@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <RVArrayGetElementAtIndex@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xor    %esi,%esi
call   1030 <RVArraySetElementAtIndex@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphere2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <RVArrayGetElementAtIndex@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <RVArrayGetElementAtIndex@plt>
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <RVArraySetElementAtIndex@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.RVArray = type { i32 }
define i32 @sphere2(%struct.RVArray* %0, %struct.RVArray* %1, i8* %2) {
%4 = alloca %struct.RVArray*
%5 = alloca %struct.RVArray*
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
store %struct.RVArray* %0, %struct.RVArray** %4
store %struct.RVArray* %1, %struct.RVArray** %5
store i8* %2, i8** %6
%9 = load %struct.RVArray*, %struct.RVArray** %4
%10 = call double @RVArrayGetElementAtIndex(%struct.RVArray* %9, i32 0)
store double %10, double* %7
%11 = load %struct.RVArray*, %struct.RVArray** %4
%12 = call double @RVArrayGetElementAtIndex(%struct.RVArray* %11, i32 1)
store double %12, double* %8
%13 = load %struct.RVArray*, %struct.RVArray** %5
%14 = load double, double* %7
%15 = load double, double* %7
%16 = load double, double* %8
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = call i32 @RVArraySetElementAtIndex(%struct.RVArray* %13, i32 0, double %19)
ret i32 0
}

LLVM IR (-O2):
%struct.RVArray = type { i32 }
define i32 @sphere2(%struct.RVArray* %0, %struct.RVArray* %1, i8* nocapture readnone %2) {
%4 = tail call double @RVArrayGetElementAtIndex(%struct.RVArray* %0, i32 0)
%5 = tail call double @RVArrayGetElementAtIndex(%struct.RVArray* %0, i32 1)
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %6)
%8 = tail call i32 @RVArraySetElementAtIndex(%struct.RVArray* %1, i32 0, double %7)
ret i32 0
}