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


x86 assembly (clang, -O0):
<create_givens_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1171 <create_givens_float+0x51>
jp     1171 <create_givens_float+0x51>
mov    -0x10(%rbp),%rax
movss  0xeab(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    128f <create_givens_float+0x16f>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x30(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jle    1214 <create_givens_float+0xf4>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe3d(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x20(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    128a <create_givens_float+0x16a>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
divss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdc2(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xda2(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    128f <create_givens_float+0x16f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_givens_float>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    114f <create_givens_float+0x2f>
jp     114f <create_givens_float+0x2f>
movl   $0x3f800000,(%r15)
movl   $0x0,(%r14)
jmp    1213 <create_givens_float+0xf3>
movaps %xmm1,0x10(%rsp)
movaps %xmm1,%xmm0
movaps %xmm2,(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jle    11c2 <create_givens_float+0xa2>
movaps (%rsp),%xmm0
xorps  0xe84(%rip),%xmm0
divss  0x10(%rsp),%xmm0
movaps %xmm0,(%rsp)
mulss  %xmm0,%xmm0
addss  0xe7e(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  0xe75(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r14)
movaps (%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r15)
jmp    1213 <create_givens_float+0xf3>
movaps 0x10(%rsp),%xmm0
xorps  0xe32(%rip),%xmm0
divss  (%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
mulss  %xmm0,%xmm0
addss  0xe2c(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  0xe23(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15)
movaps 0x10(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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