#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 sqrt(int);
void eig2t(double *A, int stride) {
  int N;
  double a11, a12, a21, a22, c, s, c2, s2, cs, t1, t, t2, at11, at12, at21,
      at22;
  N = stride;
  a11 = A[0];
  a12 = A[1];
  a21 = A[N];
  a22 = A[N + 1];
  if ((a12 + a21) == 0) {
    c = 1. / sqrt(2.0);
    s = c;
  } else {
    t1 = (a11 - a22) / (a12 + a21);
    t = t1 / (1. + sqrt(1 + t1 * t1));
    c = 1. / sqrt(1 + t * t);
    s = c * t;
  }
  c2 = c * c;
  s2 = s * s;
  cs = c * s;
  at11 = c2 * a11 + s2 * a22 - cs * (a12 + a21);
  at12 = c2 * a12 - s2 * a21 + cs * (a11 - a22);
  at21 = c2 * a21 - s2 * a12 + cs * (a11 - a22);
  at22 = c2 * a22 + s2 * a11 + cs * (a12 + a21);
  A[0] = at11;
  A[1] = at12;
  A[N] = at21;
  A[N + 1] = at22;
}


x86 assembly (clang, -O0):
<eig2t>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b7 <eig2t+0xa7>
jp     11b7 <eig2t+0xa7>
mov    $0x2,%edi
call   1030 <sqrt@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe61(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    126c <eig2t+0x15c>
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe09(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  -0x98(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm2
movsd  0xde8(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc5(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdac(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
addsd  -0x28(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
subsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
subsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
addsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x80(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eig2t>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
movupd (%rdi),%xmm3
movslq %esi,%r14
movupd (%rdi,%r14,8),%xmm2
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
addpd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm2,0x20(%rsp)
movapd %xmm3,0x10(%rsp)
movapd %xmm1,0x40(%rsp)
jne    1198 <eig2t+0x88>
jp     1198 <eig2t+0x88>
mov    $0x2,%edi
call   1030 <sqrt@plt>
movapd 0x10(%rsp),%xmm9
movapd 0x20(%rsp),%xmm8
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe88(%rip),%xmm5
divsd  %xmm0,%xmm5
movapd %xmm8,%xmm0
unpckhpd %xmm8,%xmm0
movapd %xmm9,%xmm6
subsd  %xmm0,%xmm6
movapd %xmm5,%xmm7
jmp    123a <eig2t+0x12a>
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
movapd %xmm3,%xmm4
subsd  %xmm0,%xmm4
movapd %xmm4,0x30(%rsp)
movapd %xmm4,%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
movsd  0xe39(%rip),%xmm4
addsd  %xmm4,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe1d(%rip),%xmm2
addsd  %xmm2,%xmm0
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  0xdee(%rip),%xmm7
movapd (%rsp),%xmm5
movapd 0x30(%rsp),%xmm6
movapd 0x10(%rsp),%xmm9
movapd 0x20(%rsp),%xmm8
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm7
mulsd  %xmm7,%xmm5
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm7,%xmm5
mulsd  %xmm7,%xmm7
movapd 0xdbe(%rip),%xmm1
movapd %xmm5,%xmm2
xorpd  %xmm1,%xmm2
xorpd  %xmm0,%xmm1
movapd %xmm8,%xmm3
shufpd $0x1,%xmm8,%xmm3
unpcklpd %xmm1,%xmm0
mulpd  %xmm0,%xmm3
unpcklpd %xmm7,%xmm7
movapd %xmm7,%xmm1
mulpd  %xmm9,%xmm1
addpd  %xmm3,%xmm1
unpcklpd %xmm5,%xmm2
movapd 0x40(%rsp),%xmm4
movapd %xmm4,%xmm3
unpcklpd %xmm6,%xmm3
mulpd  %xmm2,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm9,%xmm0
shufpd $0x1,%xmm0,%xmm0
mulpd  %xmm8,%xmm7
addpd  %xmm0,%xmm7
unpcklpd %xmm5,%xmm5
unpcklpd %xmm4,%xmm6
mulpd  %xmm5,%xmm6
addpd  %xmm7,%xmm6
movupd %xmm3,(%rbx)
movupd %xmm6,(%rbx,%r14,8)
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @eig2t(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%22 = load i32, i32* %4
store i32 %22, i32* %5
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
store double %25, double* %6
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
store double %28, double* %7
%29 = load double*, double** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
store double %33, double* %8
%34 = load double*, double** %3
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
%39 = load double, double* %38
store double %39, double* %9
%40 = load double, double* %7
%41 = load double, double* %8
%42 = fadd double %40, %41
%43 = fcmp oeq double %42, 0.000000e+00
br i1 %43, label %44, label %49
44: ; preds = %2
%45 = call i32 @sqrt(i32 2)
%46 = sitofp i32 %45 to double
%47 = fdiv double 1.000000e+00, %46
store double %47, double* %10
%48 = load double, double* %10
store double %48, double* %11
br label %76
49: ; preds = %2
%50 = load double, double* %6
%51 = load double, double* %9
%52 = fsub double %50, %51
%53 = load double, double* %7
%54 = load double, double* %8
%55 = fadd double %53, %54
%56 = fdiv double %52, %55
store double %56, double* %15
%57 = load double, double* %15
%58 = load double, double* %15
%59 = load double, double* %15
%60 = call double @llvm.fmuladd.f64(double %58, double %59, double 1.000000e+00)
%61 = fptosi double %60 to i32
%62 = call i32 @sqrt(i32 %61)
%63 = sitofp i32 %62 to double
%64 = fadd double 1.000000e+00, %63
%65 = fdiv double %57, %64
store double %65, double* %16
%66 = load double, double* %16
%67 = load double, double* %16
%68 = call double @llvm.fmuladd.f64(double %66, double %67, double 1.000000e+00)
%69 = fptosi double %68 to i32
%70 = call i32 @sqrt(i32 %69)
%71 = sitofp i32 %70 to double
%72 = fdiv double 1.000000e+00, %71
store double %72, double* %10
%73 = load double, double* %10
%74 = load double, double* %16
%75 = fmul double %73, %74
store double %75, double* %11
br label %76
76: ; preds = %49, %44
%77 = load double, double* %10
%78 = load double, double* %10
%79 = fmul double %77, %78
store double %79, double* %12
%80 = load double, double* %11
%81 = load double, double* %11
%82 = fmul double %80, %81
store double %82, double* %13
%83 = load double, double* %10
%84 = load double, double* %11
%85 = fmul double %83, %84
store double %85, double* %14
%86 = load double, double* %12
%87 = load double, double* %6
%88 = load double, double* %13
%89 = load double, double* %9
%90 = fmul double %88, %89
%91 = call double @llvm.fmuladd.f64(double %86, double %87, double %90)
%92 = load double, double* %14
%93 = load double, double* %7
%94 = load double, double* %8
%95 = fadd double %93, %94
%96 = fneg double %92
%97 = call double @llvm.fmuladd.f64(double %96, double %95, double %91)
store double %97, double* %18
%98 = load double, double* %12
%99 = load double, double* %7
%100 = load double, double* %13
%101 = load double, double* %8
%102 = fmul double %100, %101
%103 = fneg double %102
%104 = call double @llvm.fmuladd.f64(double %98, double %99, double %103)
%105 = load double, double* %14
%106 = load double, double* %6
%107 = load double, double* %9
%108 = fsub double %106, %107
%109 = call double @llvm.fmuladd.f64(double %105, double %108, double %104)
store double %109, double* %19
%110 = load double, double* %12
%111 = load double, double* %8
%112 = load double, double* %13
%113 = load double, double* %7
%114 = fmul double %112, %113
%115 = fneg double %114
%116 = call double @llvm.fmuladd.f64(double %110, double %111, double %115)
%117 = load double, double* %14
%118 = load double, double* %6
%119 = load double, double* %9
%120 = fsub double %118, %119
%121 = call double @llvm.fmuladd.f64(double %117, double %120, double %116)
store double %121, double* %20
%122 = load double, double* %12
%123 = load double, double* %9
%124 = load double, double* %13
%125 = load double, double* %6
%126 = fmul double %124, %125
%127 = call double @llvm.fmuladd.f64(double %122, double %123, double %126)
%128 = load double, double* %14
%129 = load double, double* %7
%130 = load double, double* %8
%131 = fadd double %129, %130
%132 = call double @llvm.fmuladd.f64(double %128, double %131, double %127)
store double %132, double* %21
%133 = load double, double* %18
%134 = load double*, double** %3
%135 = getelementptr inbounds double, double* %134, i64 0
store double %133, double* %135
%136 = load double, double* %19
%137 = load double*, double** %3
%138 = getelementptr inbounds double, double* %137, i64 1
store double %136, double* %138
%139 = load double, double* %20
%140 = load double*, double** %3
%141 = load i32, i32* %5
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %140, i64 %142
store double %139, double* %143
%144 = load double, double* %21
%145 = load double*, double** %3
%146 = load i32, i32* %5
%147 = add nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double, double* %145, i64 %148
store double %144, double* %149
ret void
}

LLVM IR (-O2):
define void @eig2t(double* nocapture %0, i32 %1) {
%3 = bitcast double* %0 to <2 x double>*
%4 = load <2 x double>, <2 x double>* %3
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = bitcast double* %6 to <2 x double>*
%8 = load <2 x double>, <2 x double>* %7
%9 = shufflevector <2 x double> %4, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%10 = fadd <2 x double> %9, %8
%11 = extractelement <2 x double> %10, i64 0
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = tail call i32 @sqrt(i32 2)
%15 = sitofp i32 %14 to double
%16 = fdiv double 1.000000e+00, %15
%17 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%18 = fsub <2 x double> %4, %17
%19 = extractelement <2 x double> %18, i64 0
br label %37
20: ; preds = %2
%21 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%22 = fsub <2 x double> %4, %21
%23 = extractelement <2 x double> %22, i64 0
%24 = fdiv double %23, %11
%25 = tail call double @llvm.fmuladd.f64(double %24, double %24, double 1.000000e+00)
%26 = fptosi double %25 to i32
%27 = tail call i32 @sqrt(i32 %26)
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 1.000000e+00
%30 = fdiv double %24, %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double %30, double 1.000000e+00)
%32 = fptosi double %31 to i32
%33 = tail call i32 @sqrt(i32 %32)
%34 = sitofp i32 %33 to double
%35 = fdiv double 1.000000e+00, %34
%36 = fmul double %35, %30
br label %37
37: ; preds = %20, %13
%38 = phi double [ %23, %20 ], [ %19, %13 ]
%39 = phi double [ %36, %20 ], [ %16, %13 ]
%40 = phi double [ %35, %20 ], [ %16, %13 ]
%41 = fmul double %40, %40
%42 = fmul double %39, %39
%43 = fmul double %39, %40
%44 = fneg double %43
%45 = fneg double %42
%46 = insertelement <2 x double> poison, double %45, i64 0
%47 = insertelement <2 x double> %46, double %42, i64 1
%48 = fmul <2 x double> %8, %47
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%50 = insertelement <2 x double> poison, double %41, i64 0
%51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
%52 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %51, <2 x double> %4, <2 x double> %49)
%53 = insertelement <2 x double> poison, double %44, i64 0
%54 = insertelement <2 x double> %53, double %43, i64 1
%55 = insertelement <2 x double> %10, double %38, i64 1
%56 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %54, <2 x double> %55, <2 x double> %52)
%57 = insertelement <2 x double> poison, double %42, i64 0
%58 = insertelement <2 x double> %57, double %45, i64 1
%59 = fmul <2 x double> %4, %58
%60 = shufflevector <2 x double> %59, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%61 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %51, <2 x double> %8, <2 x double> %60)
%62 = insertelement <2 x double> poison, double %43, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
%64 = insertelement <2 x double> poison, double %11, i64 1
%65 = insertelement <2 x double> %64, double %38, i64 0
%66 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %63, <2 x double> %65, <2 x double> %61)
%67 = bitcast double* %0 to <2 x double>*
store <2 x double> %56, <2 x double>* %67
%68 = bitcast double* %6 to <2 x double>*
store <2 x double> %66, <2 x double>* %68
ret void
}