#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(int);
void GivensCalc(double v_1, double v_2, double *c, double *s, double *r) {
  double w, q;
  if (fabs(v_1) > fabs(v_2)) {
    w = v_2 / v_1;
    q = sqrt(1 + w * w);
    *c = 1 / q;
    if (v_1 < 0)
      *c = -(*c);
    *s = w * (*c);
    *r = fabs(v_1) * q;
  } else {
    if (v_2 == 0) {
      *c = 1;
      *s = 0;
      *r = 0;
    } else {
      w = v_1 / v_2;
      q = sqrt(1 + w * w);
      *s = 1 / q;
      if (v_2 < 0)
        *s = -(*s);
      *c = w * (*s);
      *r = fabs(v_2) * q;
    }
  }
}


x86 assembly (clang, -O0):
<GivensCalc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xec6(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xeb6(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1210 <GivensCalc+0x100>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe93(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe79(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11d9 <GivensCalc+0xc9>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movaps 0xe06(%rip),%xmm1
pand   %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    130b <GivensCalc+0x1fb>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1253 <GivensCalc+0x143>
jp     1253 <GivensCalc+0x143>
mov    -0x18(%rbp),%rax
movsd  0xddc(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1306 <GivensCalc+0x1f6>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd98(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xd7e(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12d4 <GivensCalc+0x1c4>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movaps 0xd0b(%rip),%xmm1
pand   %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    130b <GivensCalc+0x1fb>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GivensCalc>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movapd 0xed6(%rip),%xmm3
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
andpd  %xmm1,%xmm3
ucomisd %xmm3,%xmm2
jbe    11d4 <GivensCalc+0xc4>
divsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movapd %xmm2,(%rsp)
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xec1(%rip),%xmm1
addsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm0,0x10(%rsp)
call   1030 <sqrt@plt>
movsd  0xea6(%rip),%xmm2
divsd  %xmm0,%xmm2
movapd 0xe8a(%rip),%xmm1
xorpd  %xmm2,%xmm1
movapd %xmm2,%xmm4
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm4,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movlpd %xmm3,(%rbx)
mulsd  0x20(%rsp),%xmm3
movsd  %xmm3,(%r15)
movapd (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movapd (%rsp),%xmm2
jmp    127e <GivensCalc+0x16e>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    11f9 <GivensCalc+0xe9>
jp     11f9 <GivensCalc+0xe9>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rbx)
movq   $0x0,(%r15)
jmp    127e <GivensCalc+0x16e>
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe0d(%rip),%xmm0
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm1,0x20(%rsp)
movapd %xmm3,(%rsp)
call   1030 <sqrt@plt>
movsd  0xded(%rip),%xmm2
divsd  %xmm0,%xmm2
movapd 0xdd1(%rip),%xmm1
xorpd  %xmm2,%xmm1
movapd %xmm2,%xmm4
movapd 0x20(%rsp),%xmm3
cmpltsd 0xdd2(%rip),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm4,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movlpd %xmm3,(%r15)
mulsd  0x10(%rsp),%xmm3
movsd  %xmm3,(%rbx)
movapd (%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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