; 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: nounwind uwtable
define dso_local zeroext i1 @Mat3d_isIdentity(ptr noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %35, %1
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 3
  br i1 %9, label %10, label %38

10:                                               ; preds = %7
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %31, %10
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 3
  br i1 %13, label %14, label %34

14:                                               ; preds = %11
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [3 x double], ptr %15, i64 %17
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [3 x double], ptr %18, i64 0, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = icmp eq i32 %23, %24
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, double 1.000000e+00, double 0.000000e+00
  %28 = fcmp une double %22, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %14
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %39

30:                                               ; preds = %14
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !13

34:                                               ; preds = %11
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !15

38:                                               ; preds = %7
  store i1 true, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %39

39:                                               ; preds = %38, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %40 = load i1, ptr %2, align 1
  ret i1 %40
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @Mat3d_isIdentity(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
.preheader:
  %1 = load double, ptr %0, align 8, !tbaa !5
  %2 = fcmp une double %1, 1.000000e+00
  br i1 %2, label %.loopexit.loopexit, label %3

3:                                                ; preds = %.preheader
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fcmp une double %5, 0.000000e+00
  br i1 %6, label %.loopexit.loopexit, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fcmp une double %9, 0.000000e+00
  br i1 %10, label %.loopexit.loopexit, label %.preheader.1

.preheader.1:                                     ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fcmp une double %12, 0.000000e+00
  br i1 %13, label %.loopexit.loopexit, label %14

14:                                               ; preds = %.preheader.1
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp une double %16, 1.000000e+00
  br i1 %17, label %.loopexit.loopexit, label %18

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fcmp une double %20, 0.000000e+00
  br i1 %21, label %.loopexit.loopexit, label %.preheader.2

.preheader.2:                                     ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fcmp une double %23, 0.000000e+00
  br i1 %24, label %.loopexit.loopexit, label %25

25:                                               ; preds = %.preheader.2
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fcmp une double %27, 0.000000e+00
  br i1 %28, label %.loopexit.loopexit, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 64
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fcmp une double %31, 1.000000e+00
  br i1 %32, label %.loopexit.loopexit, label %.loopexit

.loopexit.loopexit:                               ; preds = %29, %25, %.preheader.2, %18, %14, %.preheader.1, %7, %3, %.preheader
  br label %.loopexit

.loopexit:                                        ; preds = %29, %.loopexit.loopexit
  %33 = phi i1 [ false, %.loopexit.loopexit ], [ true, %29 ]
  ret i1 %33
}

attributes #0 = { 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" }

!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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass