#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 fabs(double);
double sqrt(double);
void sss(double *fg, double *cs) {
  double r, d;
  if ((fabs(fg[0]) + fabs(fg[1])) == 0.0) {
    cs[0] = 1.0;
    cs[1] = 0.0;
    d = 0.0;
  } else {
    d = sqrt(fg[0] * fg[0] + fg[1] * fg[1]);
    if (fabs(fg[0]) > fabs(fg[1])) {
      d = fabs(d);
      if (fg[0] < 0.0)
        d = -d;
    }
    if (fabs(fg[1]) >= fabs(fg[0])) {
      d = fabs(d);
      if (fg[1] < 0.0)
        d = -d;
    }
    cs[0] = fg[0] / d;
    cs[1] = fg[1] / d;
  }
  r = 1.0;
  if (fabs(fg[0]) > fabs(fg[1]))
    r = cs[1];
  else if (cs[0] != 0.0)
    r = 1.0 / cs[0];
  fg[0] = d;
  fg[1] = r;
}


x86 assembly (clang, -O0):
<sss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xed1(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
movaps 0xebd(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1187 <sss+0x77>
jp     1187 <sss+0x77>
mov    -0x10(%rbp),%rax
movsd  0xea6(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12e2 <sss+0x1d2>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe36(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
movaps 0xe22(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1238 <sss+0x128>
movsd  -0x20(%rbp),%xmm0
movaps 0xe08(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1233 <sss+0x123>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1238 <sss+0x128>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xdb8(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xda5(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     12b6 <sss+0x1a6>
movsd  -0x20(%rbp),%xmm0
movaps 0xd8b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jbe    12b1 <sss+0x1a1>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12b6 <sss+0x1a6>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  0xd26(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xd02(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
movaps 0xcee(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1333 <sss+0x223>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    136d <sss+0x25d>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1353 <sss+0x243>
jp     1353 <sss+0x243>
jmp    1368 <sss+0x258>
mov    -0x10(%rbp),%rax
movsd  0xcb1(%rip),%xmm0
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    136d <sss+0x25d>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sss>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movdqu (%rdi),%xmm0
movdqa 0xeda(%rip),%xmm1
pand   %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm3
addsd  %xmm1,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm3
jne    115d <sss+0x4d>
jp     115d <sss+0x4d>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r14)
movsd  0xecc(%rip),%xmm1
xorpd  %xmm0,%xmm0
jmp    11f1 <sss+0xe1>
movdqa %xmm0,%xmm1
mulpd  %xmm0,%xmm1
unpckhpd %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     117d <sss+0x6d>
sqrtsd %xmm0,%xmm0
jmp    1182 <sss+0x72>
call   1030 <sqrt@plt>
movdqu (%rbx),%xmm1
movdqa 0xe72(%rip),%xmm2
pand   %xmm1,%xmm2
pshufd $0xee,%xmm2,%xmm3
ucomisd %xmm3,%xmm2
jbe    11b7 <sss+0xa7>
andpd  0xe5b(%rip),%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm1,%xmm4
jbe    11b7 <sss+0xa7>
xorpd  0xe59(%rip),%xmm0
ucomisd %xmm2,%xmm3
jb     11df <sss+0xcf>
andpd  0xe3b(%rip),%xmm0
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jbe    11df <sss+0xcf>
xorpd  0xe31(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r14)
movdqu (%rbx),%xmm3
pand   0xdfd(%rip),%xmm3
pshufd $0xee,%xmm3,%xmm4
ucomisd %xmm4,%xmm3
ja     1230 <sss+0x120>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    121a <sss+0x10a>
jnp    1228 <sss+0x118>
movsd  0xdfe(%rip),%xmm2
divsd  %xmm1,%xmm2
jmp    1230 <sss+0x120>
movsd  0xdf0(%rip),%xmm2
movsd  %xmm0,(%rbx)
movsd  %xmm2,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @sss(double* nocapture %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = bitcast double* %0 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %5)
%7 = shufflevector <2 x double> %6, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%8 = fadd <2 x double> %6, %7
%9 = extractelement <2 x double> %8, i64 0
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %2
store double 1.000000e+00, double* %1
br label %45
12: ; preds = %2
%13 = fmul <2 x double> %5, %5
%14 = extractelement <2 x double> %13, i64 1
%15 = extractelement <2 x double> %5, i64 0
%16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %14)
%17 = tail call double @sqrt(double %16)
%18 = bitcast double* %0 to <2 x double>*
%19 = load <2 x double>, <2 x double>* %18
%20 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %19)
%21 = extractelement <2 x double> %20, i64 0
%22 = extractelement <2 x double> %20, i64 1
%23 = fcmp ogt double %21, %22
br i1 %23, label %24, label %30
24: ; preds = %12
%25 = tail call double @llvm.fabs.f64(double %17)
%26 = extractelement <2 x double> %19, i64 0
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = fneg double %25
br label %30
30: ; preds = %24, %28, %12
%31 = phi double [ %29, %28 ], [ %25, %24 ], [ %17, %12 ]
%32 = fcmp ult double %22, %21
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = tail call double @llvm.fabs.f64(double %31)
%35 = extractelement <2 x double> %19, i64 1
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = fneg double %34
br label %39
39: ; preds = %33, %37, %30
%40 = phi double [ %38, %37 ], [ %34, %33 ], [ %31, %30 ]
%41 = extractelement <2 x double> %19, i64 0
%42 = fdiv double %41, %40
store double %42, double* %1
%43 = load double, double* %3
%44 = fdiv double %43, %40
br label %45
45: ; preds = %39, %11
%46 = phi double [ %44, %39 ], [ 0.000000e+00, %11 ]
%47 = phi double [ %42, %39 ], [ 1.000000e+00, %11 ]
%48 = phi double [ %40, %39 ], [ 0.000000e+00, %11 ]
%49 = getelementptr inbounds double, double* %1, i64 1
store double %46, double* %49
%50 = bitcast double* %0 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %51)
%53 = extractelement <2 x double> %52, i64 0
%54 = extractelement <2 x double> %52, i64 1
%55 = fcmp ogt double %53, %54
br i1 %55, label %60, label %56
56: ; preds = %45
%57 = fcmp une double %47, 0.000000e+00
br i1 %57, label %58, label %60
58: ; preds = %56
%59 = fdiv double 1.000000e+00, %47
br label %60
60: ; preds = %45, %56, %58
%61 = phi double [ %59, %58 ], [ 1.000000e+00, %56 ], [ %46, %45 ]
store double %48, double* %0
store double %61, double* %3
ret void
}