; LLVM IR from jrl-umi3218/tvm :: src/internal/MatrixProperties.ll (ZN3tvm8internalplERKNS0_16MatrixProperties5ShapeES4_)

; 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.std::pair.0" = type { ptr, ptr }

@_ZTISt13runtime_error = external constant ptr
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3tvm8internalplERKNS0_16MatrixProperties5ShapeES4_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.std::pair.0", align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call { ptr, ptr } @_ZSt6minmaxIN3tvm8internal16MatrixProperties5ShapeEESt4pairIRKT_S7_ES7_S7_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %13 = getelementptr inbounds { ptr, ptr }, ptr %6, i32 0, i32 0
  %14 = extractvalue { ptr, ptr } %12, 0
  store ptr %14, ptr %13, align 8
  %15 = getelementptr inbounds { ptr, ptr }, ptr %6, i32 0, i32 1
  %16 = extractvalue { ptr, ptr } %12, 1
  store ptr %16, ptr %15, align 8
  %17 = getelementptr inbounds %"struct.std::pair.0", ptr %6, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = load i32, ptr %18, align 4, !tbaa !11
  switch i32 %19, label %52 [
    i32 0, label %20
    i32 1, label %21
    i32 2, label %28
    i32 3, label %29
    i32 4, label %30
    i32 5, label %31
    i32 6, label %44
    i32 7, label %51
  ]

20:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

21:                                               ; preds = %2
  %22 = getelementptr inbounds %"struct.std::pair.0", ptr %6, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = icmp eq i32 %24, 2
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, i32 0, i32 1
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

28:                                               ; preds = %2
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

29:                                               ; preds = %2
  store i32 3, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

30:                                               ; preds = %2
  store i32 4, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

31:                                               ; preds = %2
  %32 = getelementptr inbounds %"struct.std::pair.0", ptr %6, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 5
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i32 4, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

37:                                               ; preds = %31
  %38 = getelementptr inbounds %"struct.std::pair.0", ptr %6, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = icmp eq i32 %40, 6
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  store i32 7, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

43:                                               ; preds = %37
  store i32 5, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

44:                                               ; preds = %2
  %45 = getelementptr inbounds %"struct.std::pair.0", ptr %6, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = icmp eq i32 %47, 6
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, i32 4, i32 6
  store i32 %50, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

51:                                               ; preds = %2
  store i32 7, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %59

52:                                               ; preds = %2
  %53 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %53, ptr noundef @.str.4)
          to label %54 unwind label %55

54:                                               ; preds = %52
  call void @__cxa_throw(ptr %53, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #6
  unreachable

55:                                               ; preds = %52
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %8, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %9, align 4
  call void @__cxa_free_exception(ptr %53) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %61

59:                                               ; preds = %51, %44, %43, %42, %36, %30, %29, %28, %21, %20
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  %60 = load i32, ptr %3, align 4
  ret i32 %60

61:                                               ; preds = %55
  %62 = load ptr, ptr %8, align 8
  %63 = load i32, ptr %9, align 4
  %64 = insertvalue { ptr, i32 } poison, ptr %62, 0
  %65 = insertvalue { ptr, i32 } %64, i32 %63, 1
  resume { ptr, i32 } %65
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { ptr, ptr } @_ZSt6minmaxIN3tvm8internal16MatrixProperties5ShapeEESt4pairIRKT_S7_ES7_S7_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIRKN3tvm8internal16MatrixProperties5ShapeES5_E", !6, i64 0, !6, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN3tvm8internal16MatrixProperties5ShapeE", !7, i64 0}
!13 = !{!10, !6, i64 8}


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

@_ZTISt13runtime_error = external constant ptr
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 8) i32 @_ZN3tvm8internalplERKNS0_16MatrixProperties5ShapeES4_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %3 = tail call { ptr, ptr } @_ZSt6minmaxIN3tvm8internal16MatrixProperties5ShapeEESt4pairIRKT_S7_ES7_S7_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %4 = extractvalue { ptr, ptr } %3, 0
  %5 = extractvalue { ptr, ptr } %3, 1
  %6 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %6, label %17 [
    i32 0, label %22
    i32 1, label %7
    i32 2, label %22
    i32 3, label %22
    i32 4, label %22
    i32 5, label %11
    i32 6, label %13
    i32 7, label %22
  ]

7:                                                ; preds = %2
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 2
  %10 = zext i1 %9 to i32
  br label %22

11:                                               ; preds = %2
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %switch.selectcmp = icmp eq i32 %12, 6
  %switch.select = select i1 %switch.selectcmp, i32 7, i32 5
  %switch.selectcmp8 = icmp eq i32 %12, 5
  %switch.select9 = select i1 %switch.selectcmp8, i32 4, i32 %switch.select
  br label %22

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 6
  %16 = select i1 %15, i32 4, i32 6
  br label %22

17:                                               ; preds = %2
  %18 = tail call ptr @__cxa_allocate_exception(i64 16) #4
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull @.str.4)
          to label %19 unwind label %20

19:                                               ; preds = %17
  tail call void @__cxa_throw(ptr nonnull %18, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #5
  unreachable

20:                                               ; preds = %17
  %21 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %18) #4
  resume { ptr, i32 } %21

22:                                               ; preds = %2, %2, %2, %2, %11, %2, %13, %7
  %.0 = phi i32 [ %16, %13 ], [ %10, %7 ], [ %6, %2 ], [ %switch.select9, %11 ], [ %6, %2 ], [ %6, %2 ], [ %6, %2 ], [ %6, %2 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { ptr, ptr } @_ZSt6minmaxIN3tvm8internal16MatrixProperties5ShapeEESt4pairIRKT_S7_ES7_S7_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

attributes #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 = { 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 = { mustprogress 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 = { inlinehint mustprogress 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 }
attributes #5 = { noreturn }

!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 = !{!"_ZTSN3tvm8internal16MatrixProperties5ShapeE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass