; LLVM IR from ljm941004/HYPERCV_PUBLIC :: modules/core/src/c_src (hypermat)

; 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.HyperMat = type { i32, i32, i32, i32, [3 x i8], ptr, ptr }

@.str.24 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [21 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @hyper_mat_showinfo(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = call i32 (ptr, ...) @printf(ptr noundef @.str.31)
  br label %69

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.HyperMat, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, i32 noundef %11)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.HyperMat, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.33, i32 noundef %15)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.HyperMat, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.34, i32 noundef %19)
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HyperMat, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.35, i32 noundef %23)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.HyperMat, ptr %25, i32 0, i32 4
  %27 = getelementptr inbounds [3 x i8], ptr %26, i64 0, i64 0
  %28 = load i8, ptr %27, align 8, !tbaa !15
  %29 = sext i8 %28 to i32
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.HyperMat, ptr %30, i32 0, i32 4
  %32 = getelementptr inbounds [3 x i8], ptr %31, i64 0, i64 1
  %33 = load i8, ptr %32, align 1, !tbaa !15
  %34 = sext i8 %33 to i32
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.HyperMat, ptr %35, i32 0, i32 4
  %37 = getelementptr inbounds [3 x i8], ptr %36, i64 0, i64 2
  %38 = load i8, ptr %37, align 2, !tbaa !15
  %39 = sext i8 %38 to i32
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.36, i32 noundef %29, i32 noundef %34, i32 noundef %39)
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.HyperMat, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %68

45:                                               ; preds = %8
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.37)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %47

47:                                               ; preds = %64, %45
  %48 = load i32, ptr %3, align 4, !tbaa !17
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.HyperMat, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = icmp slt i32 %48, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %67

54:                                               ; preds = %47
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.HyperMat, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  %58 = load i32, ptr %3, align 4, !tbaa !17
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds float, ptr %57, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !18
  %62 = fpext float %61 to double
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, double noundef %62)
  br label %64

64:                                               ; preds = %54
  %65 = load i32, ptr %3, align 4, !tbaa !17
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %3, align 4, !tbaa !17
  br label %47, !llvm.loop !20

67:                                               ; preds = %53
  br label %68

68:                                               ; preds = %67, %8
  br label %69

69:                                               ; preds = %68, %6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !7, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 12}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !6, i64 32}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@.str.24 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @hyper_mat_showinfo(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %5

3:                                                ; preds = %1
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31)
  br label %.loopexit

5:                                                ; preds = %1
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, i32 noundef %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33, i32 noundef %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.34, i32 noundef %12)
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35, i32 noundef %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load i8, ptr %17, align 8, !tbaa !14
  %19 = sext i8 %18 to i32
  %20 = getelementptr inbounds i8, ptr %0, i64 17
  %21 = load i8, ptr %20, align 1, !tbaa !14
  %22 = sext i8 %21 to i32
  %23 = getelementptr inbounds i8, ptr %0, i64 18
  %24 = load i8, ptr %23, align 2, !tbaa !14
  %25 = sext i8 %24 to i32
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.36, i32 noundef %19, i32 noundef %22, i32 noundef %25)
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %.not = icmp eq ptr %28, null
  br i1 %.not, label %.loopexit, label %29

29:                                               ; preds = %5
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %31 = load i32, ptr %11, align 8, !tbaa !12
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %29, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %29 ]
  %33 = load ptr, ptr %27, align 8, !tbaa !15
  %34 = getelementptr inbounds float, ptr %33, i64 %indvars.iv
  %35 = load float, ptr %34, align 4, !tbaa !16
  %36 = fpext float %35 to double
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, double noundef %36)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr %11, align 8, !tbaa !12
  %39 = sext i32 %38 to i64
  %40 = icmp slt i64 %indvars.iv.next, %39
  br i1 %40, label %.lr.ph, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph, %29, %5, %3
  ret void
}

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 = { nofree 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" }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 12}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !10, i64 32}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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