#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 */
scalar_t__ fabs(double);
double sqrt(int);
void givensRotation_double(double *csVect, double a, double b) {
  double tau;
  double tmpVal;
  if (b == 0.0) {
    csVect[0] = 1.0;
    csVect[1] = 0.0;
  } else {
    if (fabs(b) > fabs(a)) {
      tau = (-a) / b;
      tmpVal = sqrt(1 + (tau * tau));
      csVect[1] = 1 / tmpVal;
      csVect[0] = tau / tmpVal;
    } else {
      tau = (-b) / a;
      tmpVal = sqrt(1 + (tau * tau));
      csVect[0] = 1 / tmpVal;
      csVect[1] = tau / tmpVal;
    }
  }
}


x86 assembly (clang, -O0):
<givensRotation_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116f <givensRotation_double+0x4f>
jp     116f <givensRotation_double+0x4f>
mov    -0x8(%rbp),%rax
movsd  0xea6(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
jmp    128d <givensRotation_double+0x16d>
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jle    1212 <givensRotation_double+0xf2>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe13(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1288 <givensRotation_double+0x168>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xd98(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    128d <givensRotation_double+0x16d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<givensRotation_double>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movapd %xmm0,%xmm2
mov    %rdi,%r14
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    114c <givensRotation_double+0x2c>
jp     114c <givensRotation_double+0x2c>
movsd  0xeee(%rip),%xmm0
movupd %xmm0,(%r14)
jmp    11f7 <givensRotation_double+0xd7>
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
movapd %xmm2,(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jle    11ae <givensRotation_double+0x8e>
movapd (%rsp),%xmm0
xorpd  0xe82(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
addsd  0xe9b(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd (%rsp),%xmm1
shufpd $0x2,0xe74(%rip),%xmm1
jmp    11ea <givensRotation_double+0xca>
movapd 0x10(%rsp),%xmm0
xorpd  0xe44(%rip),%xmm0
divsd  (%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
mulsd  %xmm0,%xmm0
addsd  0xe5d(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd 0xe2c(%rip),%xmm1
unpcklpd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movupd %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @givensRotation_double(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 0
store double 1.000000e+00, double* %13
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
store double 0.000000e+00, double* %15
br label %61
16: ; preds = %3
%17 = load double, double* %6
%18 = call i64 @fabs(double %17)
%19 = load double, double* %5
%20 = call i64 @fabs(double %19)
%21 = icmp sgt i64 %18, %20
br i1 %21, label %22, label %41
22: ; preds = %16
%23 = load double, double* %5
%24 = fneg double %23
%25 = load double, double* %6
%26 = fdiv double %24, %25
store double %26, double* %7
%27 = load double, double* %7
%28 = load double, double* %7
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 1.000000e+00)
%30 = fptosi double %29 to i32
%31 = call double @sqrt(i32 %30)
store double %31, double* %8
%32 = load double, double* %8
%33 = fdiv double 1.000000e+00, %32
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 1
store double %33, double* %35
%36 = load double, double* %7
%37 = load double, double* %8
%38 = fdiv double %36, %37
%39 = load double*, double** %4
%40 = getelementptr inbounds double, double* %39, i64 0
store double %38, double* %40
br label %60
41: ; preds = %16
%42 = load double, double* %6
%43 = fneg double %42
%44 = load double, double* %5
%45 = fdiv double %43, %44
store double %45, double* %7
%46 = load double, double* %7
%47 = load double, double* %7
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double 1.000000e+00)
%49 = fptosi double %48 to i32
%50 = call double @sqrt(i32 %49)
store double %50, double* %8
%51 = load double, double* %8
%52 = fdiv double 1.000000e+00, %51
%53 = load double*, double** %4
%54 = getelementptr inbounds double, double* %53, i64 0
store double %52, double* %54
%55 = load double, double* %7
%56 = load double, double* %8
%57 = fdiv double %55, %56
%58 = load double*, double** %4
%59 = getelementptr inbounds double, double* %58, i64 1
store double %57, double* %59
br label %60
60: ; preds = %41, %22
br label %61
61: ; preds = %60, %11
ret void
}

LLVM IR (-O2):
define void @givensRotation_double(double* nocapture writeonly %0, double %1, double %2) {
%4 = fcmp oeq double %2, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = bitcast double* %0 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 0.000000e+00>, <2 x double>* %6
br label %33
7: ; preds = %3
%8 = tail call i64 @fabs(double %2)
%9 = tail call i64 @fabs(double %1)
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = fneg double %1
%13 = fdiv double %12, %2
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double 1.000000e+00)
%15 = fptosi double %14 to i32
%16 = tail call double @sqrt(i32 %15)
%17 = insertelement <2 x double> <double poison, double 1.000000e+00>, double %13, i64 0
%18 = insertelement <2 x double> poison, double %16, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = fdiv <2 x double> %17, %19
%21 = bitcast double* %0 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
br label %33
22: ; preds = %7
%23 = fneg double %2
%24 = fdiv double %23, %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 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %24, i64 1
%29 = insertelement <2 x double> poison, double %27, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = fdiv <2 x double> %28, %30
%32 = bitcast double* %0 to <2 x double>*
store <2 x double> %31, <2 x double>* %32
br label %33
33: ; preds = %11, %22, %5
ret void
}