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

; 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"

%struct.HTr = type { [3 x double], [3 x [3 x double]] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@__func__.HTr_isValid = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1
@RcsLogLevel = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

declare zeroext i1 @Mat3d_isValid(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @HTr_isValid(ptr noundef %0) #3 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  store i8 0, ptr %5, align 1, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %73

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.HTr, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds [3 x [3 x double]], ptr %12, i64 0, i64 0
  %14 = call zeroext i1 @Mat3d_isValid(ptr noundef %13)
  %15 = zext i1 %14 to i8
  store i8 %15, ptr %5, align 1, !tbaa !9
  %16 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %17 = trunc i8 %16 to i1
  %18 = zext i1 %17 to i32
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %10
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %73

21:                                               ; preds = %10
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %22

22:                                               ; preds = %67, %21
  %23 = load i32, ptr %4, align 4, !tbaa !13
  %24 = icmp slt i32 %23, 3
  br i1 %24, label %25, label %70

25:                                               ; preds = %22
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.HTr, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %4, align 4, !tbaa !13
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [3 x double], ptr %27, i64 0, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = call zeroext i1 @Math_isFinite(double noundef %31)
  br i1 %32, label %66, label %33

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !13
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.HTr, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %4, align 4, !tbaa !13
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [3 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !15
  call void (i32, ptr, ptr, i32, ptr, ...) %38(i32 noundef 4, ptr noundef @.str.1, ptr noundef @__func__.HTr_isValid, i32 noundef 185, ptr noundef @.str.4, i32 noundef %39, double noundef %45)
  br label %46

46:                                               ; preds = %37, %34
  %47 = load i32, ptr @RcsLogLevel, align 4, !tbaa !13
  %48 = icmp sle i32 4, %47
  br i1 %48, label %49, label %63

49:                                               ; preds = %46
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.5, ptr noundef @.str.1, ptr noundef @__func__.HTr_isValid, i32 noundef 185) #4
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !13
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.HTr, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %4, align 4, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [3 x double], ptr %55, i64 0, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !15
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.4, i32 noundef %53, double noundef %59) #4
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.6) #4
  br label %63

63:                                               ; preds = %49, %46
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %73

66:                                               ; preds = %25
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %4, align 4, !tbaa !13
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %4, align 4, !tbaa !13
  br label %22, !llvm.loop !17

70:                                               ; preds = %22
  %71 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %72 = trunc i8 %71 to i1
  store i1 %72, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %73

73:                                               ; preds = %70, %65, %20, %9
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %74 = load i1, ptr %2, align 1
  ret i1 %74
}

declare zeroext i1 @Math_isFinite(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 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 #4 = { 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 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@__func__.HTr_isValid = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare zeroext i1 @Mat3d_isValid(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @HTr_isValid(ptr noundef %0) local_unnamed_addr #2 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %.loopexit, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = tail call zeroext i1 @Mat3d_isValid(ptr noundef nonnull %4) #3
  br i1 %5, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %3
  %6 = load double, ptr %0, align 8, !tbaa !5
  %7 = tail call zeroext i1 @Math_isFinite(double noundef %6) #3
  br i1 %7, label %.preheader.1, label %8

8:                                                ; preds = %.preheader.2, %.preheader.1, %.preheader.preheader
  %.019.lcssa.wide = phi i64 [ 0, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 2, %.preheader.2 ]
  %9 = trunc nuw nsw i64 %.019.lcssa.wide to i32
  %10 = getelementptr inbounds [3 x double], ptr %0, i64 0, i64 %.019.lcssa.wide
  %11 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !9
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %14, label %12

12:                                               ; preds = %8
  %13 = load double, ptr %10, align 8, !tbaa !5
  tail call void (i32, ptr, ptr, i32, ptr, ...) %11(i32 noundef 4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.HTr_isValid, i32 noundef 185, ptr noundef nonnull @.str.4, i32 noundef %9, double noundef %13) #3
  br label %14

14:                                               ; preds = %12, %8
  %15 = load i32, ptr @RcsLogLevel, align 4, !tbaa !11
  %16 = icmp sgt i32 %15, 3
  br i1 %16, label %17, label %.loopexit

17:                                               ; preds = %14
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.HTr_isValid, i32 noundef 185) #4
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = load double, ptr %10, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.4, i32 noundef %9, double noundef %21) #4
  %23 = load ptr, ptr @stderr, align 8, !tbaa !9
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.6) #4
  br label %.loopexit

.preheader.1:                                     ; preds = %.preheader.preheader
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = tail call zeroext i1 @Math_isFinite(double noundef %26) #3
  br i1 %27, label %.preheader.2, label %8

.preheader.2:                                     ; preds = %.preheader.1
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call zeroext i1 @Math_isFinite(double noundef %29) #3
  br i1 %30, label %.loopexit, label %8

.loopexit:                                        ; preds = %.preheader.2, %14, %17, %3, %1
  %.014 = phi i1 [ false, %1 ], [ false, %3 ], [ false, %17 ], [ false, %14 ], [ true, %.preheader.2 ]
  ret i1 %.014
}

declare zeroext i1 @Math_isFinite(double noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind "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 #1 = { "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 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 }
attributes #4 = { cold 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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