#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 */
int sqrt(float);
void rvec2st(float rx, float ry, float rz, float *sp, float *tp) {
  double s, t;
  double m;
  m = 2 * sqrt(rx * rx + ry * ry + (rz + 1) * (rz + 1));
  s = rx / m + 0.5;
  t = ry / m + 0.5;
  *sp = (float)s;
  *tp = (float)t;
}


x86 assembly (clang, -O0):
<rvec2st>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xeb5(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  0xea8(%rip),%xmm2
addss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rvec2st>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
mulss  %xmm0,%xmm0
addss  %xmm3,%xmm0
addss  0xec4(%rip),%xmm2
mulss  %xmm2,%xmm2
addss  %xmm2,%xmm0
call   1030 <sqrt@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm0,%xmm1
movsd  0xea1(%rip),%xmm2
addsd  %xmm2,%xmm1
movss  0x4(%rsp),%xmm3
cvtss2sd %xmm3,%xmm3
divsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
movss  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @rvec2st(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 double
%12 = alloca double
%13 = alloca double
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
%14 = load float, float* %6
%15 = load float, float* %6
%16 = load float, float* %7
%17 = load float, float* %7
%18 = fmul float %16, %17
%19 = call float @llvm.fmuladd.f32(float %14, float %15, float %18)
%20 = load float, float* %8
%21 = fadd float %20, 1.000000e+00
%22 = load float, float* %8
%23 = fadd float %22, 1.000000e+00
%24 = call float @llvm.fmuladd.f32(float %21, float %23, float %19)
%25 = call i32 @sqrt(float %24)
%26 = mul nsw i32 2, %25
%27 = sitofp i32 %26 to double
store double %27, double* %13
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = load double, double* %13
%31 = fdiv double %29, %30
%32 = fadd double %31, 5.000000e-01
store double %32, double* %11
%33 = load float, float* %7
%34 = fpext float %33 to double
%35 = load double, double* %13
%36 = fdiv double %34, %35
%37 = fadd double %36, 5.000000e-01
store double %37, double* %12
%38 = load double, double* %11
%39 = fptrunc double %38 to float
%40 = load float*, float** %9
store float %39, float* %40
%41 = load double, double* %12
%42 = fptrunc double %41 to float
%43 = load float*, float** %10
store float %42, float* %43
ret void
}

LLVM IR (-O2):
define void @rvec2st(float %0, float %1, float %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = fmul float %1, %1
%7 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %6)
%8 = fadd float %2, 1.000000e+00
%9 = tail call float @llvm.fmuladd.f32(float %8, float %8, float %7)
%10 = tail call i32 @sqrt(float %9)
%11 = shl nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = fpext float %0 to double
%14 = fdiv double %13, %12
%15 = fadd double %14, 5.000000e-01
%16 = fpext float %1 to double
%17 = fdiv double %16, %12
%18 = fadd double %17, 5.000000e-01
%19 = fptrunc double %15 to float
store float %19, float* %3
%20 = fptrunc double %18 to float
store float %20, float* %4
ret void
}