; LLVM IR from HarshCasper/NeoAlgo :: C/ds (Hashtable_chaining)

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

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @print_table(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %38, %1
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 10
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %41

11:                                               ; preds = %7
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.HashTable, ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %35

16:                                               ; preds = %11
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %19, ptr %5, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %25, %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HashTable, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %33

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.HashTable, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  store ptr %28, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.HashTable, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %31)
  br label %20, !llvm.loop !14

33:                                               ; preds = %20
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %35

35:                                               ; preds = %33, %11
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.HashTable, ptr %36, i32 1
  store ptr %37, ptr %3, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %35
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !16

41:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

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


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

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_table(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %13, label %4

4:                                                ; preds = %1
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 0)
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %.not1213 = icmp eq ptr %6, null
  br i1 %.not1213, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %7 = phi ptr [ %11, %.lr.ph ], [ %6, %4 ]
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %8)
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %.not12 = icmp eq ptr %11, null
  br i1 %.not12, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %4
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %13

13:                                               ; preds = %._crit_edge, %1
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %.not.1 = icmp eq ptr %15, null
  br i1 %.not.1, label %25, label %16

16:                                               ; preds = %13
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1)
  %18 = load ptr, ptr %14, align 8, !tbaa !5
  %.not1213.1 = icmp eq ptr %18, null
  br i1 %.not1213.1, label %._crit_edge.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %16, %.lr.ph.1
  %19 = phi ptr [ %23, %.lr.ph.1 ], [ %18, %16 ]
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %20)
  %22 = getelementptr inbounds i8, ptr %19, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %.not12.1 = icmp eq ptr %23, null
  br i1 %.not12.1, label %._crit_edge.1, label %.lr.ph.1, !llvm.loop !12

._crit_edge.1:                                    ; preds = %.lr.ph.1, %16
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %25

25:                                               ; preds = %._crit_edge.1, %13
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %.not.2 = icmp eq ptr %27, null
  br i1 %.not.2, label %37, label %28

28:                                               ; preds = %25
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 2)
  %30 = load ptr, ptr %26, align 8, !tbaa !5
  %.not1213.2 = icmp eq ptr %30, null
  br i1 %.not1213.2, label %._crit_edge.2, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %28, %.lr.ph.2
  %31 = phi ptr [ %35, %.lr.ph.2 ], [ %30, %28 ]
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %32)
  %34 = getelementptr inbounds i8, ptr %31, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %.not12.2 = icmp eq ptr %35, null
  br i1 %.not12.2, label %._crit_edge.2, label %.lr.ph.2, !llvm.loop !12

._crit_edge.2:                                    ; preds = %.lr.ph.2, %28
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %37

37:                                               ; preds = %._crit_edge.2, %25
  %38 = getelementptr inbounds i8, ptr %0, i64 56
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %.not.3 = icmp eq ptr %39, null
  br i1 %.not.3, label %49, label %40

40:                                               ; preds = %37
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 3)
  %42 = load ptr, ptr %38, align 8, !tbaa !5
  %.not1213.3 = icmp eq ptr %42, null
  br i1 %.not1213.3, label %._crit_edge.3, label %.lr.ph.3

.lr.ph.3:                                         ; preds = %40, %.lr.ph.3
  %43 = phi ptr [ %47, %.lr.ph.3 ], [ %42, %40 ]
  %44 = load i32, ptr %43, align 8, !tbaa !11
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %44)
  %46 = getelementptr inbounds i8, ptr %43, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %.not12.3 = icmp eq ptr %47, null
  br i1 %.not12.3, label %._crit_edge.3, label %.lr.ph.3, !llvm.loop !12

._crit_edge.3:                                    ; preds = %.lr.ph.3, %40
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %49

49:                                               ; preds = %._crit_edge.3, %37
  %50 = getelementptr inbounds i8, ptr %0, i64 72
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %.not.4 = icmp eq ptr %51, null
  br i1 %.not.4, label %61, label %52

52:                                               ; preds = %49
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 4)
  %54 = load ptr, ptr %50, align 8, !tbaa !5
  %.not1213.4 = icmp eq ptr %54, null
  br i1 %.not1213.4, label %._crit_edge.4, label %.lr.ph.4

.lr.ph.4:                                         ; preds = %52, %.lr.ph.4
  %55 = phi ptr [ %59, %.lr.ph.4 ], [ %54, %52 ]
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %56)
  %58 = getelementptr inbounds i8, ptr %55, i64 8
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %.not12.4 = icmp eq ptr %59, null
  br i1 %.not12.4, label %._crit_edge.4, label %.lr.ph.4, !llvm.loop !12

._crit_edge.4:                                    ; preds = %.lr.ph.4, %52
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %61

61:                                               ; preds = %._crit_edge.4, %49
  %62 = getelementptr inbounds i8, ptr %0, i64 88
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %.not.5 = icmp eq ptr %63, null
  br i1 %.not.5, label %73, label %64

64:                                               ; preds = %61
  %65 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 5)
  %66 = load ptr, ptr %62, align 8, !tbaa !5
  %.not1213.5 = icmp eq ptr %66, null
  br i1 %.not1213.5, label %._crit_edge.5, label %.lr.ph.5

.lr.ph.5:                                         ; preds = %64, %.lr.ph.5
  %67 = phi ptr [ %71, %.lr.ph.5 ], [ %66, %64 ]
  %68 = load i32, ptr %67, align 8, !tbaa !11
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %68)
  %70 = getelementptr inbounds i8, ptr %67, i64 8
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %.not12.5 = icmp eq ptr %71, null
  br i1 %.not12.5, label %._crit_edge.5, label %.lr.ph.5, !llvm.loop !12

._crit_edge.5:                                    ; preds = %.lr.ph.5, %64
  %72 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %73

73:                                               ; preds = %._crit_edge.5, %61
  %74 = getelementptr inbounds i8, ptr %0, i64 104
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %.not.6 = icmp eq ptr %75, null
  br i1 %.not.6, label %85, label %76

76:                                               ; preds = %73
  %77 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 6)
  %78 = load ptr, ptr %74, align 8, !tbaa !5
  %.not1213.6 = icmp eq ptr %78, null
  br i1 %.not1213.6, label %._crit_edge.6, label %.lr.ph.6

.lr.ph.6:                                         ; preds = %76, %.lr.ph.6
  %79 = phi ptr [ %83, %.lr.ph.6 ], [ %78, %76 ]
  %80 = load i32, ptr %79, align 8, !tbaa !11
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %80)
  %82 = getelementptr inbounds i8, ptr %79, i64 8
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %.not12.6 = icmp eq ptr %83, null
  br i1 %.not12.6, label %._crit_edge.6, label %.lr.ph.6, !llvm.loop !12

._crit_edge.6:                                    ; preds = %.lr.ph.6, %76
  %84 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %85

85:                                               ; preds = %._crit_edge.6, %73
  %86 = getelementptr inbounds i8, ptr %0, i64 120
  %87 = load ptr, ptr %86, align 8, !tbaa !5
  %.not.7 = icmp eq ptr %87, null
  br i1 %.not.7, label %97, label %88

88:                                               ; preds = %85
  %89 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 7)
  %90 = load ptr, ptr %86, align 8, !tbaa !5
  %.not1213.7 = icmp eq ptr %90, null
  br i1 %.not1213.7, label %._crit_edge.7, label %.lr.ph.7

.lr.ph.7:                                         ; preds = %88, %.lr.ph.7
  %91 = phi ptr [ %95, %.lr.ph.7 ], [ %90, %88 ]
  %92 = load i32, ptr %91, align 8, !tbaa !11
  %93 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %92)
  %94 = getelementptr inbounds i8, ptr %91, i64 8
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  %.not12.7 = icmp eq ptr %95, null
  br i1 %.not12.7, label %._crit_edge.7, label %.lr.ph.7, !llvm.loop !12

._crit_edge.7:                                    ; preds = %.lr.ph.7, %88
  %96 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %97

97:                                               ; preds = %._crit_edge.7, %85
  %98 = getelementptr inbounds i8, ptr %0, i64 136
  %99 = load ptr, ptr %98, align 8, !tbaa !5
  %.not.8 = icmp eq ptr %99, null
  br i1 %.not.8, label %109, label %100

100:                                              ; preds = %97
  %101 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 8)
  %102 = load ptr, ptr %98, align 8, !tbaa !5
  %.not1213.8 = icmp eq ptr %102, null
  br i1 %.not1213.8, label %._crit_edge.8, label %.lr.ph.8

.lr.ph.8:                                         ; preds = %100, %.lr.ph.8
  %103 = phi ptr [ %107, %.lr.ph.8 ], [ %102, %100 ]
  %104 = load i32, ptr %103, align 8, !tbaa !11
  %105 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %104)
  %106 = getelementptr inbounds i8, ptr %103, i64 8
  %107 = load ptr, ptr %106, align 8, !tbaa !5
  %.not12.8 = icmp eq ptr %107, null
  br i1 %.not12.8, label %._crit_edge.8, label %.lr.ph.8, !llvm.loop !12

._crit_edge.8:                                    ; preds = %.lr.ph.8, %100
  %108 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %109

109:                                              ; preds = %._crit_edge.8, %97
  %110 = getelementptr inbounds i8, ptr %0, i64 152
  %111 = load ptr, ptr %110, align 8, !tbaa !5
  %.not.9 = icmp eq ptr %111, null
  br i1 %.not.9, label %121, label %112

112:                                              ; preds = %109
  %113 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 9)
  %114 = load ptr, ptr %110, align 8, !tbaa !5
  %.not1213.9 = icmp eq ptr %114, null
  br i1 %.not1213.9, label %._crit_edge.9, label %.lr.ph.9

.lr.ph.9:                                         ; preds = %112, %.lr.ph.9
  %115 = phi ptr [ %119, %.lr.ph.9 ], [ %114, %112 ]
  %116 = load i32, ptr %115, align 8, !tbaa !11
  %117 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %116)
  %118 = getelementptr inbounds i8, ptr %115, i64 8
  %119 = load ptr, ptr %118, align 8, !tbaa !5
  %.not12.9 = icmp eq ptr %119, null
  br i1 %.not12.9, label %._crit_edge.9, label %.lr.ph.9, !llvm.loop !12

._crit_edge.9:                                    ; preds = %.lr.ph.9, %112
  %120 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %121

121:                                              ; preds = %._crit_edge.9, %109
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { nofree 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 = { nofree 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" }

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


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