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