; LLVM IR from XiaoMi/mace :: micro/framework/operator.ll (ZN5micro9framework8Operator21GetOutputQuantizeInfoEj)

; 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.micro::QuantizeInfo" = type { float, i32 }
%"class.micro::base::Logger" = type { i32 }
%"class.micro::model::QuantizeActivationInfo" = type { float, i32, float, float }
%"class.micro::framework::Operator" = type { ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [37 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
declare dso_local noundef i32 @_ZN5micro9framework8Operator13GetOutputSizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

declare { i64, <2 x float> } @_ZNK5micro5model11OperatorDef13quantize_infoEj(ptr noundef nonnull align 4 dereferenceable(76), i32 noundef) #1

declare noundef float @_ZNK5micro5model22QuantizeActivationInfo5scaleEv(ptr noundef nonnull align 4 dereferenceable(16)) #1

declare noundef i32 @_ZNK5micro5model22QuantizeActivationInfo10zero_pointEv(ptr noundef nonnull align 4 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN5micro9framework8Operator21GetOutputQuantizeInfoEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.micro::QuantizeInfo", align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.micro::base::Logger", align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.micro::model::QuantizeActivationInfo", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = call noundef i32 @_ZN5micro9framework8Operator13GetOutputSizeEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
  %13 = icmp ult i32 %11, %12
  br i1 %13, label %21, label %14

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef @.str, i32 noundef 250, i32 noundef 4)
  %15 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef @.str.9)
          to label %16 unwind label %17

16:                                               ; preds = %14
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %21

17:                                               ; preds = %14
  %18 = landingpad { ptr, i32 }
          cleanup
  %19 = extractvalue { ptr, i32 } %18, 0
  store ptr %19, ptr %7, align 8
  %20 = extractvalue { ptr, i32 } %18, 1
  store i32 %20, ptr %8, align 4
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %35

21:                                               ; preds = %16, %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  %22 = getelementptr inbounds %"class.micro::framework::Operator", ptr %10, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = call { i64, <2 x float> } @_ZNK5micro5model11OperatorDef13quantize_infoEj(ptr noundef nonnull align 4 dereferenceable(76) %23, i32 noundef %24)
  %26 = getelementptr inbounds { i64, <2 x float> }, ptr %9, i32 0, i32 0
  %27 = extractvalue { i64, <2 x float> } %25, 0
  store i64 %27, ptr %26, align 4
  %28 = getelementptr inbounds { i64, <2 x float> }, ptr %9, i32 0, i32 1
  %29 = extractvalue { i64, <2 x float> } %25, 1
  store <2 x float> %29, ptr %28, align 4
  %30 = call noundef float @_ZNK5micro5model22QuantizeActivationInfo5scaleEv(ptr noundef nonnull align 4 dereferenceable(16) %9)
  %31 = getelementptr inbounds %"struct.micro::QuantizeInfo", ptr %3, i32 0, i32 0
  store float %30, ptr %31, align 4, !tbaa !13
  %32 = call noundef i32 @_ZNK5micro5model22QuantizeActivationInfo10zero_pointEv(ptr noundef nonnull align 4 dereferenceable(16) %9)
  %33 = getelementptr inbounds %"struct.micro::QuantizeInfo", ptr %3, i32 0, i32 1
  store i32 %32, ptr %33, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  %34 = load i64, ptr %3, align 4
  ret i64 %34

35:                                               ; preds = %17
  %36 = load ptr, ptr %7, align 8
  %37 = load i32, ptr %8, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 }

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


; 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 }
%"class.micro::model::QuantizeActivationInfo" = type { float, i32, float, float }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [37 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
declare dso_local noundef i32 @_ZN5micro9framework8Operator13GetOutputSizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

declare { i64, <2 x float> } @_ZNK5micro5model11OperatorDef13quantize_infoEj(ptr noundef nonnull align 4 dereferenceable(76), i32 noundef) local_unnamed_addr #1

declare noundef float @_ZNK5micro5model22QuantizeActivationInfo5scaleEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1

declare noundef i32 @_ZNK5micro5model22QuantizeActivationInfo10zero_pointEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN5micro9framework8Operator21GetOutputQuantizeInfoEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.micro::base::Logger", align 4
  %4 = alloca %"class.micro::model::QuantizeActivationInfo", align 8
  %5 = tail call noundef i32 @_ZN5micro9framework8Operator13GetOutputSizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %6 = icmp ugt i32 %5, %1
  br i1 %6, label %12, label %7

7:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @_ZN5micro4base6LoggerC1EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull @.str, i32 noundef 250, i32 noundef 4)
  %8 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5micro4base6LoggerlsEPKc(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull @.str.9)
          to label %9 unwind label %10

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

10:                                               ; preds = %7
  %11 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5micro4base6LoggerD1Ev(ptr noundef nonnull align 4 dereferenceable(4) %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  resume { ptr, i32 } %11

12:                                               ; preds = %9, %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = call { i64, <2 x float> } @_ZNK5micro5model11OperatorDef13quantize_infoEj(ptr noundef nonnull align 4 dereferenceable(76) %14, i32 noundef %1)
  %16 = extractvalue { i64, <2 x float> } %15, 0
  store i64 %16, ptr %4, align 8
  %17 = getelementptr inbounds i8, ptr %4, i64 8
  %18 = extractvalue { i64, <2 x float> } %15, 1
  store <2 x float> %18, ptr %17, align 8
  %19 = call noundef float @_ZNK5micro5model22QuantizeActivationInfo5scaleEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %20 = call noundef i32 @_ZNK5micro5model22QuantizeActivationInfo10zero_pointEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  %21 = bitcast float %19 to i32
  %.sroa.2.0.insert.ext = zext i32 %20 to i64
  %.sroa.2.0.insert.shift = shl nuw i64 %.sroa.2.0.insert.ext, 32
  %.sroa.0.0.insert.ext = zext i32 %21 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  ret i64 %.sroa.0.0.insert.insert
}

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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 }

!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, !7, i64 8}
!6 = !{!"_ZTSN5micro9framework8OperatorE", !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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