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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18mt_create_operatorPKc12OperatorTypejj(ptr dead_on_unwind noalias writable sret(%struct.OperatorSpec) align 8 %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  store i32 %4, ptr %9, align 4, !tbaa !11
  call void @_ZN12OperatorSpecC2Ev(ptr noundef nonnull align 8 dereferenceable(1300) %0)
  call void @_Z10UNI_MEMSETPvim(ptr noundef %0, i32 noundef 0, i64 noundef 1304)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call i64 @strlen(ptr noundef %13) #6
  %15 = icmp ult i64 %14, 127
  br i1 %15, label %16, label %19

16:                                               ; preds = %5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call i64 @strlen(ptr noundef %17) #6
  br label %20

19:                                               ; preds = %5
  br label %20

20:                                               ; preds = %19, %16
  %21 = phi i64 [ %18, %16 ], [ 127, %19 ]
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %10, align 4, !tbaa !11
  %23 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 0
  %24 = getelementptr inbounds [128 x i8], ptr %23, i64 0, i64 0
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %10, align 4, !tbaa !11
  %27 = call noundef i32 @_Z8str_copyPcPKcii(ptr noundef %24, ptr noundef %25, i32 noundef %26, i32 noundef 128)
  %28 = load i32, ptr %10, align 4, !tbaa !11
  %29 = icmp ult i32 %28, 128
  br i1 %29, label %30, label %35

30:                                               ; preds = %20
  %31 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 0
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds [128 x i8], ptr %31, i64 0, i64 %33
  store i8 0, ptr %34, align 1, !tbaa !13
  br label %35

35:                                               ; preds = %30, %20
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 1
  store i32 %36, ptr %37, align 8, !tbaa !14
  %38 = load i32, ptr %8, align 4, !tbaa !11
  %39 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 2
  store i32 %38, ptr %39, align 4, !tbaa !16
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = zext i32 %40 to i64
  %42 = mul i64 %41, 8
  %43 = trunc i64 %42 to i32
  %44 = call noundef ptr @_Z9mt_mallocj(i32 noundef %43)
  %45 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 3
  store ptr %44, ptr %45, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %58, %35
  %47 = load i32, ptr %11, align 4, !tbaa !11
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = icmp ult i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %61

51:                                               ; preds = %46
  %52 = call noundef ptr @_Z9mt_mallocj(i32 noundef 128)
  %53 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = load i32, ptr %11, align 4, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %54, i64 %56
  store ptr %52, ptr %57, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %51
  %59 = load i32, ptr %11, align 4, !tbaa !11
  %60 = add i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !11
  br label %46, !llvm.loop !18

61:                                               ; preds = %50
  %62 = load i32, ptr %9, align 4, !tbaa !11
  %63 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 4
  store i32 %62, ptr %63, align 8, !tbaa !20
  %64 = load i32, ptr %9, align 4, !tbaa !11
  %65 = zext i32 %64 to i64
  %66 = mul i64 %65, 8
  %67 = trunc i64 %66 to i32
  %68 = call noundef ptr @_Z9mt_mallocj(i32 noundef %67)
  %69 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 6
  store ptr %68, ptr %69, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %82, %61
  %71 = load i32, ptr %12, align 4, !tbaa !11
  %72 = load i32, ptr %9, align 4, !tbaa !11
  %73 = icmp ult i32 %71, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %85

75:                                               ; preds = %70
  %76 = call noundef ptr @_Z9mt_mallocj(i32 noundef 128)
  %77 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 6
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = load i32, ptr %12, align 4, !tbaa !11
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %78, i64 %80
  store ptr %76, ptr %81, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %75
  %83 = load i32, ptr %12, align 4, !tbaa !11
  %84 = add i32 %83, 1
  store i32 %84, ptr %12, align 4, !tbaa !11
  br label %70, !llvm.loop !22

85:                                               ; preds = %74
  %86 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 7
  store ptr null, ptr %86, align 8, !tbaa !23
  %87 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 8
  store i32 0, ptr %87, align 8, !tbaa !24
  %88 = getelementptr inbounds %struct.OperatorSpec, ptr %0, i32 0, i32 10
  store ptr null, ptr %88, align 8, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12OperatorSpecC2Ev(ptr noundef nonnull align 8 dereferenceable(1300)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z10UNI_MEMSETPvim(ptr noundef, i32 noundef, i64 noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8str_copyPcPKcii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z9mt_mallocj(i32 noundef) #1

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

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 = { inlinehint 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 #2 = { inlinehint 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" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind willreturn memory(read) "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 }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"_ZTS12OperatorType", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 128}
!15 = !{!"_ZTS12OperatorSpec", !7, i64 0, !10, i64 128, !12, i64 132, !6, i64 136, !12, i64 144, !6, i64 152, !6, i64 160, !12, i64 168, !6, i64 176, !7, i64 184}
!16 = !{!15, !12, i64 132}
!17 = !{!15, !6, i64 136}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!15, !12, i64 144}
!21 = !{!15, !6, i64 152}
!22 = distinct !{!22, !19}
!23 = !{!15, !6, i64 160}
!24 = !{!15, !12, i64 168}
!25 = !{!15, !6, i64 176}


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

%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 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18mt_create_operatorPKc12OperatorTypejj(ptr dead_on_unwind noalias nonnull writable sret(%struct.OperatorSpec) align 8 %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  tail call void @_ZN12OperatorSpecC2Ev(ptr noundef nonnull align 8 dereferenceable(1300) %0)
  tail call void @_Z10UNI_MEMSETPvim(ptr noundef nonnull %0, i32 noundef 0, i64 noundef 1304)
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %spec.select21 = tail call i64 @llvm.umin.i64(i64 %6, i64 127)
  %spec.select = trunc nuw nsw i64 %spec.select21 to i32
  %7 = tail call noundef i32 @_Z8str_copyPcPKcii(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %spec.select, i32 noundef 128)
  %8 = getelementptr inbounds [128 x i8], ptr %0, i64 0, i64 %spec.select21
  store i8 0, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 128
  store i32 %2, ptr %9, align 8, !tbaa !8
  %10 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 %3, ptr %10, align 4, !tbaa !13
  %11 = shl i32 %3, 3
  %12 = tail call noundef ptr @_Z9mt_mallocj(i32 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr %12, ptr %13, align 8, !tbaa !14
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext i32 %3 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %5
  %14 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %4, ptr %14, align 8, !tbaa !15
  %15 = shl i32 %4, 3
  %16 = tail call noundef ptr @_Z9mt_mallocj(i32 noundef %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 152
  store ptr %16, ptr %17, align 8, !tbaa !16
  %.not27 = icmp eq i32 %4, 0
  br i1 %.not27, label %._crit_edge26, label %.lr.ph25.preheader

.lr.ph25.preheader:                               ; preds = %._crit_edge
  %wide.trip.count32 = zext i32 %4 to i64
  br label %.lr.ph25

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %18 = tail call noundef ptr @_Z9mt_mallocj(i32 noundef 128)
  %19 = load ptr, ptr %13, align 8, !tbaa !14
  %20 = getelementptr inbounds ptr, ptr %19, i64 %indvars.iv
  store ptr %18, ptr %20, align 8, !tbaa !17
  %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 %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge26:                                    ; preds = %.lr.ph25, %._crit_edge
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr null, ptr %21, align 8, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 0, ptr %22, align 8, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %0, i64 176
  store ptr null, ptr %23, align 8, !tbaa !22
  ret void

.lr.ph25:                                         ; preds = %.lr.ph25.preheader, %.lr.ph25
  %indvars.iv29 = phi i64 [ 0, %.lr.ph25.preheader ], [ %indvars.iv.next30, %.lr.ph25 ]
  %24 = tail call noundef ptr @_Z9mt_mallocj(i32 noundef 128)
  %25 = load ptr, ptr %17, align 8, !tbaa !16
  %26 = getelementptr inbounds ptr, ptr %25, i64 %indvars.iv29
  store ptr %24, ptr %26, align 8, !tbaa !17
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count32
  br i1 %exitcond33.not, label %._crit_edge26, label %.lr.ph25, !llvm.loop !23
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12OperatorSpecC2Ev(ptr noundef nonnull align 8 dereferenceable(1300)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z10UNI_MEMSETPvim(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8str_copyPcPKcii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z9mt_mallocj(i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #4

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 = { inlinehint 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 #2 = { inlinehint 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" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 128}
!9 = !{!"_ZTS12OperatorSpec", !6, i64 0, !10, i64 128, !11, i64 132, !12, i64 136, !11, i64 144, !12, i64 152, !12, i64 160, !11, i64 168, !12, i64 176, !6, i64 184}
!10 = !{!"_ZTS12OperatorType", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!9, !11, i64 132}
!14 = !{!9, !12, i64 136}
!15 = !{!9, !11, i64 144}
!16 = !{!9, !12, i64 152}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!9, !12, i64 160}
!21 = !{!9, !11, i64 168}
!22 = !{!9, !12, i64 176}
!23 = distinct !{!23, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass