#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 */
scalar_t__ pow(float, int);
float sqrt(scalar_t__);
void sense(float x, float y, float direction, float *measurement_ref,
           unsigned int **sensed) {
  int i;
  for (i = 0; i < 3; i++) {
    float dist_from_ref =
        sqrt(pow((x - sensed[i][0]), 2) + pow((y - sensed[i][1]), 2));
    measurement_ref[i] = dist_from_ref;
  }
  return;
}


x86 assembly (clang, -O0):
<sense>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11d2 <sense+0xb2>
movss  -0x4(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
cvtsi2ss %rax,%xmm1
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x4(%rax),%eax
cvtsi2ss %rax,%xmm1
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1146 <sense+0x26>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sense>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
mov    (%rsi),%rax
mov    (%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rbx
mov    (%r15),%rax
mov    0x4(%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0x8(%rsp),%xmm0
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,(%r14)
mov    0x8(%r15),%rax
mov    (%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rbx
mov    0x8(%r15),%rax
mov    0x4(%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0x8(%rsp),%xmm0
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,0x4(%r14)
mov    0x10(%r15),%rax
mov    (%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rbx
mov    0x10(%r15),%rax
mov    0x4(%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0x8(%rsp),%xmm0
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,0x8(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sense(float %0, float %1, float %2, float* %3, i32** %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float*
%10 = alloca i32**
%11 = alloca i32
%12 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float* %3, float** %9
store i32** %4, i32*** %10
store i32 0, i32* %11
br label %13
13: ; preds = %46, %5
%14 = load i32, i32* %11
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %49
16: ; preds = %13
%17 = load float, float* %6
%18 = load i32**, i32*** %10
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32*, i32** %18, i64 %20
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
%25 = uitofp i32 %24 to float
%26 = fsub float %17, %25
%27 = call i64 @pow(float %26, i32 2)
%28 = load float, float* %7
%29 = load i32**, i32*** %10
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32*, i32** %29, i64 %31
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 1
%35 = load i32, i32* %34
%36 = uitofp i32 %35 to float
%37 = fsub float %28, %36
%38 = call i64 @pow(float %37, i32 2)
%39 = add nsw i64 %27, %38
%40 = call float @sqrt(i64 %39)
store float %40, float* %12
%41 = load float, float* %12
%42 = load float*, float** %9
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %42, i64 %44
store float %41, float* %45
br label %46
46: ; preds = %16
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %13
49: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @sense(float %0, float %1, float %2, float* nocapture writeonly %3, i32** nocapture %4) {
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = uitofp i32 %7 to float
%9 = fsub float %0, %8
%10 = tail call i64 @pow(float %9, i32 2)
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
%14 = uitofp i32 %13 to float
%15 = fsub float %1, %14
%16 = tail call i64 @pow(float %15, i32 2)
%17 = add nsw i64 %16, %10
%18 = tail call float @sqrt(i64 %17)
store float %18, float* %3
%19 = getelementptr inbounds i32*, i32** %4, i64 1
%20 = load i32*, i32** %19
%21 = load i32, i32* %20
%22 = uitofp i32 %21 to float
%23 = fsub float %0, %22
%24 = tail call i64 @pow(float %23, i32 2)
%25 = load i32*, i32** %19
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = uitofp i32 %27 to float
%29 = fsub float %1, %28
%30 = tail call i64 @pow(float %29, i32 2)
%31 = add nsw i64 %30, %24
%32 = tail call float @sqrt(i64 %31)
%33 = getelementptr inbounds float, float* %3, i64 1
store float %32, float* %33
%34 = getelementptr inbounds i32*, i32** %4, i64 2
%35 = load i32*, i32** %34
%36 = load i32, i32* %35
%37 = uitofp i32 %36 to float
%38 = fsub float %0, %37
%39 = tail call i64 @pow(float %38, i32 2)
%40 = load i32*, i32** %34
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = load i32, i32* %41
%43 = uitofp i32 %42 to float
%44 = fsub float %1, %43
%45 = tail call i64 @pow(float %44, i32 2)
%46 = add nsw i64 %45, %39
%47 = tail call float @sqrt(i64 %46)
%48 = getelementptr inbounds float, float* %3, i64 2
store float %47, float* %48
ret void
}