#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 */
int /*<<< orphan*/ dlartg_(double *, double *, double *, double *, double *);
void dbdqr(int *n, double *d, double *e, double *c1, double *c2) {
  int i;
  double cs, sn, r;
  if (*n < 2) {
    return;
  }
  for (i = 0; i < *n - 1; i++) {
    dlartg_(d + i, e + i, &cs, &sn, &r);
    d[i] = r;
    e[i] = sn * d[i + 1];
    d[i + 1] = cs * d[i + 1];
  }
  i = *n - 1;
  dlartg_(d + i, e + i, &cs, &sn, &r);
  d[i] = r;
  e[i] = 0.0;
  *c1 = sn;
  *c2 = cs;
}


x86 assembly (clang, -O0):
<dbdqr>:
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    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x2,(%rax)
jge    113e <dbdqr+0x2e>
jmp    126c <dbdqr+0x15c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f5 <dbdqr+0xe5>
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1030 <dlartg_@plt>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1145 <dbdqr+0x35>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1030 <dlartg_@plt>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbdqr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmpl   $0x2,(%rdi)
jl     120c <dbdqr+0xfc>
mov    %rdi,%rbx
mov    %rcx,0x28(%rsp)
mov    %r8,0x30(%rsp)
xor    %ebp,%ebp
mov    %rsp,%r15
mov    %rsi,0x18(%rsp)
mov    %rsi,%r13
mov    %rdx,0x20(%rsp)
mov    %rdx,%r12
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r12,%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %r15,%r8
call   1030 <dlartg_@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%r13)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbp
mulsd  0x8(%r13),%xmm0
movsd  %xmm0,(%r12)
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%r13),%xmm0
movsd  %xmm0,0x8(%r13)
add    $0x8,%r13
movslq (%rbx),%r14
add    $0xffffffffffffffff,%r14
add    $0x8,%r12
cmp    %r14,%rbp
jl     1150 <dbdqr+0x40>
mov    0x18(%rsp),%rbp
lea    0x0(,%r14,8),%rdi
add    %rbp,%rdi
mov    0x20(%rsp),%rbx
lea    (%rbx,%r14,8),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
call   1030 <dlartg_@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%rbp,%r14,8)
movq   $0x0,(%rbx,%r14,8)
movsd  0x8(%rsp),%xmm0
mov    0x28(%rsp),%rax
movsd  %xmm0,(%rax)
movsd  0x10(%rsp),%xmm0
mov    0x30(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dbdqr(i32* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32* %0, i32** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %5
br label %95
19: ; preds = %5
store i32 0, i32* %11
br label %20
20: ; preds = %66, %19
%21 = load i32, i32* %11
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = sub nsw i32 %23, 1
%25 = icmp slt i32 %21, %24
br i1 %25, label %26, label %69
26: ; preds = %20
%27 = load double*, double** %7
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double*, double** %8
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = call i32 @dlartg_(double* %30, double* %34, double* %12, double* %13, double* %14)
%36 = load double, double* %14
%37 = load double*, double** %7
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
%41 = load double, double* %13
%42 = load double*, double** %7
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %42, i64 %45
%47 = load double, double* %46
%48 = fmul double %41, %47
%49 = load double*, double** %8
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
%53 = load double, double* %12
%54 = load double*, double** %7
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %54, i64 %57
%59 = load double, double* %58
%60 = fmul double %53, %59
%61 = load double*, double** %7
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %61, i64 %64
store double %60, double* %65
br label %66
66: ; preds = %26
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %20
69: ; preds = %20
%70 = load i32*, i32** %6
%71 = load i32, i32* %70
%72 = sub nsw i32 %71, 1
store i32 %72, i32* %11
%73 = load double*, double** %7
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double*, double** %8
%78 = load i32, i32* %11
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = call i32 @dlartg_(double* %76, double* %80, double* %12, double* %13, double* %14)
%82 = load double, double* %14
%83 = load double*, double** %7
%84 = load i32, i32* %11
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double %82, double* %86
%87 = load double*, double** %8
%88 = load i32, i32* %11
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
store double 0.000000e+00, double* %90
%91 = load double, double* %13
%92 = load double*, double** %9
store double %91, double* %92
%93 = load double, double* %12
%94 = load double*, double** %10
store double %93, double* %94
br label %95
95: ; preds = %69, %18
ret void
}

LLVM IR (-O2):
define void @dbdqr(i32* nocapture %0, double* %1, double* %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %6 to i8*
%10 = bitcast double* %7 to i8*
%11 = bitcast double* %8 to i8*
%12 = load i32, i32* %0
%13 = icmp slt i32 %12, 2
br i1 %13, label %39, label %14
14: ; preds = %5, %14
%15 = phi i64 [ %21, %14 ], [ 0, %5 ]
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = getelementptr inbounds double, double* %2, i64 %15
%18 = call i32 @dlartg_(double* %16, double* %17, double* %6, double* %7, double* %8)
%19 = load double, double* %8
store double %19, double* %16
%20 = load double, double* %7
%21 = add nuw nsw i64 %15, 1
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = load double, double* %22
%24 = fmul double %20, %23
store double %24, double* %17
%25 = load double, double* %6
%26 = load double, double* %22
%27 = fmul double %25, %26
store double %27, double* %22
%28 = load i32, i32* %0
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %21, %30
br i1 %31, label %14, label %32
32: ; preds = %14
%33 = getelementptr inbounds double, double* %1, i64 %30
%34 = getelementptr inbounds double, double* %2, i64 %30
%35 = call i32 @dlartg_(double* %33, double* %34, double* %6, double* %7, double* %8)
%36 = load double, double* %8
store double %36, double* %33
store double 0.000000e+00, double* %34
%37 = load double, double* %7
store double %37, double* %3
%38 = load double, double* %6
store double %38, double* %4
br label %39
39: ; preds = %5, %32
ret void
}