#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 cosf(float);
int /*<<< orphan*/ quat_normalize(float *, float *);
float sinf(float);
float *quat_from_axis_angle(float *result, float *a, float angle) {
  float half = angle * 0.5f;
  float s = sinf(half);
  result[0] = a[0] * s;
  result[1] = a[1] * s;
  result[2] = a[2] * s;
  result[3] = cosf(half);
  quat_normalize(result, result);
  return result;
}


x86 assembly (clang, -O0):
<quat_from_axis_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  0xeb3(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <sinf@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x18(%rbp),%xmm0
call   1050 <cosf@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <quat_normalize@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_from_axis_angle>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mulss  0xebe(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1040 <sinf@plt>
movss  (%r14),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  0x4(%r14),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rbx)
mulss  0x8(%r14),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x4(%rsp),%xmm0
call   1050 <cosf@plt>
movss  %xmm0,0xc(%rbx)
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <quat_normalize@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define float* @quat_from_axis_angle(float* returned %0, float* nocapture %1, float %2) {
%4 = fmul float %2, 5.000000e-01
%5 = tail call float @sinf(float %4)
%6 = load float, float* %1
%7 = fmul float %5, %6
store float %7, float* %0
%8 = getelementptr inbounds float, float* %1, i64 1
%9 = load float, float* %8
%10 = fmul float %5, %9
%11 = getelementptr inbounds float, float* %0, i64 1
store float %10, float* %11
%12 = getelementptr inbounds float, float* %1, i64 2
%13 = load float, float* %12
%14 = fmul float %5, %13
%15 = getelementptr inbounds float, float* %0, i64 2
store float %14, float* %15
%16 = tail call float @cosf(float %4)
%17 = getelementptr inbounds float, float* %0, i64 3
store float %16, float* %17
%18 = tail call i32 @quat_normalize(float* %0, float* %0)
ret float* %0
}