#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 */
int /*<<< orphan*/ _trical_measurement_calibrate(float *, float *, float *);
int /*<<< orphan*/ fabs(float);
scalar_t__ sqrt(int /*<<< orphan*/);
float _trical_measurement_reduce(float state[12], float measurement[3],
                                 float field[3]) {
  float temp[3];
  _trical_measurement_calibrate(state, measurement, temp);
  return (float)sqrt(
      (fabs(temp[0] * field[0] + temp[1] * field[1] + temp[2] * field[2])));
}


x86 assembly (clang, -O0):
<_trical_measurement_reduce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <_trical_measurement_calibrate@plt>
movss  -0x24(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
movss  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
cvtsi2ss %rax,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_trical_measurement_reduce>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0x4(%rsp),%rdx
call   1040 <_trical_measurement_calibrate@plt>
movss  0x8(%rsp),%xmm0
mulss  0x4(%rbx),%xmm0
movss  0x4(%rsp),%xmm1
mulss  (%rbx),%xmm1
addss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
mulss  0x8(%rbx),%xmm0
addss  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @_trical_measurement_reduce(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [3 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%8 = load float*, float** %4
%9 = load float*, float** %5
%10 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%11 = call i32 @_trical_measurement_calibrate(float* %8, float* %9, float* %10)
%12 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%13 = load float, float* %12
%14 = load float*, float** %6
%15 = getelementptr inbounds float, float* %14, i64 0
%16 = load float, float* %15
%17 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%18 = load float, float* %17
%19 = load float*, float** %6
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = fmul float %18, %21
%23 = call float @llvm.fmuladd.f32(float %13, float %16, float %22)
%24 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%25 = load float, float* %24
%26 = load float*, float** %6
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
%29 = call float @llvm.fmuladd.f32(float %25, float %28, float %23)
%30 = call i32 @fabs(float %29)
%31 = call i64 @sqrt(i32 %30)
%32 = sitofp i64 %31 to float
ret float %32
}

LLVM IR (-O2):
define float @_trical_measurement_reduce(float* %0, float* %1, float* nocapture %2) {
%4 = alloca [3 x float]
%5 = bitcast [3 x float]* %4 to i8*
%6 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%7 = call i32 @_trical_measurement_calibrate(float* %0, float* %1, float* %6)
%8 = load float, float* %6
%9 = load float, float* %2
%10 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
%11 = load float, float* %10
%12 = getelementptr inbounds float, float* %2, i64 1
%13 = load float, float* %12
%14 = fmul float %11, %13
%15 = call float @llvm.fmuladd.f32(float %8, float %9, float %14)
%16 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %2, i64 2
%19 = load float, float* %18
%20 = call float @llvm.fmuladd.f32(float %17, float %19, float %15)
%21 = call i32 @fabs(float %20)
%22 = call i64 @sqrt(i32 %21)
%23 = sitofp i64 %22 to float
ret float %23
}