; LLVM IR from Montimage/mmt-security :: test/hoa (hash_table_botcc)

; 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.DataItem = type { ptr, i64 }

@hashArrayIPAdd = external dso_local global [15000 x ptr], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @hashCode(i64 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: nounwind uwtable
define dso_local i32 @delete_hash_ip(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i32 -1, ptr %2, align 4
  br label %53

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.DataItem, ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %13, ptr %4, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %14 = load i64, ptr %4, align 8, !tbaa !12
  %15 = call i64 @hashCode(i64 noundef %14)
  %16 = trunc i64 %15 to i32
  store i32 %16, ptr %5, align 4, !tbaa !13
  br label %17

17:                                               ; preds = %46, %10
  %18 = load i32, ptr %5, align 4, !tbaa !13
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %51

23:                                               ; preds = %17
  %24 = load i32, ptr %5, align 4, !tbaa !13
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DataItem, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = load i64, ptr %4, align 8, !tbaa !12
  %31 = icmp eq i64 %29, %30
  br i1 %31, label %32, label %46

32:                                               ; preds = %23
  %33 = load i32, ptr %5, align 4, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %34
  store ptr null, ptr %35, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DataItem, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  call void @free(ptr noundef %41) #3
  %42 = load i32, ptr %5, align 4, !tbaa !13
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  call void @free(ptr noundef %45) #3
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %52

46:                                               ; preds = %23
  %47 = load i32, ptr %5, align 4, !tbaa !13
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !13
  %49 = load i32, ptr %5, align 4, !tbaa !13
  %50 = srem i32 %49, 15000
  store i32 %50, ptr %5, align 4, !tbaa !13
  br label %17, !llvm.loop !16

51:                                               ; preds = %17
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %52

52:                                               ; preds = %51, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %53

53:                                               ; preds = %52, %9
  %54 = load i32, ptr %2, align 4
  ret i32 %54
}

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"DataItem", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@hashArrayIPAdd = external dso_local local_unnamed_addr global [15000 x ptr], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @hashCode(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @delete_hash_ip(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %.loopexit, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = tail call i64 @hashCode(i64 noundef %5)
  %sext = shl i64 %6, 32
  %7 = ashr exact i64 %sext, 32
  %8 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %7
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %.not15 = icmp eq ptr %9, null
  br i1 %.not15, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = icmp eq i64 %11, %5
  br i1 %12, label %.lr.ph._crit_edge, label %.lr.ph21

.lr.ph21:                                         ; preds = %.lr.ph.preheader
  %13 = trunc i64 %6 to i32
  br label %18

.lr.ph:                                           ; preds = %18
  %14 = getelementptr inbounds i8, ptr %23, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = icmp eq i64 %15, %5
  br i1 %16, label %.lr.ph._crit_edge, label %18, !llvm.loop !12

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa = phi i64 [ %7, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %17 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %.lcssa
  store ptr null, ptr %17, align 8, !tbaa !11
  br label %.loopexit

18:                                               ; preds = %.lr.ph21, %.lr.ph
  %.01620 = phi i32 [ %13, %.lr.ph21 ], [ %20, %.lr.ph ]
  %19 = add nsw i32 %.01620, 1
  %20 = srem i32 %19, 15000
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [15000 x ptr], ptr @hashArrayIPAdd, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !12

.loopexit:                                        ; preds = %18, %3, %.lr.ph._crit_edge, %1
  %.1 = phi i32 [ -1, %1 ], [ 1, %.lr.ph._crit_edge ], [ 0, %3 ], [ 0, %18 ]
  ret i32 %.1
}

attributes #0 = { 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, !10, i64 8}
!6 = !{!"DataItem", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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