#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 fabs(double);
double sqrt(float);
void lib3ds_quat_inv(float c[4]) {
  double l, m;
  l = sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2] + c[3] * c[3]);
  if (fabs(l) < (1e-5)) {
    c[0] = c[1] = c[2] = 0.0f;
    c[3] = 1.0f;
  } else {
    m = 1.0f / l;
    c[0] = (float)(-c[0] * m);
    c[1] = (float)(-c[1] * m);
    c[2] = (float)(-c[2] * m);
    c[3] = (float)(c[3] * m);
  }
}


x86 assembly (clang, -O0):
<lib3ds_quat_inv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe56(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ed <lib3ds_quat_inv+0xcd>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0xe2d(%rip),%xmm0
movss  %xmm0,0xc(%rax)
jmp    12a0 <lib3ds_quat_inv+0x180>
movsd  0xe13(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib3ds_quat_inv>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  0x8(%rdi),%xmm1
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0xc(%rdi),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    11e5 <lib3ds_quat_inv+0xc5>
movsd  0xe8d(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
movaps 0xe90(%rip),%xmm1
movss  (%rbx),%xmm2
movss  0x4(%rbx),%xmm3
movss  0x8(%rbx),%xmm4
xorps  %xmm1,%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm0,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  %xmm2,(%rbx)
xorps  %xmm1,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
mulsd  %xmm0,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  %xmm2,0x4(%rbx)
xorps  %xmm1,%xmm4
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
mulsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,0x8(%rbx)
movss  0xc(%rbx),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
jmp    11fb <lib3ds_quat_inv+0xdb>
movl   $0x0,0x8(%rbx)
movq   $0x0,(%rbx)
movss  0xe25(%rip),%xmm0
movss  %xmm0,0xc(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @lib3ds_quat_inv(float* %0) {
%2 = alloca float*
%3 = alloca double
%4 = alloca double
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 1
%13 = load float, float* %12
%14 = load float*, float** %2
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
%17 = fmul float %13, %16
%18 = call float @llvm.fmuladd.f32(float %7, float %10, float %17)
%19 = load float*, float** %2
%20 = getelementptr inbounds float, float* %19, i64 2
%21 = load float, float* %20
%22 = load float*, float** %2
%23 = getelementptr inbounds float, float* %22, i64 2
%24 = load float, float* %23
%25 = call float @llvm.fmuladd.f32(float %21, float %24, float %18)
%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 = call float @llvm.fmuladd.f32(float %28, float %31, float %25)
%33 = call double @sqrt(float %32)
store double %33, double* %3
%34 = load double, double* %3
%35 = call i32 @fabs(double %34)
%36 = sitofp i32 %35 to double
%37 = fcmp olt double %36, 1.000000e-05
br i1 %37, label %38, label %47
38: ; preds = %1
%39 = load float*, float** %2
%40 = getelementptr inbounds float, float* %39, i64 2
store float 0.000000e+00, float* %40
%41 = load float*, float** %2
%42 = getelementptr inbounds float, float* %41, i64 1
store float 0.000000e+00, float* %42
%43 = load float*, float** %2
%44 = getelementptr inbounds float, float* %43, i64 0
store float 0.000000e+00, float* %44
%45 = load float*, float** %2
%46 = getelementptr inbounds float, float* %45, i64 3
store float 1.000000e+00, float* %46
br label %89
47: ; preds = %1
%48 = load double, double* %3
%49 = fdiv double 1.000000e+00, %48
store double %49, double* %4
%50 = load float*, float** %2
%51 = getelementptr inbounds float, float* %50, i64 0
%52 = load float, float* %51
%53 = fneg float %52
%54 = fpext float %53 to double
%55 = load double, double* %4
%56 = fmul double %54, %55
%57 = fptrunc double %56 to float
%58 = load float*, float** %2
%59 = getelementptr inbounds float, float* %58, i64 0
store float %57, float* %59
%60 = load float*, float** %2
%61 = getelementptr inbounds float, float* %60, i64 1
%62 = load float, float* %61
%63 = fneg float %62
%64 = fpext float %63 to double
%65 = load double, double* %4
%66 = fmul double %64, %65
%67 = fptrunc double %66 to float
%68 = load float*, float** %2
%69 = getelementptr inbounds float, float* %68, i64 1
store float %67, float* %69
%70 = load float*, float** %2
%71 = getelementptr inbounds float, float* %70, i64 2
%72 = load float, float* %71
%73 = fneg float %72
%74 = fpext float %73 to double
%75 = load double, double* %4
%76 = fmul double %74, %75
%77 = fptrunc double %76 to float
%78 = load float*, float** %2
%79 = getelementptr inbounds float, float* %78, i64 2
store float %77, float* %79
%80 = load float*, float** %2
%81 = getelementptr inbounds float, float* %80, i64 3
%82 = load float, float* %81
%83 = fpext float %82 to double
%84 = load double, double* %4
%85 = fmul double %83, %84
%86 = fptrunc double %85 to float
%87 = load float*, float** %2
%88 = getelementptr inbounds float, float* %87, i64 3
store float %86, float* %88
br label %89
89: ; preds = %47, %38
ret void
}

LLVM IR (-O2):
define void @lib3ds_quat_inv(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = fmul float %4, %4
%6 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %5)
%7 = getelementptr inbounds float, float* %0, i64 2
%8 = load float, float* %7
%9 = tail call float @llvm.fmuladd.f32(float %8, float %8, float %6)
%10 = getelementptr inbounds float, float* %0, i64 3
%11 = load float, float* %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float %11, float %9)
%13 = tail call double @sqrt(float %12)
%14 = tail call i32 @fabs(double %13)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %1
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %0
br label %38
17: ; preds = %1
%18 = fdiv double 1.000000e+00, %13
%19 = load float, float* %0
%20 = fneg float %19
%21 = fpext float %20 to double
%22 = fmul double %18, %21
%23 = fptrunc double %22 to float
store float %23, float* %0
%24 = load float, float* %3
%25 = fneg float %24
%26 = fpext float %25 to double
%27 = fmul double %18, %26
%28 = fptrunc double %27 to float
store float %28, float* %3
%29 = load float, float* %7
%30 = fneg float %29
%31 = fpext float %30 to double
%32 = fmul double %18, %31
%33 = fptrunc double %32 to float
store float %33, float* %7
%34 = load float, float* %10
%35 = fpext float %34 to double
%36 = fmul double %18, %35
%37 = fptrunc double %36 to float
br label %38
38: ; preds = %17, %16
%39 = phi float [ %37, %17 ], [ 1.000000e+00, %16 ]
store float %39, float* %10
ret void
}