; LLVM IR from AngelPn/DBMS-Simulator :: src (HP)

; 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.HP_info = type { i32, i32, i8, ptr, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1

declare void @BF_PrintError(ptr noundef) #0

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

declare i32 @BF_ReadBlock(i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @BF_WriteBlock(i32 noundef, i32 noundef) #0

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

declare ptr @get_key(ptr noundef, ptr noundef) #0

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

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

19:                                               ; preds = %2
  call void @BF_PrintError(ptr noundef @.str.3)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %103

20:                                               ; preds = %2
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 512
  %23 = getelementptr inbounds i8, ptr %22, i64 -8
  %24 = load i32, ptr %23, align 4, !tbaa !9
  store i32 %24, ptr %6, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %97, %20
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp ne i32 %26, -1
  br i1 %27, label %28, label %102

28:                                               ; preds = %25
  %29 = getelementptr inbounds %struct.HP_info, ptr %0, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = call i32 @BF_ReadBlock(i32 noundef %30, i32 noundef %31, ptr noundef %7)
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %28
  call void @BF_PrintError(ptr noundef @.str.3)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %103

35:                                               ; preds = %28
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 512
  %38 = getelementptr inbounds i8, ptr %37, i64 -4
  %39 = load i32, ptr %38, align 4, !tbaa !9
  store i32 %39, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %92, %35
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 4, ptr %8, align 4
  br label %95

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = mul i64 %48, 96
  %50 = getelementptr inbounds i8, ptr %46, i64 %49
  store ptr %50, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.HP_info, ptr %0, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = call ptr @get_key(ptr noundef %51, ptr noundef %53)
  store ptr %54, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.HP_info, ptr %0, i32 0, i32 4
  %58 = load i32, ptr %57, align 8, !tbaa !15
  %59 = sext i32 %58 to i64
  %60 = call i32 @memcmp(ptr noundef %55, ptr noundef %56, i64 noundef %59) #6
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %88

62:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = sub nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = mul i64 %66, 96
  %68 = getelementptr inbounds i8, ptr %63, i64 %67
  store ptr %68, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = mul i64 %71, 96
  %73 = getelementptr inbounds i8, ptr %69, i64 %72
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %73, ptr align 4 %74, i64 96, i1 false)
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %5, align 4, !tbaa !9
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 512
  %79 = getelementptr inbounds i8, ptr %78, i64 -4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %79, ptr align 4 %5, i64 4, i1 false)
  %80 = getelementptr inbounds %struct.HP_info, ptr %0, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !11
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = call i32 @BF_WriteBlock(i32 noundef %81, i32 noundef %82)
  %84 = icmp slt i32 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %62
  call void @BF_PrintError(ptr noundef @.str.5)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %87

86:                                               ; preds = %62
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %87

87:                                               ; preds = %86, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %89

88:                                               ; preds = %45
  store i32 0, ptr %8, align 4
  br label %89

89:                                               ; preds = %88, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %90 = load i32, ptr %8, align 4
  switch i32 %90, label %95 [
    i32 0, label %91
  ]

91:                                               ; preds = %89
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %9, align 4, !tbaa !9
  br label %40, !llvm.loop !16

95:                                               ; preds = %89, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %96 = load i32, ptr %8, align 4
  switch i32 %96, label %103 [
    i32 4, label %97
  ]

97:                                               ; preds = %95
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i64 512
  %100 = getelementptr inbounds i8, ptr %99, i64 -8
  %101 = load i32, ptr %100, align 4, !tbaa !9
  store i32 %101, ptr %6, align 4, !tbaa !9
  br label %25, !llvm.loop !18

102:                                              ; preds = %25
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %103

103:                                              ; preds = %102, %95, %34, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %104 = load i32, ptr %3, align 4
  ret i32 %104
}

attributes #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"HP_info", !10, i64 0, !10, i64 4, !7, i64 8, !6, i64 16, !10, i64 24, !10, i64 28}
!13 = !{!12, !10, i64 28}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !10, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.HP_info = type { i32, i32, i8, ptr, i32, i32 }

@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1

declare void @BF_PrintError(ptr noundef) local_unnamed_addr #0

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

declare i32 @BF_ReadBlock(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @BF_WriteBlock(i32 noundef, i32 noundef) local_unnamed_addr #0

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

declare ptr @get_key(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @HP_DeleteEntry(ptr nocapture noundef readonly byval(%struct.HP_info) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load i32, ptr %6, align 4, !tbaa !12
  %8 = call i32 @BF_ReadBlock(i32 noundef %5, i32 noundef %7, ptr noundef nonnull %3) #5
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %.thread28.sink.split, label %.preheader

.preheader:                                       ; preds = %2
  %.pn35 = load ptr, ptr %3, align 8, !tbaa !5
  %.019.in36 = getelementptr inbounds i8, ptr %.pn35, i64 504
  %.01937 = load i32, ptr %.019.in36, align 4, !tbaa !13
  %.not38 = icmp eq i32 %.01937, -1
  br i1 %.not38, label %.thread28, label %.lr.ph40

.lr.ph40:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load ptr, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i32, ptr %12, align 8
  %14 = sext i32 %13 to i64
  br label %15

.loopexit.loopexit:                               ; preds = %22
  %.pn.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %18
  %.pn = phi ptr [ %.pn.pre, %.loopexit.loopexit ], [ %19, %18 ]
  %.019.in = getelementptr inbounds i8, ptr %.pn, i64 504
  %.019 = load i32, ptr %.019.in, align 4, !tbaa !13
  %.not = icmp eq i32 %.019, -1
  br i1 %.not, label %.thread28, label %15

15:                                               ; preds = %.lr.ph40, %.loopexit
  %.01939 = phi i32 [ %.01937, %.lr.ph40 ], [ %.019, %.loopexit ]
  %16 = call i32 @BF_ReadBlock(i32 noundef %5, i32 noundef %.01939, ptr noundef nonnull %3) #5
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %.thread28.sink.split, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 508
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %.not2533 = icmp sgt i32 %21, 0
  br i1 %.not2533, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %18
  %wide.trip.count = zext nneg i32 %21 to i64
  br label %.lr.ph

22:                                               ; preds = %.lr.ph
  %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 %.loopexit.loopexit, label %.lr.ph, !llvm.loop !14

.lr.ph:                                           ; preds = %.lr.ph.preheader, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %22 ]
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = mul nuw nsw i64 %indvars.iv, 96
  %25 = getelementptr inbounds i8, ptr %23, i64 %24
  %26 = call ptr @get_key(ptr noundef %25, ptr noundef %11) #5
  %bcmp = call i32 @bcmp(ptr %1, ptr %26, i64 %14)
  %.not24 = icmp eq i32 %bcmp, 0
  br i1 %.not24, label %27, label %22

27:                                               ; preds = %.lr.ph
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = add nsw i32 %21, -1
  %30 = sext i32 %29 to i64
  %31 = mul nsw i64 %30, 96
  %32 = getelementptr inbounds i8, ptr %28, i64 %31
  %33 = getelementptr inbounds i8, ptr %28, i64 %24
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(96) %33, ptr noundef nonnull align 4 dereferenceable(96) %32, i64 96, i1 false)
  %34 = getelementptr inbounds i8, ptr %28, i64 508
  store i32 %29, ptr %34, align 1
  %35 = call i32 @BF_WriteBlock(i32 noundef %5, i32 noundef %.01939) #5
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %.thread28.sink.split, label %.thread28

.thread28.sink.split:                             ; preds = %15, %27, %2
  %.str.5.sink = phi ptr [ @.str.3, %2 ], [ @.str.5, %27 ], [ @.str.3, %15 ]
  call void @BF_PrintError(ptr noundef nonnull %.str.5.sink) #5
  br label %.thread28

.thread28:                                        ; preds = %.loopexit, %.thread28.sink.split, %.preheader, %27
  %.5 = phi i32 [ 0, %27 ], [ -1, %.preheader ], [ -1, %.thread28.sink.split ], [ -1, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 %.5
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #4

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nofree nounwind willreturn memory(argmem: 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"HP_info", !11, i64 0, !11, i64 4, !7, i64 8, !6, i64 16, !11, i64 24, !11, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 28}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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