#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);
float drand(float);
float sinf(float);
float sqrtf(float);
void vrand(float a, float *x, float *y, float *z) {
  float v = drand(2.0f * 3.141592654f);
  float u = drand(2.0f) - 1.0f;
  float r = sqrtf(1.0f - u * u);
  *x = a * r * cosf(v);
  *y = a * r * sinf(v);
  *z = a * u;
}


x86 assembly (clang, -O0):
<vrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movss  0xea7(%rip),%xmm0
call   1040 <drand@plt>
movss  %xmm0,-0x24(%rbp)
movss  0xe91(%rip),%xmm0
call   1040 <drand@plt>
movss  0xe80(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm1,%xmm0
movss  0xe54(%rip),%xmm1
addss  %xmm1,%xmm0
call   1060 <sqrtf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x24(%rbp),%xmm0
call   1050 <cosf@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrand>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  %xmm0,0x8(%rsp)
movss  0xea0(%rip),%xmm0
call   1040 <drand@plt>
movss  %xmm0,0x4(%rsp)
movss  0xe91(%rip),%xmm0
call   1040 <drand@plt>
addss  0xe88(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  0xe77(%rip),%xmm0
subss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11a7 <vrand+0x67>
sqrtss %xmm0,%xmm0
jmp    11ac <vrand+0x6c>
call   1060 <sqrtf@plt>
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
call   1050 <cosf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x4(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%r15)
movss  0xc(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @vrand(float %0, float* %1, float* %2, float* %3) {
%5 = alloca float
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float %0, float* %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%12 = call float @drand(float 0x401921FB60000000)
store float %12, float* %9
%13 = call float @drand(float 2.000000e+00)
%14 = fsub float %13, 1.000000e+00
store float %14, float* %10
%15 = load float, float* %10
%16 = load float, float* %10
%17 = fneg float %15
%18 = call float @llvm.fmuladd.f32(float %17, float %16, float 1.000000e+00)
%19 = call float @sqrtf(float %18)
store float %19, float* %11
%20 = load float, float* %5
%21 = load float, float* %11
%22 = fmul float %20, %21
%23 = load float, float* %9
%24 = call float @cosf(float %23)
%25 = fmul float %22, %24
%26 = load float*, float** %6
store float %25, float* %26
%27 = load float, float* %5
%28 = load float, float* %11
%29 = fmul float %27, %28
%30 = load float, float* %9
%31 = call float @sinf(float %30)
%32 = fmul float %29, %31
%33 = load float*, float** %7
store float %32, float* %33
%34 = load float, float* %5
%35 = load float, float* %10
%36 = fmul float %34, %35
%37 = load float*, float** %8
store float %36, float* %37
ret void
}

LLVM IR (-O2):
define void @vrand(float %0, float* nocapture writeonly %1, float* nocapture writeonly %2, float* nocapture writeonly %3) {
%5 = tail call float @drand(float 0x401921FB60000000)
%6 = tail call float @drand(float 2.000000e+00)
%7 = fadd float %6, -1.000000e+00
%8 = fneg float %7
%9 = tail call float @llvm.fmuladd.f32(float %8, float %7, float 1.000000e+00)
%10 = tail call float @sqrtf(float %9)
%11 = fmul float %10, %0
%12 = tail call float @cosf(float %5)
%13 = fmul float %11, %12
store float %13, float* %1
%14 = tail call float @sinf(float %5)
%15 = fmul float %11, %14
store float %15, float* %2
%16 = fmul float %7, %0
store float %16, float* %3
ret void
}