#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 */
double sqrt(double);
void rotmat_2d_fr_slope(double *out, double dy, double dx) {
  double r;
  r = sqrt(dy * dy + dx * dx);
  out[0] = out[3] = dx / r;
  out[2] = -(out[1] = dy / r);
}


x86 assembly (clang, -O0):
<rotmat_2d_fr_slope>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotmat_2d_fr_slope>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm3
mov    %rdi,%rbx
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     113c <rotmat_2d_fr_slope+0x2c>
sqrtsd %xmm0,%xmm0
jmp    1157 <rotmat_2d_fr_slope+0x47>
movapd %xmm1,0x10(%rsp)
movapd %xmm3,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm3
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm3,%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movupd %xmm1,(%rbx)
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
xorpd  0xe89(%rip),%xmm0
unpcklpd %xmm1,%xmm0
movupd %xmm0,0x10(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @rotmat_2d_fr_slope(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %5
%9 = load double, double* %5
%10 = load double, double* %6
%11 = load double, double* %6
%12 = fmul double %10, %11
%13 = call double @llvm.fmuladd.f64(double %8, double %9, double %12)
%14 = call double @sqrt(double %13)
store double %14, double* %7
%15 = load double, double* %6
%16 = load double, double* %7
%17 = fdiv double %15, %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 3
store double %17, double* %19
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 0
store double %17, double* %21
%22 = load double, double* %5
%23 = load double, double* %7
%24 = fdiv double %22, %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 1
store double %24, double* %26
%27 = fneg double %24
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 2
store double %27, double* %29
ret void
}

LLVM IR (-O2):
define void @rotmat_2d_fr_slope(double* nocapture writeonly %0, double %1, double %2) {
%4 = fmul double %2, %2
%5 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %4)
%6 = tail call double @sqrt(double %5)
%7 = getelementptr inbounds double, double* %0, i64 3
%8 = insertelement <2 x double> poison, double %2, i64 0
%9 = insertelement <2 x double> %8, double %1, i64 1
%10 = insertelement <2 x double> poison, double %6, i64 0
%11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
%12 = fdiv <2 x double> %9, %11
%13 = extractelement <2 x double> %12, i64 0
store double %13, double* %7
%14 = bitcast double* %0 to <2 x double>*
store <2 x double> %12, <2 x double>* %14
%15 = extractelement <2 x double> %12, i64 1
%16 = fneg double %15
%17 = getelementptr inbounds double, double* %0, i64 2
store double %16, double* %17
ret void
}