#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 */
long double fabsl(long double);
long double sqrt(long double);
void CNAME(double *DA, double *DB, double *C, double *S) {
  long double da = *DA;
  long double db = *DB;
  long double c;
  long double s;
  long double r, roe, z;
  long double ada = fabsl(da);
  long double adb = fabsl(db);
  long double scale = ada + adb;
  roe = db;
  if (ada > adb)
    roe = da;
  if (scale == 0.0) {
    *C = 1.0;
    *S = 0.0;
    *DA = 0.0;
    *DB = 0.0;
  } else {
    r = sqrt(da * da + db * db);
    if (roe < 0)
      r = -r;
    c = da / r;
    s = db / r;
    z = 1.0;
    if (da != 0.0) {
      if (ada > adb) {
        z = s;
      } else {
        z = 1.0 / c;
      }
    }
    *C = c;
    *S = s;
    *DA = r;
    *DB = z;
  }
}


x86 assembly (clang, -O0):
<CNAME>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
fldl   (%rax)
fstpt  -0x30(%rbp)
mov    -0x10(%rbp),%rax
fldl   (%rax)
fstpt  -0x40(%rbp)
fldt   -0x30(%rbp)
fabs
fstpt  -0xa0(%rbp)
fldt   -0x40(%rbp)
fabs
fstpt  -0xb0(%rbp)
fldt   -0xa0(%rbp)
fldt   -0xb0(%rbp)
faddp  %st,%st(1)
fstpt  -0xc0(%rbp)
fldt   -0x40(%rbp)
fstpt  -0x80(%rbp)
fldt   -0xa0(%rbp)
fldt   -0xb0(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1190 <CNAME+0x80>
jmp    118a <CNAME+0x7a>
fldt   -0x30(%rbp)
fstpt  -0x80(%rbp)
fldt   -0xc0(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11e5 <CNAME+0xd5>
jp     11e5 <CNAME+0xd5>
jmp    11af <CNAME+0x9f>
mov    -0x18(%rbp),%rax
movsd  0xe45(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12ca <CNAME+0x1ba>
fldt   -0x30(%rbp)
fldt   -0x40(%rbp)
fmul   %st,%st(0)
fxch   %st(1)
fmul   %st,%st(0)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sqrt@plt>
fstpt  -0x70(%rbp)
fldt   -0x80(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    121c <CNAME+0x10c>
jmp    1214 <CNAME+0x104>
fldt   -0x70(%rbp)
fchs
fstpt  -0x70(%rbp)
fldt   -0x30(%rbp)
fldt   -0x70(%rbp)
fdivrp %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x40(%rbp)
fldt   -0x70(%rbp)
fdivrp %st,%st(1)
fstpt  -0x60(%rbp)
fld1
fstpt  -0x90(%rbp)
fldt   -0x30(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1256 <CNAME+0x146>
jp     1256 <CNAME+0x146>
jmp    1293 <CNAME+0x183>
fldt   -0xa0(%rbp)
fldt   -0xb0(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1281 <CNAME+0x171>
jmp    1273 <CNAME+0x163>
fldt   -0x60(%rbp)
fstpt  -0x90(%rbp)
jmp    128e <CNAME+0x17e>
fldt   -0x50(%rbp)
fld1
fdivp  %st,%st(1)
fstpt  -0x90(%rbp)
jmp    1293 <CNAME+0x183>
fldt   -0x50(%rbp)
mov    -0x18(%rbp),%rax
fstpl  (%rax)
fldt   -0x60(%rbp)
mov    -0x20(%rbp),%rax
fstpl  (%rax)
fldt   -0x70(%rbp)
mov    -0x8(%rbp),%rax
fstpl  (%rax)
fldt   -0x90(%rbp)
fstpl  -0xc8(%rbp)
movsd  -0xc8(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CNAME>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  %xmm1,0x28(%rsp)
fldl   0x28(%rsp)
fldl   (%rsi)
fld    %st(1)
fabs
fld    %st(1)
fabs
fld    %st(1)
fadd   %st(1),%st
fldz
fxch   %st(1)
fucomip %st(1),%st
jne    117b <CNAME+0x6b>
jp     117b <CNAME+0x6b>
fstp   %st(3)
fstp   %st(2)
fstp   %st(2)
fstp   %st(1)
fstp   %st(0)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r12)
movq   $0x0,(%r14)
movq   $0x0,(%rbx)
xorps  %xmm0,%xmm0
jmp    124e <CNAME+0x13e>
fxch   %st(2)
fucomi %st(1),%st
fld    %st(3)
fcmovnbe %st(5),%st
fstpt  0x6c(%rsp)
fld    %st(3)
fmul   %st(4),%st
fld    %st(5)
fmul   %st(6),%st
faddp  %st,%st(1)
fld    %st(0)
fsqrt
fxch   %st(1)
fucomi %st(4),%st
jae    11ed <CNAME+0xdd>
fstp   %st(1)
fstpt  (%rsp)
movsd  %xmm1,0x18(%rsp)
fxch   %st(4)
fstpt  0x60(%rsp)
fxch   %st(3)
fstpt  0x54(%rsp)
fxch   %st(2)
fstpt  0x48(%rsp)
fstpt  0x3c(%rsp)
fstpt  0x30(%rsp)
call   1030 <sqrt@plt>
fldt   0x30(%rsp)
fldt   0x3c(%rsp)
fldt   0x48(%rsp)
fldt   0x54(%rsp)
fldt   0x60(%rsp)
movsd  0x18(%rsp),%xmm1
fldz
fxch   %st(1)
fxch   %st(6)
fxch   %st(4)
fxch   %st(5)
fxch   %st(4)
fxch   %st(1)
fstp   %st(0)
fldt   0x6c(%rsp)
fxch   %st(4)
fucomip %st(4),%st
fstp   %st(3)
fld    %st(2)
fchs
fxch   %st(3)
fcmovnbe %st(3),%st
fstp   %st(3)
fxch   %st(3)
fdiv   %st(2),%st
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
fld1
fld    %st(0)
fcmovne %st(2),%st
fxch   %st(6)
fdiv   %st(4),%st
fdivr  %st,%st(1)
fxch   %st(6)
fcmovu %st(2),%st
fxch   %st(5)
fucomip %st(3),%st
fstp   %st(2)
fxch   %st(1)
fcmovnbe %st(3),%st
ucomisd %xmm0,%xmm1
fxch   %st(3)
fcmovne %st(3),%st
fcmovu %st(3),%st
fstp   %st(3)
fxch   %st(3)
fstpl  (%r12)
fxch   %st(2)
fstpl  (%r14)
fxch   %st(1)
fstpl  (%rbx)
fstpl  0x20(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15)
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @CNAME(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca x86_fp80
%10 = alloca x86_fp80
%11 = alloca x86_fp80
%12 = alloca x86_fp80
%13 = alloca x86_fp80
%14 = alloca x86_fp80
%15 = alloca x86_fp80
%16 = alloca x86_fp80
%17 = alloca x86_fp80
%18 = alloca x86_fp80
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%19 = load double*, double** %5
%20 = load double, double* %19
%21 = fpext double %20 to x86_fp80
store x86_fp80 %21, x86_fp80* %9
%22 = load double*, double** %6
%23 = load double, double* %22
%24 = fpext double %23 to x86_fp80
store x86_fp80 %24, x86_fp80* %10
%25 = load x86_fp80, x86_fp80* %9
%26 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %25)
store x86_fp80 %26, x86_fp80* %16
%27 = load x86_fp80, x86_fp80* %10
%28 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %27)
store x86_fp80 %28, x86_fp80* %17
%29 = load x86_fp80, x86_fp80* %16
%30 = load x86_fp80, x86_fp80* %17
%31 = fadd x86_fp80 %29, %30
store x86_fp80 %31, x86_fp80* %18
%32 = load x86_fp80, x86_fp80* %10
store x86_fp80 %32, x86_fp80* %14
%33 = load x86_fp80, x86_fp80* %16
%34 = load x86_fp80, x86_fp80* %17
%35 = fcmp ogt x86_fp80 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %4
%37 = load x86_fp80, x86_fp80* %9
store x86_fp80 %37, x86_fp80* %14
br label %38
38: ; preds = %36, %4
%39 = load x86_fp80, x86_fp80* %18
%40 = fcmp oeq x86_fp80 %39, 0xK00000000000000000000
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load double*, double** %7
store double 1.000000e+00, double* %42
%43 = load double*, double** %8
store double 0.000000e+00, double* %43
%44 = load double*, double** %5
store double 0.000000e+00, double* %44
%45 = load double*, double** %6
store double 0.000000e+00, double* %45
br label %91
46: ; preds = %38
%47 = load x86_fp80, x86_fp80* %9
%48 = load x86_fp80, x86_fp80* %9
%49 = load x86_fp80, x86_fp80* %10
%50 = load x86_fp80, x86_fp80* %10
%51 = fmul x86_fp80 %49, %50
%52 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %47, x86_fp80 %48, x86_fp80 %51)
%53 = call x86_fp80 @sqrt(x86_fp80 %52)
store x86_fp80 %53, x86_fp80* %13
%54 = load x86_fp80, x86_fp80* %14
%55 = fcmp olt x86_fp80 %54, 0xK00000000000000000000
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = load x86_fp80, x86_fp80* %13
%58 = fneg x86_fp80 %57
store x86_fp80 %58, x86_fp80* %13
br label %59
59: ; preds = %56, %46
%60 = load x86_fp80, x86_fp80* %9
%61 = load x86_fp80, x86_fp80* %13
%62 = fdiv x86_fp80 %60, %61
store x86_fp80 %62, x86_fp80* %11
%63 = load x86_fp80, x86_fp80* %10
%64 = load x86_fp80, x86_fp80* %13
%65 = fdiv x86_fp80 %63, %64
store x86_fp80 %65, x86_fp80* %12
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %15
%66 = load x86_fp80, x86_fp80* %9
%67 = fcmp une x86_fp80 %66, 0xK00000000000000000000
br i1 %67, label %68, label %78
68: ; preds = %59
%69 = load x86_fp80, x86_fp80* %16
%70 = load x86_fp80, x86_fp80* %17
%71 = fcmp ogt x86_fp80 %69, %70
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = load x86_fp80, x86_fp80* %12
store x86_fp80 %73, x86_fp80* %15
br label %77
74: ; preds = %68
%75 = load x86_fp80, x86_fp80* %11
%76 = fdiv x86_fp80 0xK3FFF8000000000000000, %75
store x86_fp80 %76, x86_fp80* %15
br label %77
77: ; preds = %74, %72
br label %78
78: ; preds = %77, %59
%79 = load x86_fp80, x86_fp80* %11
%80 = fptrunc x86_fp80 %79 to double
%81 = load double*, double** %7
store double %80, double* %81
%82 = load x86_fp80, x86_fp80* %12
%83 = fptrunc x86_fp80 %82 to double
%84 = load double*, double** %8
store double %83, double* %84
%85 = load x86_fp80, x86_fp80* %13
%86 = fptrunc x86_fp80 %85 to double
%87 = load double*, double** %5
store double %86, double* %87
%88 = load x86_fp80, x86_fp80* %15
%89 = fptrunc x86_fp80 %88 to double
%90 = load double*, double** %6
store double %89, double* %90
br label %91
91: ; preds = %78, %41
ret void
}

LLVM IR (-O2):
define void @CNAME(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = load double, double* %0
%6 = fpext double %5 to x86_fp80
%7 = load double, double* %1
%8 = fpext double %7 to x86_fp80
%9 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %6)
%10 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %8)
%11 = fadd x86_fp80 %9, %10
%12 = fcmp ogt x86_fp80 %9, %10
%13 = fcmp oeq x86_fp80 %11, 0xK00000000000000000000
br i1 %13, label %14, label %15
14: ; preds = %4
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %0
br label %34
15: ; preds = %4
%16 = select i1 %12, x86_fp80 %6, x86_fp80 %8
%17 = fmul x86_fp80 %8, %8
%18 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %6, x86_fp80 %6, x86_fp80 %17)
%19 = tail call x86_fp80 @sqrt(x86_fp80 %18)
%20 = fcmp olt x86_fp80 %16, 0xK00000000000000000000
%21 = fneg x86_fp80 %19
%22 = select i1 %20, x86_fp80 %21, x86_fp80 %19
%23 = fdiv x86_fp80 %6, %22
%24 = fdiv x86_fp80 %8, %22
%25 = fcmp oeq double %5, 0.000000e+00
%26 = select i1 %25, i1 true, i1 %12
%27 = select i1 %25, x86_fp80 0xK3FFF8000000000000000, x86_fp80 %24
%28 = fdiv x86_fp80 0xK3FFF8000000000000000, %23
%29 = select i1 %26, x86_fp80 %27, x86_fp80 %28
%30 = fptrunc x86_fp80 %23 to double
store double %30, double* %2
%31 = fptrunc x86_fp80 %24 to double
store double %31, double* %3
%32 = fptrunc x86_fp80 %22 to double
store double %32, double* %0
%33 = fptrunc x86_fp80 %29 to double
br label %34
34: ; preds = %15, %14
%35 = phi double [ %33, %15 ], [ 0.000000e+00, %14 ]
store double %35, double* %1
ret void
}