; LLVM IR from XiaoMi/mace :: micro/ops/bias_add.ll (ZN5micro3ops9BiasAddOp3RunEv)

; 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::BiasAddOp" = type { %"class.micro::framework::Operator", ptr, ptr, i32, ptr, ptr, i32, ptr }
%"class.micro::framework::Operator" = type { ptr, ptr, ptr, ptr }

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

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(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops9BiasAddOp3RunEv(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.micro::base::Logger", align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %10 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 3
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = call noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %9, i32 noundef 0, i32 noundef %11, ptr noundef %13)
  store i32 %14, ptr %4, align 4, !tbaa !14
  %15 = load i32, ptr %4, align 4, !tbaa !14
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %36

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef @.str.1, i32 noundef 46, i32 noundef 1)
  %18 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = invoke noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %9, i32 noundef 0, i32 noundef %19, ptr noundef %21)
          to label %23 unwind label %32

23:                                               ; preds = %17
  %24 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef %22)
          to label %25 unwind label %32

25:                                               ; preds = %23
  %26 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %24, ptr noundef @.str.8)
          to label %27 unwind label %32

27:                                               ; preds = %25
  %28 = load i32, ptr %4, align 4, !tbaa !14
  %29 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %26, i32 noundef %28)
          to label %30 unwind label %32

30:                                               ; preds = %27
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %31 = load i32, ptr %4, align 4, !tbaa !14
  store i32 %31, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %37

32:                                               ; preds = %27, %25, %23, %17
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %6, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %7, align 4
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %57

36:                                               ; preds = %1
  store i32 0, ptr %8, align 4
  br label %37

37:                                               ; preds = %36, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %38 = load i32, ptr %8, align 4
  switch i32 %38, label %62 [
    i32 0, label %39
    i32 1, label %55
  ]

39:                                               ; preds = %37
  %40 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 3
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = getelementptr inbounds i32, ptr %49, i64 0
  %51 = load i32, ptr %50, align 4, !tbaa !19
  %52 = getelementptr inbounds %"class.micro::ops::BiasAddOp", ptr %9, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = call noundef i32 @_ZN5micro3ops5crumb11ComputeBiasEPKfPKijS3_iPf(ptr noundef %41, ptr noundef %43, i32 noundef %45, ptr noundef %47, i32 noundef %51, ptr noundef %53)
  store i32 %54, ptr %2, align 4
  br label %55

55:                                               ; preds = %39, %37
  %56 = load i32, ptr %2, align 4
  ret i32 %56

57:                                               ; preds = %32
  %58 = load ptr, ptr %6, align 8
  %59 = load i32, ptr %7, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61

62:                                               ; preds = %37
  unreachable
}

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

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

declare noundef i32 @_ZN5micro3ops5crumb11ComputeBiasEPKfPKijS3_iPf(ptr noundef, ptr noundef, i32 noundef, ptr 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 = { 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 = { 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 }

!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, !12, i64 48}
!10 = !{!"_ZTSN5micro3ops9BiasAddOpE", !11, i64 0, !6, i64 32, !6, i64 40, !12, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !6, i64 80}
!11 = !{!"_ZTSN5micro9framework8OperatorE", !6, i64 8, !6, i64 16, !6, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 40}
!14 = !{!15, !15, i64 0}
!15 = !{!"_ZTSN5micro10MaceStatusE", !7, i64 0}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !6, i64 56}
!18 = !{!10, !6, i64 64}
!19 = !{!12, !12, i64 0}
!20 = !{!10, !6, i64 80}


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

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

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(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5micro3ops9BiasAddOp3RunEv(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.micro::base::Logger", align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = tail call noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0, i32 noundef %4, ptr noundef %6)
  %.not.not = icmp eq i32 %7, 0
  br i1 %.not.not, label %21, label %8

8:                                                ; preds = %1
  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 46, i32 noundef 1)
  %9 = load i32, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !12
  %11 = invoke noundef i32 @_ZN5micro9framework8Operator17ResizeOutputShapeEjjPKi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0, i32 noundef %9, ptr noundef %10)
          to label %12 unwind label %18

12:                                               ; preds = %8
  %13 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %11)
          to label %14 unwind label %18

14:                                               ; preds = %12
  %15 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull @.str.8)
          to label %16 unwind label %18

16:                                               ; preds = %14
  %17 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEi(ptr noundef nonnull align 4 dereferenceable(4) %15, i32 noundef %7)
          to label %20 unwind label %18

18:                                               ; preds = %16, %14, %12, %8
  %19 = 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 } %19

20:                                               ; preds = %16
  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 %34

21:                                               ; preds = %1
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load ptr, ptr %5, align 8, !tbaa !12
  %25 = load i32, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %0, i64 64
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = tail call noundef i32 @_ZN5micro3ops5crumb11ComputeBiasEPKfPKijS3_iPf(ptr noundef %23, ptr noundef %24, i32 noundef %25, ptr noundef %27, i32 noundef %30, ptr noundef %32)
  br label %34

34:                                               ; preds = %20, %21
  %.1 = phi i32 [ %7, %20 ], [ %33, %21 ]
  ret i32 %.1
}

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

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

declare noundef i32 @_ZN5micro3ops5crumb11ComputeBiasEPKfPKijS3_iPf(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 "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 = { 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 }

!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 = !{!"_ZTSN5micro3ops9BiasAddOpE", !7, i64 0, !8, i64 32, !8, i64 40, !11, i64 48, !8, i64 56, !8, i64 64, !11, i64 72, !8, i64 80}
!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, !8, i64 32}
!14 = !{!6, !8, i64 56}
!15 = !{!6, !8, i64 64}
!16 = !{!11, !11, i64 0}
!17 = !{!6, !8, i64 80}


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