; LLVM IR from huawei-noah/bolt :: common/model_spec/src/model_deserialize.ll (Z19model_compatibilityP12OperatorSpeci)

; 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.OperatorSpec = type <{ [128 x i8], i32, i32, ptr, i32, [4 x i8], ptr, ptr, i32, [4 x i8], ptr, %union.ParameterSpec, [4 x i8] }>
%union.ParameterSpec = type { %struct.MultiHeadAttentionParamSpec }
%struct.MultiHeadAttentionParamSpec = type { [6 x %struct.FullyConnectedParamSpec], %struct.PowerParamSpec, [2 x i8], i32, [4 x %struct.ReshapeParamSpec], [2 x %struct.EltwiseParamSpec] }
%struct.FullyConnectedParamSpec = type { i32, i32, [32 x i32] }
%struct.PowerParamSpec = type { float, float, float }
%struct.ReshapeParamSpec = type { [8 x i32], i32, i32, i32 }
%struct.EltwiseParamSpec = type { i32, %struct.EltwiseSumSpec, i32, %union.ActivationSpec }
%struct.EltwiseSumSpec = type { [8 x float], i32 }
%union.ActivationSpec = type { %struct.ClipParamSpec }
%struct.ClipParamSpec = type { float, float }
%struct.ConvolutionParamSpec = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %union.ActivationSpec, i32, i32, i32, i32 }
%struct.LayerNormParamSpec = type { i32, float }
%struct.TransposeParamSpec = type { [8 x i32], i32, i32 }
%struct.PoolingParamSpec = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8 }
%struct.ResizeParamSpec = type { [2 x i32], [4 x float], i32, i32, i32, i32, i32, float, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z19model_compatibilityP12OperatorSpeci(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = icmp eq i32 %5, 20201120
  br i1 %6, label %7, label %37

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.OperatorSpec, ptr %8, i32 0, i32 1
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %17, label %12

12:                                               ; preds = %7
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.OperatorSpec, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp eq i32 %15, 3
  br i1 %16, label %17, label %27

17:                                               ; preds = %12, %7
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.OperatorSpec, ptr %18, i32 0, i32 11
  %20 = getelementptr inbounds %struct.ConvolutionParamSpec, ptr %19, i32 0, i32 23
  store i32 0, ptr %20, align 8, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.OperatorSpec, ptr %21, i32 0, i32 11
  %23 = getelementptr inbounds %struct.ConvolutionParamSpec, ptr %22, i32 0, i32 24
  store i32 0, ptr %23, align 4, !tbaa !14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.OperatorSpec, ptr %24, i32 0, i32 11
  %26 = getelementptr inbounds %struct.ConvolutionParamSpec, ptr %25, i32 0, i32 25
  store i32 0, ptr %26, align 8, !tbaa !14
  br label %27

27:                                               ; preds = %17, %12
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.OperatorSpec, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = icmp eq i32 %30, 13
  br i1 %31, label %32, label %36

32:                                               ; preds = %27
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.OperatorSpec, ptr %33, i32 0, i32 11
  %35 = getelementptr inbounds %struct.LayerNormParamSpec, ptr %34, i32 0, i32 0
  store i32 -1, ptr %35, align 8, !tbaa !14
  br label %36

36:                                               ; preds = %32, %27
  br label %37

37:                                               ; preds = %36, %2
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 20201120
  br i1 %39, label %43, label %40

40:                                               ; preds = %37
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 20211021
  br i1 %42, label %43, label %53

43:                                               ; preds = %40, %37
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.OperatorSpec, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !11
  %47 = icmp eq i32 %46, 41
  br i1 %47, label %48, label %52

48:                                               ; preds = %43
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.OperatorSpec, ptr %49, i32 0, i32 11
  %51 = getelementptr inbounds %struct.TransposeParamSpec, ptr %50, i32 0, i32 2
  store i32 0, ptr %51, align 4, !tbaa !14
  br label %52

52:                                               ; preds = %48, %43
  br label %53

53:                                               ; preds = %52, %40
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = icmp slt i32 %54, 20220126
  br i1 %55, label %56, label %66

56:                                               ; preds = %53
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.OperatorSpec, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = icmp eq i32 %59, 9
  br i1 %60, label %61, label %65

61:                                               ; preds = %56
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.OperatorSpec, ptr %62, i32 0, i32 11
  %64 = getelementptr inbounds %struct.PoolingParamSpec, ptr %63, i32 0, i32 14
  store i8 0, ptr %64, align 8, !tbaa !14
  br label %65

65:                                               ; preds = %61, %56
  br label %66

66:                                               ; preds = %65, %53
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = icmp slt i32 %67, 20220817
  br i1 %68, label %69, label %85

69:                                               ; preds = %66
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.OperatorSpec, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !11
  %73 = icmp eq i32 %72, 7
  br i1 %73, label %74, label %84

74:                                               ; preds = %69
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.OperatorSpec, ptr %75, i32 0, i32 11
  %77 = getelementptr inbounds %struct.ResizeParamSpec, ptr %76, i32 0, i32 7
  store float 0.000000e+00, ptr %77, align 4, !tbaa !14
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.OperatorSpec, ptr %78, i32 0, i32 11
  %80 = getelementptr inbounds %struct.ResizeParamSpec, ptr %79, i32 0, i32 8
  store i32 0, ptr %80, align 8, !tbaa !14
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.OperatorSpec, ptr %81, i32 0, i32 11
  %83 = getelementptr inbounds %struct.ResizeParamSpec, ptr %82, i32 0, i32 9
  store i32 0, ptr %83, align 4, !tbaa !14
  br label %84

84:                                               ; preds = %74, %69
  br label %85

85:                                               ; preds = %84, %66
  ret i32 0
}

attributes #0 = { mustprogress nounwind 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, !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, !13, i64 128}
!12 = !{!"_ZTS12OperatorSpec", !7, i64 0, !13, i64 128, !10, i64 132, !6, i64 136, !10, i64 144, !6, i64 152, !6, i64 160, !10, i64 168, !6, i64 176, !7, i64 184}
!13 = !{!"_ZTS12OperatorType", !7, i64 0}
!14 = !{!7, !7, i64 0}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @_Z19model_compatibilityP12OperatorSpeci(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  switch i32 %1, label %18 [
    i32 20201120, label %3
    i32 20211021, label %._crit_edge
  ]

._crit_edge:                                      ; preds = %2
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 128
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %14

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = and i32 %5, -2
  %switch = icmp eq i32 %6, 2
  br i1 %switch, label %.thread, label %10

.thread:                                          ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 280
  store i32 0, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 284
  store i32 0, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 288
  store i32 0, ptr %9, align 8, !tbaa !12
  br label %.thread22.thread

10:                                               ; preds = %3
  %11 = icmp eq i32 %5, 13
  br i1 %11, label %12, label %14

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 184
  store i32 -1, ptr %13, align 8, !tbaa !12
  br label %.thread22.thread

14:                                               ; preds = %._crit_edge, %10
  %15 = phi i32 [ %.pre, %._crit_edge ], [ %5, %10 ]
  %16 = icmp eq i32 %15, 41
  br i1 %16, label %.thread20.thread, label %.thread20

.thread20.thread:                                 ; preds = %14
  %17 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 0, ptr %17, align 4, !tbaa !12
  br label %.thread22.thread

18:                                               ; preds = %2
  %19 = icmp slt i32 %1, 20220126
  br i1 %19, label %..thread20_crit_edge, label %24

..thread20_crit_edge:                             ; preds = %18
  %.phi.trans.insert23 = getelementptr inbounds i8, ptr %0, i64 128
  %.pre24 = load i32, ptr %.phi.trans.insert23, align 8, !tbaa !5
  br label %.thread20

.thread20:                                        ; preds = %..thread20_crit_edge, %14
  %20 = phi i32 [ %.pre24, %..thread20_crit_edge ], [ %15, %14 ]
  %21 = icmp eq i32 %20, 9
  br i1 %21, label %22, label %.thread22

22:                                               ; preds = %.thread20
  %23 = getelementptr inbounds i8, ptr %0, i64 240
  store i8 0, ptr %23, align 8, !tbaa !12
  br label %.thread22.thread

24:                                               ; preds = %18
  %25 = icmp ult i32 %1, 20220817
  br i1 %25, label %..thread22_crit_edge, label %.thread22.thread

..thread22_crit_edge:                             ; preds = %24
  %.phi.trans.insert25 = getelementptr inbounds i8, ptr %0, i64 128
  %.pre26 = load i32, ptr %.phi.trans.insert25, align 8, !tbaa !5
  br label %.thread22

.thread22:                                        ; preds = %..thread22_crit_edge, %.thread20
  %26 = phi i32 [ %.pre26, %..thread22_crit_edge ], [ %20, %.thread20 ]
  %27 = icmp eq i32 %26, 7
  br i1 %27, label %28, label %.thread22.thread

28:                                               ; preds = %.thread22
  %29 = getelementptr inbounds i8, ptr %0, i64 228
  store float 0.000000e+00, ptr %29, align 4, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %0, i64 232
  store i32 0, ptr %30, align 8, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %0, i64 236
  store i32 0, ptr %31, align 4, !tbaa !12
  br label %.thread22.thread

.thread22.thread:                                 ; preds = %.thread, %12, %.thread20.thread, %22, %.thread22, %28, %24
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !9, i64 128}
!6 = !{!"_ZTS12OperatorSpec", !7, i64 0, !9, i64 128, !10, i64 132, !11, i64 136, !10, i64 144, !11, i64 152, !11, i64 160, !10, i64 168, !11, i64 176, !7, i64 184}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"_ZTS12OperatorType", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass