#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 dist3dsqrd(float, float, float);
float snis_random_float();
void random_point_in_sphere(float radius, float *x, float *y, float *z,
                            float *dsqrd) {
  const float rsqrd = radius * radius;
  do {
    *x = snis_random_float() * radius;
    *y = snis_random_float() * radius;
    *z = snis_random_float() * radius;
    *dsqrd = dist3dsqrd(*x, *y, *z);
  } while (*dsqrd > rsqrd);
}


x86 assembly (clang, -O0):
<random_point_in_sphere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <snis_random_float@plt>
mulss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1040 <snis_random_float@plt>
mulss  -0x4(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1040 <snis_random_float@plt>
mulss  -0x4(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm2
call   1030 <dist3dsqrd@plt>
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
ucomiss -0x2c(%rbp),%xmm0
ja     114c <random_point_in_sphere+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_point_in_sphere>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movss  %xmm0,(%rsp)
mulss  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <snis_random_float@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%rbx)
xor    %eax,%eax
call   1040 <snis_random_float@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%r12)
xor    %eax,%eax
call   1040 <snis_random_float@plt>
movaps %xmm0,%xmm2
mulss  (%rsp),%xmm2
movss  %xmm2,(%r15)
movss  (%rbx),%xmm0
movss  (%r12),%xmm1
call   1030 <dist3dsqrd@plt>
movss  %xmm0,(%r14)
ucomiss 0x4(%rsp),%xmm0
ja     1150 <random_point_in_sphere+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @random_point_in_sphere(float %0, float* %1, float* %2, float* %3, float* %4) {
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float
store float %0, float* %6
store float* %1, float** %7
store float* %2, float** %8
store float* %3, float** %9
store float* %4, float** %10
%12 = load float, float* %6
%13 = load float, float* %6
%14 = fmul float %12, %13
store float %14, float* %11
br label %15
15: ; preds = %36, %5
%16 = call float (...) @snis_random_float()
%17 = load float, float* %6
%18 = fmul float %16, %17
%19 = load float*, float** %7
store float %18, float* %19
%20 = call float (...) @snis_random_float()
%21 = load float, float* %6
%22 = fmul float %20, %21
%23 = load float*, float** %8
store float %22, float* %23
%24 = call float (...) @snis_random_float()
%25 = load float, float* %6
%26 = fmul float %24, %25
%27 = load float*, float** %9
store float %26, float* %27
%28 = load float*, float** %7
%29 = load float, float* %28
%30 = load float*, float** %8
%31 = load float, float* %30
%32 = load float*, float** %9
%33 = load float, float* %32
%34 = call float @dist3dsqrd(float %29, float %31, float %33)
%35 = load float*, float** %10
store float %34, float* %35
br label %36
36: ; preds = %15
%37 = load float*, float** %10
%38 = load float, float* %37
%39 = load float, float* %11
%40 = fcmp ogt float %38, %39
br i1 %40, label %15, label %41
41: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @random_point_in_sphere(float %0, float* nocapture %1, float* nocapture %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = fmul float %0, %0
br label %7
7: ; preds = %7, %5
%8 = tail call float (...) @snis_random_float()
%9 = fmul float %8, %0
store float %9, float* %1
%10 = tail call float (...) @snis_random_float()
%11 = fmul float %10, %0
store float %11, float* %2
%12 = tail call float (...) @snis_random_float()
%13 = fmul float %12, %0
store float %13, float* %3
%14 = load float, float* %1
%15 = load float, float* %2
%16 = tail call float @dist3dsqrd(float %14, float %15, float %13)
store float %16, float* %4
%17 = fcmp ogt float %16, %6
br i1 %17, label %7, label %18
18: ; preds = %7
ret void
}