; LLVM IR from XiaoMi/mace :: micro/ops/squeeze.ll (ZN5micro3ops9SqueezeOp3RunEv)

; 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::ops::SqueezeOp" = type <{ %"class.micro::framework::Operator", ptr, ptr, i32, [4 x i8], ptr, ptr, i32, [4 x i8], ptr, i32, [4 x i8] }>
%"class.micro::framework::Operator" = type { ptr, ptr, ptr, ptr }

; 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 void @_ZN5micro4base6memcpyEPvPKvj(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops9SqueezeOp3RunEv(ptr noundef nonnull align 8 dereferenceable(92) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %82, %1
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 3
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp ult i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %85

16:                                               ; preds = %10
  %17 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %18, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp sgt i32 %22, 1
  br i1 %23, label %24, label %37

24:                                               ; preds = %16
  %25 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %26, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 9
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !9
  %35 = sext i32 %33 to i64
  %36 = getelementptr inbounds i32, ptr %32, i64 %35
  store i32 %30, ptr %36, align 4, !tbaa !9
  br label %81

37:                                               ; preds = %16
  %38 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 7
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = icmp ugt i32 %39, 0
  br i1 %40, label %41, label %80

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  store i8 0, ptr %6, align 1, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %59, %41
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 7
  %45 = load i32, ptr %44, align 8, !tbaa !17
  %46 = icmp ult i32 %43, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  store i32 5, ptr %5, align 4
  br label %62

48:                                               ; preds = %42
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = icmp eq i32 %49, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %48
  store i8 1, ptr %6, align 1, !tbaa !18
  store i32 5, ptr %5, align 4
  br label %62

58:                                               ; preds = %48
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = add i32 %60, 1
  store i32 %61, ptr %7, align 4, !tbaa !9
  br label %42, !llvm.loop !21

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

63:                                               ; preds = %62
  %64 = load i8, ptr %6, align 1, !tbaa !18, !range !23, !noundef !24
  %65 = trunc i8 %64 to i1
  br i1 %65, label %79, label %66

66:                                               ; preds = %63
  %67 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %68, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 9
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %3, align 4, !tbaa !9
  %77 = sext i32 %75 to i64
  %78 = getelementptr inbounds i32, ptr %74, i64 %77
  store i32 %72, ptr %78, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %66, %63
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %80

80:                                               ; preds = %79, %37
  br label %81

81:                                               ; preds = %80, %24
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %4, align 4, !tbaa !9
  %84 = add i32 %83, 1
  store i32 %84, ptr %4, align 4, !tbaa !9
  br label %10, !llvm.loop !25

85:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %86 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 3
  %87 = load i32, ptr %86, align 8, !tbaa !11
  %88 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = call noundef i32 @_ZN5micro4base12GetShapeSizeEjPKi(i32 noundef %87, ptr noundef %89)
  store i32 %90, ptr %8, align 4, !tbaa !9
  %91 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !26
  %93 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 1
  %94 = load ptr, ptr %93, align 8, !tbaa !27
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = mul i64 %96, 4
  %98 = trunc i64 %97 to i32
  call void @_ZN5micro4base6memcpyEPvPKvj(ptr noundef %92, ptr noundef %94, i32 noundef %98)
  %99 = load i32, ptr %3, align 4, !tbaa !9
  %100 = getelementptr inbounds %"class.micro::ops::SqueezeOp", ptr %9, i32 0, i32 9
  %101 = load ptr, ptr %100, align 8, !tbaa !16
  %102 = call noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %9, i32 noundef 0, i32 noundef %99, ptr noundef %101)
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %102
}

declare noundef i32 @_ZN5micro4base12GetShapeSizeEjPKi(i32 noundef, ptr noundef) #1

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

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 = { 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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"_ZTSN5micro3ops9SqueezeOpE", !13, i64 0, !6, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !6, i64 80, !14, i64 88}
!13 = !{!"_ZTSN5micro9framework8OperatorE", !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"_ZTSN5micro10DataFormatE", !7, i64 0}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !6, i64 80}
!17 = !{!12, !10, i64 72}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!12, !6, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = distinct !{!25, !22}
!26 = !{!12, !6, i64 56}
!27 = !{!12, !6, i64 32}


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

declare void @_ZN5micro4base6memcpyEPvPKvj(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops9SqueezeOp3RunEv(ptr noundef nonnull align 8 dereferenceable(92) %0) unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not23 = icmp eq i32 %3, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 40
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = load ptr, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8
  br label %18

._crit_edge:                                      ; preds = %.loopexit, %1
  %.0.lcssa = phi i32 [ 0, %1 ], [ %.2, %.loopexit ]
  %.lcssa = phi i32 [ 0, %1 ], [ %32, %.loopexit ]
  %9 = tail call noundef i32 @_ZN5micro4base12GetShapeSizeEjPKi(i32 noundef %.lcssa, ptr noundef %.pre)
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = shl i32 %9, 2
  tail call void @_ZN5micro4base6memcpyEPvPKvj(ptr noundef %11, ptr noundef %13, i32 noundef %14)
  %15 = getelementptr inbounds i8, ptr %0, i64 80
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = tail call noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0, i32 noundef %.0.lcssa, ptr noundef %16)
  ret i32 %17

18:                                               ; preds = %.lr.ph, %.loopexit
  %indvars.iv26 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next27, %.loopexit ]
  %.021 = phi i32 [ 0, %.lr.ph ], [ %.2, %.loopexit ]
  %19 = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv26
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = icmp sgt i32 %20, 1
  br i1 %21, label %.loopexit.sink.split, label %22

22:                                               ; preds = %18
  %23 = load i32, ptr %4, align 8, !tbaa !18
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %22
  %wide.trip.count = zext i32 %23 to i64
  br label %.preheader

24:                                               ; preds = %.preheader
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit.sink.split, label %.preheader, !llvm.loop !19

.preheader:                                       ; preds = %.preheader.preheader, %24
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %24 ]
  %25 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !17
  %27 = zext i32 %26 to i64
  %28 = icmp eq i64 %indvars.iv26, %27
  br i1 %28, label %.loopexit, label %24

.loopexit.sink.split:                             ; preds = %24, %18
  %29 = add nsw i32 %.021, 1
  %30 = sext i32 %.021 to i64
  %31 = getelementptr inbounds i32, ptr %8, i64 %30
  store i32 %20, ptr %31, align 4, !tbaa !17
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split, %22
  %.2 = phi i32 [ %.021, %22 ], [ %29, %.loopexit.sink.split ], [ %.021, %.preheader ]
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %32 = load i32, ptr %2, align 8, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = icmp ult i64 %indvars.iv.next27, %33
  br i1 %34, label %18, label %._crit_edge, !llvm.loop !21
}

declare noundef i32 @_ZN5micro4base12GetShapeSizeEjPKi(i32 noundef, ptr noundef) local_unnamed_addr #0

declare noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

!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, !11, i64 48}
!6 = !{!"_ZTSN5micro3ops9SqueezeOpE", !7, i64 0, !8, i64 32, !8, i64 40, !11, i64 48, !8, i64 56, !8, i64 64, !11, i64 72, !8, i64 80, !12, i64 88}
!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 = !{!"_ZTSN5micro10DataFormatE", !9, i64 0}
!13 = !{!6, !8, i64 40}
!14 = !{!6, !8, i64 56}
!15 = !{!6, !8, i64 32}
!16 = !{!6, !8, i64 80}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 72}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass