; LLVM IR from NVIDIA/TensorRT :: plugin/disentangledAttentionPlugin (disentangledAttentionPlugin)

; 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.nvinfer1::PluginTensorDesc" = type { %"class.nvinfer1::Dims64", i32, i32, float }
%"class.nvinfer1::Dims64" = type { i32, [8 x i64] }

@.str.4 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [38 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin27DisentangledAttentionPlugin25supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %12 = load ptr, ptr %6, align 8
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %21

15:                                               ; preds = %5
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = add nsw i32 %17, %18
  %20 = icmp slt i32 %16, %19
  br i1 %20, label %23, label %21

21:                                               ; preds = %15, %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 162)
          to label %22 unwind label %72

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22, %15
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %24, i64 %26
  %28 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %30, i64 0
  %32 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = icmp eq i32 %29, %33
  %35 = zext i1 %34 to i8
  store i8 %35, ptr %11, align 1, !tbaa !17
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %36, i64 %38
  %40 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = icmp eq i32 %41, 2
  br i1 %42, label %59, label %43

43:                                               ; preds = %23
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %44, i64 %46
  %48 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %59, label %51

51:                                               ; preds = %43
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %52, i64 %54
  %56 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !11
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %70

59:                                               ; preds = %51, %43, %23
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %60, i64 %62
  %64 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !19
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %70

67:                                               ; preds = %59
  %68 = load i8, ptr %11, align 1, !tbaa !17, !range !20, !noundef !21
  %69 = trunc i8 %68 to i1
  br label %70

70:                                               ; preds = %67, %59, %51
  %71 = phi i1 [ false, %59 ], [ false, %51 ], [ %69, %67 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  ret i1 %71

72:                                               ; preds = %21
  %73 = landingpad { ptr, i32 }
          catch ptr null
  %74 = extractvalue { ptr, i32 } %73, 0
  call void @__clang_call_terminate(ptr %74) #5
  unreachable
}

declare void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef, ptr noundef, i32 noundef) #3

attributes #0 = { noinline noreturn nounwind uwtable "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 }
attributes #5 = { noreturn 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, !14, i64 72}
!12 = !{!"_ZTSN8nvinfer116PluginTensorDescE", !13, i64 0, !14, i64 72, !15, i64 76, !16, i64 80}
!13 = !{!"_ZTSN8nvinfer16Dims64E", !10, i64 0, !7, i64 8}
!14 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!15 = !{!"_ZTSN8nvinfer112TensorFormatE", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!12, !15, i64 76}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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.nvinfer1::PluginTensorDesc" = type { %"class.nvinfer1::Dims64", i32, i32, float }
%"class.nvinfer1::Dims64" = type { i32, [8 x i64] }

@.str.4 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [38 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin27DisentangledAttentionPlugin25supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr nocapture noundef nonnull readnone align 8 dereferenceable(48) %0, i32 noundef %1, ptr noundef readonly %2, i32 noundef %3, i32 noundef %4) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %.not = icmp ne ptr %2, null
  %6 = add nsw i32 %4, %3
  %7 = icmp sgt i32 %6, %1
  %or.cond = select i1 %.not, i1 %7, i1 false
  br i1 %or.cond, label %9, label %8

8:                                                ; preds = %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 162)
          to label %9 unwind label %23

9:                                                ; preds = %5, %8
  %10 = sext i32 %1 to i64
  %11 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %2, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 72
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %switch = icmp ult i32 %13, 3
  br i1 %switch, label %14, label %21

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %2, i64 72
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = icmp eq i32 %13, %16
  %18 = getelementptr inbounds i8, ptr %11, i64 76
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp eq i32 %19, 0
  %spec.select = select i1 %20, i1 %17, i1 false
  br label %21

21:                                               ; preds = %14, %9
  %22 = phi i1 [ false, %9 ], [ %spec.select, %14 ]
  ret i1 %22

23:                                               ; preds = %8
  %24 = landingpad { ptr, i32 }
          catch ptr null
  %25 = extractvalue { ptr, i32 } %24, 0
  tail call void @__clang_call_terminate(ptr %25) #3
  unreachable
}

declare void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { noinline noreturn nounwind uwtable "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 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 #2 = { "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 = { noreturn 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 72}
!6 = !{!"_ZTSN8nvinfer116PluginTensorDescE", !7, i64 0, !11, i64 72, !12, i64 76, !13, i64 80}
!7 = !{!"_ZTSN8nvinfer16Dims64E", !8, i64 0, !9, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN8nvinfer18DataTypeE", !9, i64 0}
!12 = !{!"_ZTSN8nvinfer112TensorFormatE", !9, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!6, !12, i64 76}


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