#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 */
scalar_t__ pow(float, int);
double rand0to1();
float const sqrt(scalar_t__);
int rand_in_rad(const float rad, float *x, float *y) {
  int found = 0;
  float tx, ty;
  do {
    tx = 2 * rad * (rand0to1() - 0.5);
    ty = 2 * rad * (rand0to1() - 0.5);
    if (rad > sqrt(pow(tx, 2) + pow(ty, 2))) {
      found = 1;
    }
  } while (!found);
  *x = tx;
  *y = ty;
  return 0;
}


x86 assembly (clang, -O0):
<rand_in_rad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movss  0xeb4(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1030 <rand0to1@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  0xe87(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe76(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1030 <rand0to1@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe49(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1218 <rand_in_rad+0xe8>
movl   $0x1,-0x1c(%rbp)
jmp    121d <rand_in_rad+0xed>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    114c <rand_in_rad+0x1c>
movss  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_in_rad>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movss  %xmm0,0x14(%rsp)
addss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <rand0to1@plt>
movsd  0xe91(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <rand0to1@plt>
addsd  0xe6e(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,%rbx
movss  0xc(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <sqrt@plt>
movss  0x14(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    1160 <rand_in_rad+0x30>
movss  0x10(%rsp),%xmm0
movss  %xmm0,(%r15)
movss  0xc(%rsp),%xmm0
movss  %xmm0,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @rand_in_rad(float %0, float* %1, float* %2) {
%4 = alloca float
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float* %1, float** %5
store float* %2, float** %6
store i32 0, i32* %7
br label %10
10: ; preds = %35, %3
%11 = load float, float* %4
%12 = fmul float 2.000000e+00, %11
%13 = fpext float %12 to double
%14 = call double (...) @rand0to1()
%15 = fsub double %14, 5.000000e-01
%16 = fmul double %13, %15
%17 = fptrunc double %16 to float
store float %17, float* %8
%18 = load float, float* %4
%19 = fmul float 2.000000e+00, %18
%20 = fpext float %19 to double
%21 = call double (...) @rand0to1()
%22 = fsub double %21, 5.000000e-01
%23 = fmul double %20, %22
%24 = fptrunc double %23 to float
store float %24, float* %9
%25 = load float, float* %4
%26 = load float, float* %8
%27 = call i64 @pow(float %26, i32 2)
%28 = load float, float* %9
%29 = call i64 @pow(float %28, i32 2)
%30 = add nsw i64 %27, %29
%31 = call float @sqrt(i64 %30)
%32 = fcmp ogt float %25, %31
br i1 %32, label %33, label %34
33: ; preds = %10
store i32 1, i32* %7
br label %34
34: ; preds = %33, %10
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
br i1 %38, label %10, label %39
39: ; preds = %35
%40 = load float, float* %8
%41 = load float*, float** %5
store float %40, float* %41
%42 = load float, float* %9
%43 = load float*, float** %6
store float %42, float* %43
ret i32 0
}

LLVM IR (-O2):
define i32 @rand_in_rad(float %0, float* nocapture writeonly %1, float* nocapture writeonly %2) {
%4 = fmul float %0, 2.000000e+00
%5 = fpext float %4 to double
br label %6
6: ; preds = %6, %3
%7 = tail call double (...) @rand0to1()
%8 = fadd double %7, -5.000000e-01
%9 = fmul double %8, %5
%10 = fptrunc double %9 to float
%11 = tail call double (...) @rand0to1()
%12 = fadd double %11, -5.000000e-01
%13 = fmul double %12, %5
%14 = fptrunc double %13 to float
%15 = tail call i64 @pow(float %10, i32 2)
%16 = tail call i64 @pow(float %14, i32 2)
%17 = add nsw i64 %16, %15
%18 = tail call float @sqrt(i64 %17)
%19 = fcmp uge float %18, %0
br i1 %19, label %6, label %20
20: ; preds = %6
store float %10, float* %1
store float %14, float* %2
ret i32 0
}