void div1(double x, double *y) {
  if ((!y[0] && !y[1])) {
    short int sign = x / ((x) >= 0 ? (x) : -(x));
    y[0] = x / y[0];
    y[0] = ((y[0]) >= 0 ? (y[0]) : -(y[0])) * sign;
  } else if ((!y[1]))
    y[0] = x / y[0];
  else if ((!y[0]))
    y[1] = -x / y[1];
  else {
    double rsqr = y[0] * y[0] + y[1] * y[1];
    y[0] = x * y[0] / rsqr;
    y[1] = -x * y[1] / rsqr;
  }
}


x86 assembly (clang, -O0):
<div1>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1224 <div1+0x124>
jp     1224 <div1+0x124>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1224 <div1+0x124>
jp     1224 <div1+0x124>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116f <div1+0x6f>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1190 <div1+0x90>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x12(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e2 <div1+0xe2>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1206 <div1+0x106>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movswl -0x12(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    132e <div1+0x22e>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125a <div1+0x15a>
jp     125a <div1+0x15a>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1329 <div1+0x229>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12a8 <div1+0x1a8>
jp     12a8 <div1+0x1a8>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
divsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1324 <div1+0x224>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1329 <div1+0x229>
jmp    132e <div1+0x22e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<div1>:
movupd (%rdi),%xmm1
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
jne    1118 <div1+0x18>
jnp    1151 <div1+0x51>
ucomisd %xmm3,%xmm2
jne    1120 <div1+0x20>
jnp    116b <div1+0x6b>
mulsd  %xmm2,%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd 0xec8(%rip),%xmm2
xorpd  %xmm0,%xmm2
unpcklpd %xmm2,%xmm0
mulpd  %xmm0,%xmm1
unpcklpd %xmm3,%xmm3
divpd  %xmm3,%xmm1
movupd %xmm1,(%rdi)
ret
ucomisd %xmm3,%xmm2
jne    1159 <div1+0x59>
jnp    1174 <div1+0x74>
xorpd  0xe9f(%rip),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rdi)
ret
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi)
ret
movapd 0xe84(%rip),%xmm2
movapd %xmm0,%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
cmplesd %xmm0,%xmm4
movapd %xmm4,%xmm5
andnpd %xmm3,%xmm5
andpd  %xmm0,%xmm4
orpd   %xmm5,%xmm4
movapd %xmm0,%xmm3
divsd  %xmm4,%xmm3
cvttsd2si %xmm3,%eax
xorpd  %xmm3,%xmm3
divsd  %xmm1,%xmm0
xorpd  %xmm0,%xmm2
cmpnlesd %xmm0,%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm0,%xmm3
orpd   %xmm2,%xmm3
cwtl
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,(%rdi)
ret

LLVM IR (-O0):
define void @div1(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i16
%6 = alloca double
store double %0, double* %3
store double* %1, double** %4
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = fcmp une double %9, 0.000000e+00
br i1 %10, label %57, label %11
11: ; preds = %2
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = fcmp une double %14, 0.000000e+00
br i1 %15, label %57, label %16
16: ; preds = %11
%17 = load double, double* %3
%18 = load double, double* %3
%19 = fcmp oge double %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load double, double* %3
br label %25
22: ; preds = %16
%23 = load double, double* %3
%24 = fneg double %23
br label %25
25: ; preds = %22, %20
%26 = phi double [ %21, %20 ], [ %24, %22 ]
%27 = fdiv double %17, %26
%28 = fptosi double %27 to i16
store i16 %28, i16* %5
%29 = load double, double* %3
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = fdiv double %29, %32
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 0
store double %33, double* %35
%36 = load double*, double** %4
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fcmp oge double %38, 0.000000e+00
br i1 %39, label %40, label %44
40: ; preds = %25
%41 = load double*, double** %4
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
br label %49
44: ; preds = %25
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = fneg double %47
br label %49
49: ; preds = %44, %40
%50 = phi double [ %43, %40 ], [ %48, %44 ]
%51 = load i16, i16* %5
%52 = sext i16 %51 to i32
%53 = sitofp i32 %52 to double
%54 = fmul double %50, %53
%55 = load double*, double** %4
%56 = getelementptr inbounds double, double* %55, i64 0
store double %54, double* %56
br label %120
57: ; preds = %11, %2
%58 = load double*, double** %4
%59 = getelementptr inbounds double, double* %58, i64 1
%60 = load double, double* %59
%61 = fcmp une double %60, 0.000000e+00
br i1 %61, label %70, label %62
62: ; preds = %57
%63 = load double, double* %3
%64 = load double*, double** %4
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = fdiv double %63, %66
%68 = load double*, double** %4
%69 = getelementptr inbounds double, double* %68, i64 0
store double %67, double* %69
br label %119
70: ; preds = %57
%71 = load double*, double** %4
%72 = getelementptr inbounds double, double* %71, i64 0
%73 = load double, double* %72
%74 = fcmp une double %73, 0.000000e+00
br i1 %74, label %84, label %75
75: ; preds = %70
%76 = load double, double* %3
%77 = fneg double %76
%78 = load double*, double** %4
%79 = getelementptr inbounds double, double* %78, i64 1
%80 = load double, double* %79
%81 = fdiv double %77, %80
%82 = load double*, double** %4
%83 = getelementptr inbounds double, double* %82, i64 1
store double %81, double* %83
br label %118
84: ; preds = %70
%85 = load double*, double** %4
%86 = getelementptr inbounds double, double* %85, i64 0
%87 = load double, double* %86
%88 = load double*, double** %4
%89 = getelementptr inbounds double, double* %88, i64 0
%90 = load double, double* %89
%91 = load double*, double** %4
%92 = getelementptr inbounds double, double* %91, i64 1
%93 = load double, double* %92
%94 = load double*, double** %4
%95 = getelementptr inbounds double, double* %94, i64 1
%96 = load double, double* %95
%97 = fmul double %93, %96
%98 = call double @llvm.fmuladd.f64(double %87, double %90, double %97)
store double %98, double* %6
%99 = load double, double* %3
%100 = load double*, double** %4
%101 = getelementptr inbounds double, double* %100, i64 0
%102 = load double, double* %101
%103 = fmul double %99, %102
%104 = load double, double* %6
%105 = fdiv double %103, %104
%106 = load double*, double** %4
%107 = getelementptr inbounds double, double* %106, i64 0
store double %105, double* %107
%108 = load double, double* %3
%109 = fneg double %108
%110 = load double*, double** %4
%111 = getelementptr inbounds double, double* %110, i64 1
%112 = load double, double* %111
%113 = fmul double %109, %112
%114 = load double, double* %6
%115 = fdiv double %113, %114
%116 = load double*, double** %4
%117 = getelementptr inbounds double, double* %116, i64 1
store double %115, double* %117
br label %118
118: ; preds = %84, %75
br label %119
119: ; preds = %118, %62
br label %120
120: ; preds = %119, %49
ret void
}

LLVM IR (-O2):
define void @div1(double %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %1, i64 1
%4 = bitcast double* %1 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = extractelement <2 x double> %5, i64 0
%7 = fcmp une double %6, 0.000000e+00
%8 = extractelement <2 x double> %5, i64 1
%9 = fcmp une double %8, 0.000000e+00
br i1 %7, label %23, label %10
10: ; preds = %2
br i1 %9, label %26, label %11
11: ; preds = %10
%12 = fcmp oge double %0, 0.000000e+00
%13 = fneg double %0
%14 = select i1 %12, double %0, double %13
%15 = fdiv double %0, %14
%16 = fptosi double %15 to i16
%17 = fdiv double %0, %6
%18 = fcmp ult double %17, 0.000000e+00
%19 = fneg double %17
%20 = select i1 %18, double %19, double %17
%21 = sitofp i16 %16 to double
%22 = fmul double %20, %21
store double %22, double* %1
br label %40
23: ; preds = %2
br i1 %9, label %29, label %24
24: ; preds = %23
%25 = fdiv double %0, %6
store double %25, double* %1
br label %40
26: ; preds = %10
%27 = fneg double %0
%28 = fdiv double %27, %8
store double %28, double* %3
br label %40
29: ; preds = %23
%30 = fmul double %8, %8
%31 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %30)
%32 = fneg double %0
%33 = insertelement <2 x double> poison, double %0, i64 0
%34 = insertelement <2 x double> %33, double %32, i64 1
%35 = fmul <2 x double> %5, %34
%36 = insertelement <2 x double> poison, double %31, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = fdiv <2 x double> %35, %37
%39 = bitcast double* %1 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
br label %40
40: ; preds = %24, %29, %26, %11
ret void
}