; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_Mat3d)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: nounwind uwtable
define dso_local double @Mat3d_maxAbsEle(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds [3 x double], ptr %8, i64 0
  %10 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = call double @llvm.fabs.f64(double %11)
  store double %12, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %13

13:                                               ; preds = %42, %1
  %14 = load i32, ptr %4, align 4, !tbaa !11
  %15 = icmp ult i32 %14, 3
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %45

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %38, %17
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = icmp ult i32 %19, 3
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %41

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !11
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [3 x double], ptr %23, i64 %25
  %27 = load i32, ptr %6, align 4, !tbaa !11
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [3 x double], ptr %26, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = call double @llvm.fabs.f64(double %30)
  store double %31, ptr %7, align 8, !tbaa !9
  %32 = load double, ptr %7, align 8, !tbaa !9
  %33 = load double, ptr %3, align 8, !tbaa !9
  %34 = fcmp ogt double %32, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %22
  %36 = load double, ptr %7, align 8, !tbaa !9
  store double %36, ptr %3, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %35, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %6, align 4, !tbaa !11
  %40 = add i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !11
  br label %18, !llvm.loop !13

41:                                               ; preds = %21
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %4, align 4, !tbaa !11
  %44 = add i32 %43, 1
  store i32 %44, ptr %4, align 4, !tbaa !11
  br label %13, !llvm.loop !15

45:                                               ; preds = %16
  %46 = load double, ptr %3, align 8, !tbaa !9
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %46
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local double @Mat3d_maxAbsEle(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
.preheader:
  %1 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %2 = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %1)
  %3 = extractelement <2 x double> %2, i64 0
  %4 = extractelement <2 x double> %2, i64 1
  %5 = fcmp ogt double %4, %3
  %.2.1 = select i1 %5, double %4, double %3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call double @llvm.fabs.f64(double %7)
  %9 = fcmp ogt double %8, %.2.1
  %.2.2 = select i1 %9, double %8, double %.2.1
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = tail call double @llvm.fabs.f64(double %11)
  %13 = fcmp ogt double %12, %.2.2
  %.2.120 = select i1 %13, double %12, double %.2.2
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = tail call double @llvm.fabs.f64(double %15)
  %17 = fcmp ogt double %16, %.2.120
  %.2.1.1 = select i1 %17, double %16, double %.2.120
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = tail call double @llvm.fabs.f64(double %19)
  %21 = fcmp ogt double %20, %.2.1.1
  %.2.2.1 = select i1 %21, double %20, double %.2.1.1
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = tail call double @llvm.fabs.f64(double %23)
  %25 = fcmp ogt double %24, %.2.2.1
  %.2.221 = select i1 %25, double %24, double %.2.2.1
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = tail call double @llvm.fabs.f64(double %27)
  %29 = fcmp ogt double %28, %.2.221
  %.2.1.2 = select i1 %29, double %28, double %.2.221
  %30 = getelementptr inbounds i8, ptr %0, i64 64
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = tail call double @llvm.fabs.f64(double %31)
  %33 = fcmp ogt double %32, %.2.1.2
  %.2.2.2 = select i1 %33, double %32, double %.2.1.2
  ret double %.2.2.2
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fabs.v2f64(<2 x double>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass