#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);
scalar_t__ pow(double, int);
double sqrt(scalar_t__);
void drotg(double *da, double *db, double *c, double *s) {
  double roe, scale, r, z;
  roe = *db;
  if (fabs(*da) > fabs(*db))
    roe = *da;
  scale = fabs(*da) + fabs(*db);
  if (scale == 0.0) {
    *c = 1.0;
    *s = 0.0;
    r = 0.0;
  } else {
    r = scale * sqrt(pow(*da / scale, 2) + pow(*db / scale, 2));
    r = ((roe) < 0 ? -fabs(1.0) : fabs(1.0)) * r;
    *c = *da / r;
    *s = *db / r;
  }
  z = *s;
  if (fabs(*c) > 0.0 && fabs(*c) <= *s)
    z = 1.0 / (*c);
  *da = r;
  *db = z;
}


x86 assembly (clang, -O0):
<drotg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xeac(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xe99(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1182 <drotg+0x62>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe6f(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xe5c(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f1 <drotg+0xd1>
jp     11f1 <drotg+0xd1>
mov    -0x18(%rbp),%rax
movsd  0xe3b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12c7 <drotg+0x1a7>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1281 <drotg+0x161>
movsd  0xdb0(%rip),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    128e <drotg+0x16e>
movsd  0xd87(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xd1d(%rip),%xmm1
pand   %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    132e <drotg+0x20e>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xcfd(%rip),%xmm0
pand   %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     132e <drotg+0x20e>
mov    -0x18(%rbp),%rax
movsd  0xceb(%rip),%xmm0
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drotg>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
movsd  (%rsi),%xmm1
movsd  (%rdi),%xmm0
movapd 0xeb7(%rip),%xmm3
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
andpd  %xmm1,%xmm3
movapd %xmm3,%xmm5
addsd  %xmm2,%xmm5
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm5
jne    117f <drotg+0x5f>
jp     117f <drotg+0x5f>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
xorpd  %xmm3,%xmm3
jmp    1218 <drotg+0xf8>
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,0x10(%rsp)
divsd  %xmm5,%xmm0
mov    $0x2,%edi
movapd %xmm5,(%rsp)
call   1030 <pow@plt>
mov    %rax,%rbx
movsd  0x0(%r13),%xmm0
divsd  (%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm3
mulsd  (%rsp),%xmm0
movapd 0xe2d(%rip),%xmm1
xorpd  %xmm0,%xmm1
cmpltsd 0xe38(%rip),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movsd  (%r14),%xmm0
divsd  %xmm3,%xmm0
movsd  %xmm0,(%r15)
movsd  0x0(%r13),%xmm4
divsd  %xmm3,%xmm4
movsd  %xmm4,(%r12)
movsd  (%r15),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
je     125e <drotg+0x13e>
movapd 0xdcb(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xddf(%rip),%xmm2
divsd  %xmm0,%xmm2
cmpnlesd %xmm4,%xmm1
movapd %xmm1,%xmm0
andnpd %xmm2,%xmm0
andpd  %xmm4,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm1,%xmm4
movsd  %xmm3,(%r14)
movsd  %xmm4,0x0(%r13)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @drotg(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = load double, double* %1
%6 = load double, double* %0
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = tail call double @llvm.fabs.f64(double %5)
%9 = fadd double %8, %7
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %4
store double 1.000000e+00, double* %2
br label %30
12: ; preds = %4
%13 = fcmp ogt double %7, %8
%14 = select i1 %13, double %6, double %5
%15 = fdiv double %6, %9
%16 = tail call i64 @pow(double %15, i32 2)
%17 = load double, double* %1
%18 = fdiv double %17, %9
%19 = tail call i64 @pow(double %18, i32 2)
%20 = add nsw i64 %19, %16
%21 = tail call double @sqrt(i64 %20)
%22 = fmul double %9, %21
%23 = fcmp olt double %14, 0.000000e+00
%24 = fneg double %22
%25 = select i1 %23, double %24, double %22
%26 = load double, double* %0
%27 = fdiv double %26, %25
store double %27, double* %2
%28 = load double, double* %1
%29 = fdiv double %28, %25
br label %30
30: ; preds = %12, %11
%31 = phi double [ %29, %12 ], [ 0.000000e+00, %11 ]
%32 = phi double [ %25, %12 ], [ 0.000000e+00, %11 ]
store double %31, double* %3
%33 = load double, double* %2
%34 = fcmp ueq double %33, 0.000000e+00
%35 = tail call double @llvm.fabs.f64(double %33)
%36 = fcmp ugt double %35, %31
%37 = select i1 %34, i1 true, i1 %36
%38 = fdiv double 1.000000e+00, %33
%39 = select i1 %37, double %31, double %38
store double %32, double* %0
store double %39, double* %1
ret void
}