; LLVM IR from XiaoMi/mace :: micro/ops/expand_dims.ll (ZN5micro3ops12ExpandDimsOp6OnInitEv)

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

%"class.micro::base::Logger" = type { i32 }
%"class.micro::ops::ExpandDimsOp" = type <{ %"class.micro::framework::Operator", ptr, ptr, i32, [4 x i8], ptr, i32, [4 x i8] }>
%"class.micro::framework::Operator" = type { ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops12ExpandDimsOp6OnInitEv(ptr noundef nonnull align 8 dereferenceable(68) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.micro::base::Logger", align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = call noundef ptr @_ZN5micro9framework8Operator12GetInputDataIfEEPKT_j(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef 0)
  %8 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 1
  store ptr %7, ptr %8, align 8, !tbaa !9
  %9 = call noundef ptr @_ZN5micro9framework8Operator17GetInputShapeDimsEj(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef 0)
  %10 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 2
  store ptr %9, ptr %10, align 8, !tbaa !13
  %11 = call noundef i32 @_ZN5micro9framework8Operator20GetInputShapeDimSizeEj(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef 0)
  %12 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 3
  store i32 %11, ptr %12, align 8, !tbaa !14
  %13 = call noundef ptr @_ZN5micro9framework8Operator13GetOutputDataIfEEPT_j(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef 0)
  %14 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 5
  store ptr %13, ptr %14, align 8, !tbaa !15
  %15 = call noundef i32 @_ZNK5micro9framework8Operator12GetArgByNameIiEET_PKcS3_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef @.str, i32 noundef 0)
  %16 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  store i32 %15, ptr %16, align 8, !tbaa !16
  %17 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %20, label %27

20:                                               ; preds = %1
  %21 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = add i32 %22, 1
  %24 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = add i32 %25, %23
  store i32 %26, ptr %24, align 8, !tbaa !16
  br label %27

27:                                               ; preds = %20, %1
  %28 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = icmp sge i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %27
  %32 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 3
  %35 = load i32, ptr %34, align 8, !tbaa !14
  %36 = icmp sle i32 %33, %35
  br i1 %36, label %50, label %37

37:                                               ; preds = %31, %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef @.str.1, i32 noundef 36, i32 noundef 4)
  %38 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef @.str.2)
          to label %39 unwind label %46

39:                                               ; preds = %37
  %40 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %38, ptr noundef @.str.3)
          to label %41 unwind label %46

41:                                               ; preds = %39
  %42 = getelementptr inbounds %"class.micro::ops::ExpandDimsOp", ptr %6, i32 0, i32 6
  %43 = load i32, ptr %42, align 8, !tbaa !16
  %44 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %40, i32 noundef %43)
          to label %45 unwind label %46

45:                                               ; preds = %41
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %50

46:                                               ; preds = %41, %39, %37
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %4, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %5, align 4
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %51

50:                                               ; preds = %45, %31
  ret i32 0

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8
  %53 = load i32, ptr %5, align 4
  %54 = insertvalue { ptr, i32 } poison, ptr %52, 0
  %55 = insertvalue { ptr, i32 } %54, i32 %53, 1
  resume { ptr, i32 } %55
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro9framework8Operator12GetInputDataIfEEPKT_j(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #0 align 2

declare noundef ptr @_ZN5micro9framework8Operator17GetInputShapeDimsEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1

declare noundef i32 @_ZN5micro9framework8Operator20GetInputShapeDimSizeEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro9framework8Operator13GetOutputDataIfEEPT_j(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #0 align 2

declare noundef i32 @_ZNK5micro9framework8Operator12GetArgByNameIiEET_PKcS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i32 noundef) #1

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

declare void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i32 noundef, i32 noundef) unnamed_addr #1

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef) #1

declare i32 @__gxx_personality_v0(...)

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1

; Function Attrs: nounwind
declare void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"_ZTSN5micro3ops12ExpandDimsOpE", !11, i64 0, !6, i64 32, !6, i64 40, !12, i64 48, !6, i64 56, !12, i64 64}
!11 = !{!"_ZTSN5micro9framework8OperatorE", !6, i64 8, !6, i64 16, !6, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 40}
!14 = !{!10, !12, i64 48}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !12, i64 64}


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

%"class.micro::base::Logger" = type { i32 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops12ExpandDimsOp6OnInitEv(ptr noundef nonnull align 8 dereferenceable(68) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.micro::base::Logger", align 4
  %3 = tail call noundef ptr @_ZN5micro9framework8Operator12GetInputDataIfEEPKT_j(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0)
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %3, ptr %4, align 8, !tbaa !5
  %5 = tail call noundef ptr @_ZN5micro9framework8Operator17GetInputShapeDimsEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0)
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %5, ptr %6, align 8, !tbaa !12
  %7 = tail call noundef i32 @_ZN5micro9framework8Operator20GetInputShapeDimSizeEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0)
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %7, ptr %8, align 8, !tbaa !13
  %9 = tail call noundef ptr @_ZN5micro9framework8Operator13GetOutputDataIfEEPT_j(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0)
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %9, ptr %10, align 8, !tbaa !14
  %11 = tail call noundef i32 @_ZNK5micro9framework8Operator12GetArgByNameIiEET_PKcS3_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull @.str, i32 noundef 0)
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %11, ptr %12, align 8, !tbaa !15
  %13 = icmp slt i32 %11, 0
  %.pre = load i32, ptr %8, align 8
  br i1 %13, label %14, label %17

14:                                               ; preds = %1
  %15 = add nsw i32 %11, 1
  %16 = add i32 %15, %.pre
  store i32 %16, ptr %12, align 8, !tbaa !15
  br label %17

17:                                               ; preds = %14, %1
  %18 = phi i32 [ %16, %14 ], [ %11, %1 ]
  %19 = icmp slt i32 %18, 0
  %.not = icmp sgt i32 %18, %.pre
  %or.cond = select i1 %19, i1 true, i1 %.not
  br i1 %or.cond, label %20, label %30

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull @.str.1, i32 noundef 36, i32 noundef 4)
  %21 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull @.str.2)
          to label %22 unwind label %28

22:                                               ; preds = %20
  %23 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull @.str.3)
          to label %24 unwind label %28

24:                                               ; preds = %22
  %25 = load i32, ptr %12, align 8, !tbaa !15
  %26 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef %25)
          to label %27 unwind label %28

27:                                               ; preds = %24
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %30

28:                                               ; preds = %24, %22, %20
  %29 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  resume { ptr, i32 } %29

30:                                               ; preds = %17, %27
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro9framework8Operator12GetInputDataIfEEPKT_j(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

declare noundef ptr @_ZN5micro9framework8Operator17GetInputShapeDimsEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZN5micro9framework8Operator20GetInputShapeDimSizeEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro9framework8Operator13GetOutputDataIfEEPT_j(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

declare noundef i32 @_ZNK5micro9framework8Operator12GetArgByNameIiEET_PKcS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i32 noundef, i32 noundef) unnamed_addr #1

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3

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

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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, !8, i64 32}
!6 = !{!"_ZTSN5micro3ops12ExpandDimsOpE", !7, i64 0, !8, i64 32, !8, i64 40, !11, i64 48, !8, i64 56, !11, i64 64}
!7 = !{!"_ZTSN5micro9framework8OperatorE", !8, i64 8, !8, i64 16, !8, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !8, i64 40}
!13 = !{!6, !11, i64 48}
!14 = !{!6, !8, i64 56}
!15 = !{!6, !11, i64 64}


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