#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 floats_magnitude(float const *, int);
void floats_quat_inverse(const float q[4], float r[4]) {
  float mag = floats_magnitude(q, 4);
  r[0] = q[0] / mag;
  r[1] = -q[1] / mag;
  r[2] = -q[2] / mag;
  r[3] = -q[3] / mag;
}


x86 assembly (clang, -O0):
<floats_quat_inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1030 <floats_magnitude@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_quat_inverse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x4,%esi
call   1030 <floats_magnitude@plt>
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rbx),%xmm1
movaps 0xec3(%rip),%xmm2
xorps  %xmm2,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movss  0x8(%rbx),%xmm1
xorps  %xmm2,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%r14)
movss  0xc(%rbx),%xmm1
xorps  %xmm2,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @floats_quat_inverse(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %3
%7 = call float @floats_magnitude(float* %6, i32 4)
store float %7, float* %5
%8 = load float*, float** %3
%9 = getelementptr inbounds float, float* %8, i64 0
%10 = load float, float* %9
%11 = load float, float* %5
%12 = fdiv float %10, %11
%13 = load float*, float** %4
%14 = getelementptr inbounds float, float* %13, i64 0
store float %12, float* %14
%15 = load float*, float** %3
%16 = getelementptr inbounds float, float* %15, i64 1
%17 = load float, float* %16
%18 = fneg float %17
%19 = load float, float* %5
%20 = fdiv float %18, %19
%21 = load float*, float** %4
%22 = getelementptr inbounds float, float* %21, i64 1
store float %20, float* %22
%23 = load float*, float** %3
%24 = getelementptr inbounds float, float* %23, i64 2
%25 = load float, float* %24
%26 = fneg float %25
%27 = load float, float* %5
%28 = fdiv float %26, %27
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 2
store float %28, float* %30
%31 = load float*, float** %3
%32 = getelementptr inbounds float, float* %31, i64 3
%33 = load float, float* %32
%34 = fneg float %33
%35 = load float, float* %5
%36 = fdiv float %34, %35
%37 = load float*, float** %4
%38 = getelementptr inbounds float, float* %37, i64 3
store float %36, float* %38
ret void
}

LLVM IR (-O2):
define void @floats_quat_inverse(float* %0, float* nocapture writeonly %1) {
%3 = tail call float @floats_magnitude(float* %0, i32 4)
%4 = load float, float* %0
%5 = fdiv float %4, %3
store float %5, float* %1
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = fneg float %7
%9 = fdiv float %8, %3
%10 = getelementptr inbounds float, float* %1, i64 1
store float %9, float* %10
%11 = getelementptr inbounds float, float* %0, i64 2
%12 = load float, float* %11
%13 = fneg float %12
%14 = fdiv float %13, %3
%15 = getelementptr inbounds float, float* %1, i64 2
store float %14, float* %15
%16 = getelementptr inbounds float, float* %0, i64 3
%17 = load float, float* %16
%18 = fneg float %17
%19 = fdiv float %18, %3
%20 = getelementptr inbounds float, float* %1, i64 3
store float %19, float* %20
ret void
}