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

; 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.SIMPLE_MAT = type { i32, i32, i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 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 uwtable
define dso_local ptr @create_simple_mat_with_data(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %5
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %26

22:                                               ; preds = %18, %5
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #7
  unreachable

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = call i32 @get_elemsize(i32 noundef %27)
  store i32 %28, ptr %13, align 4, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !9
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %43

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = mul nsw i32 %32, %33
  %35 = load i32, ptr %13, align 4, !tbaa !5
  %36 = mul nsw i32 %34, %35
  %37 = load i32, ptr %9, align 4, !tbaa !5
  %38 = mul nsw i32 %36, %37
  store i32 %38, ptr %14, align 4, !tbaa !5
  %39 = load i32, ptr %14, align 4, !tbaa !5
  %40 = add nsw i32 %39, 64
  %41 = load i32, ptr %12, align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %43

43:                                               ; preds = %31, %26
  %44 = load i32, ptr %12, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul i64 1, %45
  %47 = call noalias ptr @malloc(i64 noundef %46) #9
  store ptr %47, ptr %11, align 8, !tbaa !9
  %48 = load ptr, ptr %11, align 8, !tbaa !9
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %51

50:                                               ; preds = %43
  br label %55

51:                                               ; preds = %43
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #7
  unreachable

55:                                               ; preds = %50
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %77

58:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %59 = load ptr, ptr %11, align 8, !tbaa !9
  %60 = ptrtoint ptr %59 to i64
  %61 = add i64 %60, 32
  store i64 %61, ptr %15, align 8, !tbaa !11
  %62 = load i64, ptr %15, align 8, !tbaa !11
  %63 = add i64 %62, 63
  %64 = and i64 %63, -64
  store i64 %64, ptr %15, align 8, !tbaa !11
  %65 = load i64, ptr %15, align 8, !tbaa !11
  %66 = inttoptr i64 %65 to ptr
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = mul nsw i32 %67, %68
  %70 = load i32, ptr %13, align 4, !tbaa !5
  %71 = mul nsw i32 %69, %70
  %72 = sext i32 %71 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %66, i8 0, i64 %72, i1 false)
  %73 = load i64, ptr %15, align 8, !tbaa !11
  %74 = inttoptr i64 %73 to ptr
  %75 = load ptr, ptr %11, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %75, i32 0, i32 5
  store ptr %74, ptr %76, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  br label %81

77:                                               ; preds = %55
  %78 = load ptr, ptr %10, align 8, !tbaa !9
  %79 = load ptr, ptr %11, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %79, i32 0, i32 5
  store ptr %78, ptr %80, align 8, !tbaa !13
  br label %81

81:                                               ; preds = %77, %58
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = load ptr, ptr %11, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %83, i32 0, i32 0
  store i32 %82, ptr %84, align 8, !tbaa !15
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = load ptr, ptr %11, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %86, i32 0, i32 1
  store i32 %85, ptr %87, align 4, !tbaa !16
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = load ptr, ptr %11, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %89, i32 0, i32 2
  store i32 %88, ptr %90, align 8, !tbaa !17
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = load ptr, ptr %11, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %92, i32 0, i32 3
  store i32 %91, ptr %93, align 4, !tbaa !18
  %94 = load i32, ptr %13, align 4, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !9
  %96 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %95, i32 0, i32 4
  store i32 %94, ptr %96, align 8, !tbaa !19
  %97 = load ptr, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  ret ptr %97
}

; 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, ...) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_elemsize(i32 noundef) #4

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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 = { "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 = { noreturn 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 #4 = { inlinehint 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 #5 = { nounwind allocsize(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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

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


; 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 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @create_simple_mat_with_data(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp sgt i32 %0, 0
  %7 = icmp sgt i32 %1, 0
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %12, label %8

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #6
  unreachable

12:                                               ; preds = %5
  %13 = tail call i32 @get_elemsize(i32 noundef %2)
  %14 = icmp eq ptr %4, null
  br i1 %14, label %15, label %.thread

15:                                               ; preds = %12
  %16 = mul nuw nsw i32 %1, %0
  %17 = mul i32 %16, %3
  %18 = mul i32 %17, %13
  %19 = add nsw i32 %18, 96
  %20 = sext i32 %19 to i64
  %21 = tail call noalias ptr @malloc(i64 noundef %20) #7
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %23, label %27

.thread:                                          ; preds = %12
  %22 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
  %.not39 = icmp eq ptr %22, null
  br i1 %.not39, label %23, label %.thread40

23:                                               ; preds = %.thread, %15
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #6
  unreachable

27:                                               ; preds = %15
  %28 = ptrtoint ptr %21 to i64
  %29 = add i64 %28, 95
  %30 = and i64 %29, -64
  %31 = inttoptr i64 %30 to ptr
  %32 = mul nsw i32 %16, %13
  %33 = sext i32 %32 to i64
  tail call void @llvm.memset.p0.i64(ptr align 64 %31, i8 0, i64 %33, i1 false)
  br label %.thread40

.thread40:                                        ; preds = %.thread, %27
  %.sink42 = phi ptr [ %21, %27 ], [ %22, %.thread ]
  %.sink = phi ptr [ %31, %27 ], [ %4, %.thread ]
  %34 = getelementptr inbounds i8, ptr %.sink42, i64 24
  store ptr %.sink, ptr %34, align 8, !tbaa !5
  store i32 %0, ptr %.sink42, align 8, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %.sink42, i64 4
  store i32 %1, ptr %35, align 4, !tbaa !12
  %36 = getelementptr inbounds i8, ptr %.sink42, i64 8
  store i32 %2, ptr %36, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %.sink42, i64 12
  store i32 %3, ptr %37, align 4, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %.sink42, i64 16
  store i32 %13, ptr %38, align 8, !tbaa !15
  ret ptr %.sink42
}

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_elemsize(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { 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 #1 = { 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 #2 = { noreturn 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 #3 = { inlinehint 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !10, i64 24}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24}
!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 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 12}
!15 = !{!6, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass