#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(double);
void givens(double a, double b, double *c, double *s) {
  double t;
  if (b == 0.0)
    (*c) = 1.0, (*s) = 0.0;
  else if (fabs(a) <= fabs(b))
    t = -a / b, (*s) = 1.0 / sqrt(1.0 + t * t), (*c) = (*s) * t;
  else
    t = -b / a, (*c) = 1.0 / sqrt(1.0 + t * t), (*s) = (*c) * t;
  return;
}


x86 assembly (clang, -O0):
<givens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <givens+0x52>
jp     1172 <givens+0x52>
mov    -0x18(%rbp),%rax
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1286 <givens+0x166>
movsd  -0x8(%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
jg     1210 <givens+0xf0>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2a(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe16(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1281 <givens+0x161>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb4(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xda0(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1286 <givens+0x166>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<givens>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    1154 <givens+0x34>
jp     1154 <givens+0x34>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
movq   $0x0,(%r14)
jmp    1230 <givens+0x110>
movapd %xmm1,(%rsp)
movaps %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jle    11a7 <givens+0x87>
movapd (%rsp),%xmm2
xorpd  0xe7f(%rip),%xmm2
divsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe79(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11da <givens+0xba>
sqrtsd %xmm0,%xmm0
jmp    11e9 <givens+0xc9>
movapd 0x10(%rsp),%xmm2
xorpd  0xe4b(%rip),%xmm2
divsd  (%rsp),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe46(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1205 <givens+0xe5>
sqrtsd %xmm0,%xmm0
jmp    1216 <givens+0xf6>
movapd %xmm2,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm2
movsd  0xe1f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
mulsd  %xmm1,%xmm2
movsd  %xmm2,(%r14)
jmp    1230 <givens+0x110>
movapd %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movsd  0xdf2(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
mulsd  %xmm1,%xmm2
movsd  %xmm2,(%r15)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @givens(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = fcmp oeq double %1, 0.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %4
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %3
br label %25
7: ; preds = %4
%8 = tail call i64 @fabs(double %0)
%9 = tail call i64 @fabs(double %1)
%10 = icmp sgt i64 %8, %9
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = fneg double %0
%13 = fdiv double %12, %1
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double 1.000000e+00)
%15 = tail call double @sqrt(double %14)
%16 = fdiv double 1.000000e+00, %15
store double %16, double* %3
%17 = fmul double %13, %16
store double %17, double* %2
br label %25
18: ; preds = %7
%19 = fneg double %1
%20 = fdiv double %19, %0
%21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double 1.000000e+00)
%22 = tail call double @sqrt(double %21)
%23 = fdiv double 1.000000e+00, %22
store double %23, double* %2
%24 = fmul double %20, %23
store double %24, double* %3
br label %25
25: ; preds = %11, %18, %6
ret void
}