#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 sqrtf(float);
float nvg__getAverageScale(float *t) {
  float sx = sqrtf(t[0] * t[0] + t[2] * t[2]);
  float sy = sqrtf(t[1] * t[1] + t[3] * t[3]);
  return (sx + sy) * 0.5f;
}


x86 assembly (clang, -O0):
<nvg__getAverageScale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulss  0x8(%rax),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulss  0xc(%rax),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xe68(%rip),%xmm1
mulss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nvg__getAverageScale>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x8(%rdi),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm0
jb     113b <nvg__getAverageScale+0x2b>
sqrtss %xmm0,%xmm2
jmp    1146 <nvg__getAverageScale+0x36>
call   1030 <sqrtf@plt>
xorps  %xmm3,%xmm3
movaps %xmm0,%xmm2
movss  0x4(%rbx),%xmm0
movss  0xc(%rbx),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss %xmm3,%xmm0
jb     1167 <nvg__getAverageScale+0x57>
sqrtss %xmm0,%xmm0
jmp    1178 <nvg__getAverageScale+0x68>
movss  %xmm2,0xc(%rsp)
call   1030 <sqrtf@plt>
movss  0xc(%rsp),%xmm2
addss  %xmm0,%xmm2
mulss  0xe7c(%rip),%xmm2
movaps %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define float @nvg__getAverageScale(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 2
%4 = load float, float* %3
%5 = fmul float %4, %4
%6 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %5)
%7 = tail call float @sqrtf(float %6)
%8 = getelementptr inbounds float, float* %0, i64 1
%9 = load float, float* %8
%10 = getelementptr inbounds float, float* %0, i64 3
%11 = load float, float* %10
%12 = fmul float %11, %11
%13 = tail call float @llvm.fmuladd.f32(float %9, float %9, float %12)
%14 = tail call float @sqrtf(float %13)
%15 = fadd float %7, %14
%16 = fmul float %15, 5.000000e-01
ret float %16
}