; LLVM IR from mrbid/CSGO_TENSOR_TRIGGER :: GOBOT15/LIBONNX (hmap)

; 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.hmap_t = type { ptr, %struct.list_head, i32, i32, ptr }
%struct.list_head = type { ptr, ptr }
%struct.hlist_head = type { ptr }
%struct.hmap_entry_t = type { %struct.hlist_node, %struct.list_head, ptr, ptr }
%struct.hlist_node = type { ptr, ptr }

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @hlist_del(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_del(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @shash(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @hmap_resize(ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @hmap_remove(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %19, %2
  store i32 1, ptr %7, align 4
  br label %116

23:                                               ; preds = %19
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.hmap_t, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = icmp ugt i32 %26, 16
  br i1 %27, label %28, label %43

28:                                               ; preds = %23
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.hmap_t, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !13
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.hmap_t, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = lshr i32 %34, 1
  %36 = icmp ult i32 %31, %35
  br i1 %36, label %37, label %43

37:                                               ; preds = %28
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.hmap_t, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = lshr i32 %41, 1
  call void @hmap_resize(ptr noundef %38, i32 noundef %42)
  br label %43

43:                                               ; preds = %37, %28, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.hmap_t, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 @shash(ptr noundef %47)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hmap_t, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 8, !tbaa !9
  %52 = sub i32 %51, 1
  %53 = and i32 %48, %52
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds %struct.hlist_head, ptr %46, i64 %54
  %56 = getelementptr inbounds %struct.hlist_head, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  store ptr %57, ptr %8, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %65

60:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 0
  store ptr %63, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  br label %66

65:                                               ; preds = %43
  br label %66

66:                                               ; preds = %65, %60
  %67 = phi ptr [ %64, %60 ], [ null, %65 ]
  store ptr %67, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %68, ptr %5, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %112, %66
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %79

72:                                               ; preds = %69
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hmap_entry_t, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.hlist_node, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !17
  store ptr %76, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %12, align 4, !tbaa !20
  %77 = load i32, ptr %12, align 4, !tbaa !20
  %78 = icmp ne i32 %77, 0
  br label %79

79:                                               ; preds = %72, %69
  %80 = phi i1 [ false, %69 ], [ %78, %72 ]
  br i1 %80, label %81, label %115

81:                                               ; preds = %79
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.hmap_entry_t, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = call i32 @strcmp(ptr noundef %84, ptr noundef %85) #6
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %101

88:                                               ; preds = %81
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.hmap_entry_t, ptr %89, i32 0, i32 0
  call void @hlist_del(ptr noundef %90)
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.hmap_entry_t, ptr %91, i32 0, i32 1
  call void @list_del(ptr noundef %92)
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.hmap_t, ptr %93, i32 0, i32 3
  %95 = load i32, ptr %94, align 4, !tbaa !13
  %96 = add i32 %95, -1
  store i32 %96, ptr %94, align 4, !tbaa !13
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.hmap_entry_t, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !21
  call void @free(ptr noundef %99) #5
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %100) #5
  store i32 1, ptr %7, align 4
  br label %116

101:                                              ; preds = %81
  br label %102

102:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %103, ptr %13, align 8, !tbaa !5
  %104 = load ptr, ptr %13, align 8, !tbaa !5
  %105 = icmp ne ptr %104, null
  br i1 %105, label %106, label %111

106:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %107, ptr %15, align 8, !tbaa !5
  %108 = load ptr, ptr %15, align 8, !tbaa !5
  %109 = getelementptr inbounds i8, ptr %108, i64 0
  store ptr %109, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  %110 = load ptr, ptr %16, align 8, !tbaa !5
  br label %112

111:                                              ; preds = %102
  br label %112

112:                                              ; preds = %111, %106
  %113 = phi ptr [ %110, %106 ], [ null, %111 ]
  store ptr %113, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  %114 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %114, ptr %5, align 8, !tbaa !5
  br label %69, !llvm.loop !22

115:                                              ; preds = %79
  store i32 0, ptr %7, align 4
  br label %116

116:                                              ; preds = %115, %88, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %117 = load i32, ptr %7, align 4
  switch i32 %117, label %119 [
    i32 0, label %118
    i32 1, label %118
  ]

118:                                              ; preds = %116, %116
  ret void

119:                                              ; preds = %116
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { 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 #4 = { 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 #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/C++ TBAA"}
!9 = !{!10, !12, i64 24}
!10 = !{!"hmap_t", !6, i64 0, !11, i64 8, !12, i64 24, !12, i64 28, !6, i64 32}
!11 = !{!"list_head", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 28}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"hlist_head", !6, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"hmap_entry_t", !19, i64 0, !11, i64 16, !6, i64 32, !6, i64 40}
!19 = !{!"hlist_node", !6, i64 0, !6, i64 8}
!20 = !{!12, !12, i64 0}
!21 = !{!18, !6, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; 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.hlist_head = type { ptr }

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @hlist_del(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @list_del(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @shash(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @hmap_resize(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @hmap_remove(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %.critedge

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp ugt i32 %7, 16
  br i1 %8, label %9, label %15

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = lshr i32 %7, 1
  %13 = icmp ult i32 %11, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %9
  tail call void @hmap_resize(ptr noundef nonnull %0, i32 noundef %12)
  br label %15

15:                                               ; preds = %14, %9, %5
  %16 = load ptr, ptr %0, align 8, !tbaa !13
  %17 = tail call i32 @shash(ptr noundef nonnull %1)
  %18 = load i32, ptr %6, align 8, !tbaa !5
  %19 = add i32 %18, -1
  %20 = and i32 %19, %17
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds %struct.hlist_head, ptr %16, i64 %21
  br label %23

23:                                               ; preds = %24, %15
  %.0.in = phi ptr [ %22, %15 ], [ %.0, %24 ]
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !14
  %.not37 = icmp eq ptr %.0, null
  br i1 %.not37, label %.critedge, label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %.0, i64 32
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %26, ptr noundef nonnull dereferenceable(1) %1) #4
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %23, !llvm.loop !18

29:                                               ; preds = %24
  %30 = getelementptr inbounds i8, ptr %.0, i64 32
  tail call void @hlist_del(ptr noundef nonnull %.0)
  %31 = getelementptr inbounds i8, ptr %.0, i64 16
  tail call void @list_del(ptr noundef nonnull %31)
  %32 = getelementptr inbounds i8, ptr %0, i64 28
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = add i32 %33, -1
  store i32 %34, ptr %32, align 4, !tbaa !12
  %35 = load ptr, ptr %30, align 8, !tbaa !15
  tail call void @free(ptr noundef %35) #5
  tail call void @free(ptr noundef nonnull %.0) #5
  br label %.critedge

.critedge:                                        ; preds = %23, %2, %29
  ret void
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 = { 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 #3 = { 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 #4 = { nounwind willreturn memory(read) }
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, !11, i64 24}
!6 = !{!"hmap_t", !7, i64 0, !10, i64 8, !11, i64 24, !11, i64 28, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"list_head", !7, i64 0, !7, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 28}
!13 = !{!6, !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !7, i64 32}
!16 = !{!"hmap_entry_t", !17, i64 0, !10, i64 16, !7, i64 32, !7, i64 40}
!17 = !{!"hlist_node", !7, i64 0, !7, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass