#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 const);
double sqrt(int);
void create_givens(const double a, const double b, double *c, double *s) {
  if (b == 0) {
    *c = 1;
    *s = 0;
  } else if (fabs(b) > fabs(a)) {
    double t = -a / b;
    double s1 = 1.0 / sqrt(1 + t * t);
    *s = s1;
    *c = s1 * t;
  } else {
    double t = -b / a;
    double c1 = 1.0 / sqrt(1 + t * t);
    *c = c1;
    *s = c1 * t;
  }
}


x86 assembly (clang, -O0):
<create_givens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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 <create_givens+0x52>
jp     1172 <create_givens+0x52>
mov    -0x18(%rbp),%rax
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    129c <create_givens+0x17c>
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jle    121b <create_givens+0xfb>
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
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe12(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1297 <create_givens+0x177>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda9(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd91(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    129c <create_givens+0x17c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_givens>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1158 <create_givens+0x38>
jp     1158 <create_givens+0x38>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
movq   $0x0,(%r14)
jmp    1211 <create_givens+0xf1>
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    11c7 <create_givens+0xa7>
movapd (%rsp),%xmm0
xorpd  0xe76(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
addsd  0xe6f(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  0xe5e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
mulsd  (%rsp),%xmm1
movsd  %xmm1,(%r15)
jmp    1211 <create_givens+0xf1>
movapd 0x10(%rsp),%xmm0
xorpd  0xe2b(%rip),%xmm0
divsd  (%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
mulsd  %xmm0,%xmm0
addsd  0xe24(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  0xe13(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @create_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 %27
7: ; preds = %4
%8 = tail call i64 @fabs(double %1)
%9 = tail call i64 @fabs(double %0)
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %19
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 = fptosi double %14 to i32
%16 = tail call double @sqrt(i32 %15)
%17 = fdiv double 1.000000e+00, %16
store double %17, double* %3
%18 = fmul double %13, %17
store double %18, double* %2
br label %27
19: ; preds = %7
%20 = fneg double %1
%21 = fdiv double %20, %0
%22 = tail call double @llvm.fmuladd.f64(double %21, double %21, double 1.000000e+00)
%23 = fptosi double %22 to i32
%24 = tail call double @sqrt(i32 %23)
%25 = fdiv double 1.000000e+00, %24
store double %25, double* %2
%26 = fmul double %21, %25
store double %26, double* %3
br label %27
27: ; preds = %11, %19, %6
ret void
}