#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 */
float copysignf(float, float);
float fabsf(float);
float sqrtf(float);
void sp_blas_srotg(float *const a, float *const b, float *const c,
                   float *const s) {
  float scale = fabsf(*a) + fabsf(*b);
  if (scale == 0.0f) {
    *c = 1.0f;
    *s = 0.0f;
    *a = 0.0f;
    *b = 0.0f;
  } else {
    float abs_a = fabsf(*a);
    float abs_b = fabsf(*b);
    float a_scale = *a / scale;
    float b_scale = *b / scale;
    float r = scale * sqrtf(a_scale * a_scale + b_scale * b_scale);
    r = copysignf(r, abs_a > abs_b ? *a : *b);
    *c = *a / r;
    *s = *b / r;
    if (abs_a > abs_b) {
      *b = *s;
    } else if (abs_a >= abs_b && *c != 0.0f) {
      *b = 1.0f / *c;
    } else {
      *b = 1.0f;
    }
    *a = r;
  }
}


x86 assembly (clang, -O0):
<sp_blas_srotg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movaps 0xec9(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
movaps 0xeb6(%rip),%xmm2
pand   %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11a4 <sp_blas_srotg+0x94>
jp     11a4 <sp_blas_srotg+0x94>
mov    -0x18(%rbp),%rax
movss  0xea6(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1350 <sp_blas_srotg+0x240>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movaps 0xe4d(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movaps 0xe35(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    125f <sp_blas_srotg+0x14f>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x44(%rbp)
jmp    126c <sp_blas_srotg+0x15c>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
movaps 0xd93(%rip),%xmm2
pand   %xmm2,%xmm1
movaps 0xd78(%rip),%xmm2
pand   %xmm2,%xmm0
por    %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    12e3 <sp_blas_srotg+0x1d3>
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1343 <sp_blas_srotg+0x233>
movss  -0x28(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jb     132e <sp_blas_srotg+0x21e>
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1311 <sp_blas_srotg+0x201>
jp     1311 <sp_blas_srotg+0x201>
jmp    132e <sp_blas_srotg+0x21e>
mov    -0x18(%rbp),%rax
movss  0xd03(%rip),%xmm0
divss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    133e <sp_blas_srotg+0x22e>
mov    -0x10(%rbp),%rax
movss  0xce6(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    1343 <sp_blas_srotg+0x233>
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sp_blas_srotg>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movaps 0xece(%rip),%xmm3
movaps %xmm0,%xmm4
andps  %xmm3,%xmm4
movss  (%rsi),%xmm1
andps  %xmm1,%xmm3
movaps %xmm4,%xmm5
addss  %xmm3,%xmm5
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm5
jne    1171 <sp_blas_srotg+0x61>
jp     1171 <sp_blas_srotg+0x61>
movl   $0x3f800000,(%r15)
movl   $0x0,(%r12)
movl   $0x0,(%rbx)
movl   $0x0,(%r14)
jmp    1223 <sp_blas_srotg+0x113>
divss  %xmm5,%xmm0
divss  %xmm5,%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
jb     1190 <sp_blas_srotg+0x80>
sqrtss %xmm0,%xmm0
jmp    11b1 <sp_blas_srotg+0xa1>
movaps %xmm3,0x20(%rsp)
movaps %xmm4,0x10(%rsp)
movaps %xmm5,(%rsp)
call   1030 <sqrtf@plt>
movaps (%rsp),%xmm5
movaps 0x10(%rsp),%xmm4
movaps 0x20(%rsp),%xmm3
ucomiss %xmm3,%xmm4
mov    %r14,%rax
cmova  %rbx,%rax
mulss  %xmm0,%xmm5
andps  0xe3a(%rip),%xmm5
movss  (%rax),%xmm0
andps  0xe3f(%rip),%xmm0
orps   %xmm5,%xmm0
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r15)
movss  (%r14),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r12)
ja     121a <sp_blas_srotg+0x10a>
movss  0xe26(%rip),%xmm1
ucomiss %xmm3,%xmm4
jb     121a <sp_blas_srotg+0x10a>
movss  (%r15),%xmm2
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm2
jne    120e <sp_blas_srotg+0xfe>
jnp    121a <sp_blas_srotg+0x10a>
movss  0xe0a(%rip),%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,(%r14)
movss  %xmm0,(%rbx)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sp_blas_srotg(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
%13 = alloca float
%14 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%15 = load float*, float** %5
%16 = load float, float* %15
%17 = call float @llvm.fabs.f32(float %16)
%18 = load float*, float** %6
%19 = load float, float* %18
%20 = call float @llvm.fabs.f32(float %19)
%21 = fadd float %17, %20
store float %21, float* %9
%22 = load float, float* %9
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %29
24: ; preds = %4
%25 = load float*, float** %7
store float 1.000000e+00, float* %25
%26 = load float*, float** %8
store float 0.000000e+00, float* %26
%27 = load float*, float** %5
store float 0.000000e+00, float* %27
%28 = load float*, float** %6
store float 0.000000e+00, float* %28
br label %102
29: ; preds = %4
%30 = load float*, float** %5
%31 = load float, float* %30
%32 = call float @llvm.fabs.f32(float %31)
store float %32, float* %10
%33 = load float*, float** %6
%34 = load float, float* %33
%35 = call float @llvm.fabs.f32(float %34)
store float %35, float* %11
%36 = load float*, float** %5
%37 = load float, float* %36
%38 = load float, float* %9
%39 = fdiv float %37, %38
store float %39, float* %12
%40 = load float*, float** %6
%41 = load float, float* %40
%42 = load float, float* %9
%43 = fdiv float %41, %42
store float %43, float* %13
%44 = load float, float* %9
%45 = load float, float* %12
%46 = load float, float* %12
%47 = load float, float* %13
%48 = load float, float* %13
%49 = fmul float %47, %48
%50 = call float @llvm.fmuladd.f32(float %45, float %46, float %49)
%51 = call float @sqrtf(float %50)
%52 = fmul float %44, %51
store float %52, float* %14
%53 = load float, float* %14
%54 = load float, float* %10
%55 = load float, float* %11
%56 = fcmp ogt float %54, %55
br i1 %56, label %57, label %60
57: ; preds = %29
%58 = load float*, float** %5
%59 = load float, float* %58
br label %63
60: ; preds = %29
%61 = load float*, float** %6
%62 = load float, float* %61
br label %63
63: ; preds = %60, %57
%64 = phi float [ %59, %57 ], [ %62, %60 ]
%65 = call float @llvm.copysign.f32(float %53, float %64)
store float %65, float* %14
%66 = load float*, float** %5
%67 = load float, float* %66
%68 = load float, float* %14
%69 = fdiv float %67, %68
%70 = load float*, float** %7
store float %69, float* %70
%71 = load float*, float** %6
%72 = load float, float* %71
%73 = load float, float* %14
%74 = fdiv float %72, %73
%75 = load float*, float** %8
store float %74, float* %75
%76 = load float, float* %10
%77 = load float, float* %11
%78 = fcmp ogt float %76, %77
br i1 %78, label %79, label %83
79: ; preds = %63
%80 = load float*, float** %8
%81 = load float, float* %80
%82 = load float*, float** %6
store float %81, float* %82
br label %99
83: ; preds = %63
%84 = load float, float* %10
%85 = load float, float* %11
%86 = fcmp oge float %84, %85
br i1 %86, label %87, label %96
87: ; preds = %83
%88 = load float*, float** %7
%89 = load float, float* %88
%90 = fcmp une float %89, 0.000000e+00
br i1 %90, label %91, label %96
91: ; preds = %87
%92 = load float*, float** %7
%93 = load float, float* %92
%94 = fdiv float 1.000000e+00, %93
%95 = load float*, float** %6
store float %94, float* %95
br label %98
96: ; preds = %87, %83
%97 = load float*, float** %6
store float 1.000000e+00, float* %97
br label %98
98: ; preds = %96, %91
br label %99
99: ; preds = %98, %79
%100 = load float, float* %14
%101 = load float*, float** %5
store float %100, float* %101
br label %102
102: ; preds = %99, %24
ret void
}

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