#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 */
double fabs(double);
double sqrt(double);
void eigenvec2(double A[2][2], double eval, double evec[2], double *res) {
  double norm;
  double res1, res2;
  int i;
  if (fabs(A[0][0] - eval) > fabs(A[1][1] - eval)) {
    evec[0] = -A[1][0];
    evec[1] = A[0][0] - eval;
  } else {
    evec[0] = A[1][1] - eval;
    evec[1] = -A[1][0];
  }
  norm = sqrt(evec[0] * evec[0] + evec[1] * evec[1]);
  if (norm == 0) {
    evec[0] = 1;
    evec[1] = 0;
    norm = 1;
  }
  for (i = 0; i < 2; i++) {
    evec[i] /= norm;
  }
  res1 = (A[0][0] - eval) * evec[0] + A[1][0] * evec[1];
  res2 = A[1][0] * evec[0] + (A[1][1] - eval) * evec[1];
  *res = sqrt(res1 * res1 + res2 * res2);
  res1 = fabs(A[0][0]) + fabs(A[1][0]);
  res2 = fabs(A[1][1]) + fabs(A[1][0]);
  *res /= ((res1) > (res2) ? (res1) : (res2));
}


x86 assembly (clang, -O0):
<eigenvec2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xec3(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xeaa(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a7 <eigenvec2+0x97>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    11e6 <eigenvec2+0xd6>
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125b <eigenvec2+0x14b>
jp     125b <eigenvec2+0x14b>
mov    -0x18(%rbp),%rax
movsd  0xdd2(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0xdba(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jge    1295 <eigenvec2+0x185>
movsd  -0x28(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1262 <eigenvec2+0x152>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
subsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xcca(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
movaps 0xcb6(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movaps 0xc99(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
movaps 0xc85(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    13a7 <eigenvec2+0x297>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    13b1 <eigenvec2+0x2a1>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigenvec2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movapd %xmm0,%xmm4
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  0x18(%rdi),%xmm0
subsd  %xmm4,%xmm1
movapd 0xec5(%rip),%xmm2
andpd  %xmm2,%xmm1
subsd  %xmm4,%xmm0
andpd  %xmm0,%xmm2
ucomisd %xmm2,%xmm1
jbe    1169 <eigenvec2+0x59>
movsd  0x10(%rbx),%xmm0
xorpd  0xeb6(%rip),%xmm0
movlpd %xmm0,(%r15)
movsd  (%rbx),%xmm1
subsd  %xmm4,%xmm1
jmp    117b <eigenvec2+0x6b>
movsd  %xmm0,(%r15)
movsd  0x10(%rbx),%xmm1
xorpd  0xe95(%rip),%xmm1
movsd  %xmm1,0x8(%r15)
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119d <eigenvec2+0x8d>
sqrtsd %xmm0,%xmm0
jmp    11b2 <eigenvec2+0xa2>
movsd  %xmm4,0x8(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm4
ucomisd %xmm1,%xmm0
jne    11cc <eigenvec2+0xbc>
jp     11cc <eigenvec2+0xbc>
movsd  0xe5e(%rip),%xmm1
movsd  0xe56(%rip),%xmm0
jmp    11d1 <eigenvec2+0xc1>
movupd (%r15),%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movupd %xmm1,(%r15)
movsd  (%rbx),%xmm0
movsd  0x10(%rbx),%xmm2
subsd  %xmm4,%xmm0
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm3
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
movsd  0x18(%rbx),%xmm2
subsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1230 <eigenvec2+0x120>
sqrtsd %xmm0,%xmm0
jmp    1235 <eigenvec2+0x125>
call   1030 <sqrt@plt>
movsd  %xmm0,(%r14)
movsd  (%rbx),%xmm1
movapd 0xdba(%rip),%xmm2
andpd  %xmm2,%xmm1
movupd 0x10(%rbx),%xmm3
andpd  %xmm2,%xmm3
unpcklpd %xmm3,%xmm1
addpd  %xmm3,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
maxsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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