; LLVM IR from codemistic/Data-Structures-and-Algorithms :: Hashtable/cuckoo-hashing.ll (Z10printTablev)

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

@hashtable = external dso_local global [2 x [11 x i32]], align 16
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = 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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10printTablev() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %40, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 2
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %44

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %36, %9
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 11
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %39

14:                                               ; preds = %10
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2 x [11 x i32]], ptr @hashtable, i64 0, i64 %16
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [11 x i32], ptr %17, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp eq i32 %21, -2147483648
  br i1 %22, label %23, label %25

23:                                               ; preds = %14
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %34

25:                                               ; preds = %14
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [2 x [11 x i32]], ptr @hashtable, i64 0, i64 %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [11 x i32], ptr %28, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %32)
  br label %34

34:                                               ; preds = %25, %23
  %35 = phi i32 [ %24, %23 ], [ %33, %25 ]
  br label %36

36:                                               ; preds = %34
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !9

39:                                               ; preds = %13
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %1, align 4, !tbaa !5
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %5, !llvm.loop !11

44:                                               ; preds = %8
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 }

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


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

@hashtable = external dso_local local_unnamed_addr global [2 x [11 x i32]], align 16
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z10printTablev() local_unnamed_addr #1 {
.preheader:
  %0 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %1 = load i32, ptr @hashtable, align 16, !tbaa !5
  %2 = icmp eq i32 %1, -2147483648
  br i1 %2, label %3, label %5

3:                                                ; preds = %.preheader
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %7

5:                                                ; preds = %.preheader
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %1)
  br label %7

7:                                                ; preds = %3, %5
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 4), align 4, !tbaa !5
  %9 = icmp eq i32 %8, -2147483648
  br i1 %9, label %12, label %10

10:                                               ; preds = %7
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %8)
  br label %14

12:                                               ; preds = %7
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %14

14:                                               ; preds = %12, %10
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 8), align 8, !tbaa !5
  %16 = icmp eq i32 %15, -2147483648
  br i1 %16, label %19, label %17

17:                                               ; preds = %14
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %15)
  br label %21

19:                                               ; preds = %14
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %21

21:                                               ; preds = %19, %17
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 12), align 4, !tbaa !5
  %23 = icmp eq i32 %22, -2147483648
  br i1 %23, label %26, label %24

24:                                               ; preds = %21
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %22)
  br label %28

26:                                               ; preds = %21
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %28

28:                                               ; preds = %26, %24
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 16), align 16, !tbaa !5
  %30 = icmp eq i32 %29, -2147483648
  br i1 %30, label %33, label %31

31:                                               ; preds = %28
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %29)
  br label %35

33:                                               ; preds = %28
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %35

35:                                               ; preds = %33, %31
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 20), align 4, !tbaa !5
  %37 = icmp eq i32 %36, -2147483648
  br i1 %37, label %40, label %38

38:                                               ; preds = %35
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %36)
  br label %42

40:                                               ; preds = %35
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %42

42:                                               ; preds = %40, %38
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 24), align 8, !tbaa !5
  %44 = icmp eq i32 %43, -2147483648
  br i1 %44, label %47, label %45

45:                                               ; preds = %42
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %43)
  br label %49

47:                                               ; preds = %42
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %49

49:                                               ; preds = %47, %45
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 28), align 4, !tbaa !5
  %51 = icmp eq i32 %50, -2147483648
  br i1 %51, label %54, label %52

52:                                               ; preds = %49
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %50)
  br label %56

54:                                               ; preds = %49
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %56

56:                                               ; preds = %54, %52
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 32), align 16, !tbaa !5
  %58 = icmp eq i32 %57, -2147483648
  br i1 %58, label %61, label %59

59:                                               ; preds = %56
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %57)
  br label %63

61:                                               ; preds = %56
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %63

63:                                               ; preds = %61, %59
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 36), align 4, !tbaa !5
  %65 = icmp eq i32 %64, -2147483648
  br i1 %65, label %68, label %66

66:                                               ; preds = %63
  %67 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %64)
  br label %70

68:                                               ; preds = %63
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %70

70:                                               ; preds = %68, %66
  %71 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 40), align 8, !tbaa !5
  %72 = icmp eq i32 %71, -2147483648
  br i1 %72, label %75, label %73

73:                                               ; preds = %70
  %74 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %71)
  br label %.preheader.1

75:                                               ; preds = %70
  %76 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.preheader.1

.preheader.1:                                     ; preds = %75, %73
  %77 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %78 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 44), align 4, !tbaa !5
  %79 = icmp eq i32 %78, -2147483648
  br i1 %79, label %82, label %80

80:                                               ; preds = %.preheader.1
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %78)
  br label %84

82:                                               ; preds = %.preheader.1
  %83 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %84

84:                                               ; preds = %82, %80
  %85 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 48), align 16, !tbaa !5
  %86 = icmp eq i32 %85, -2147483648
  br i1 %86, label %89, label %87

87:                                               ; preds = %84
  %88 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %85)
  br label %91

89:                                               ; preds = %84
  %90 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %91

91:                                               ; preds = %89, %87
  %92 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 52), align 4, !tbaa !5
  %93 = icmp eq i32 %92, -2147483648
  br i1 %93, label %96, label %94

94:                                               ; preds = %91
  %95 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %92)
  br label %98

96:                                               ; preds = %91
  %97 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %98

98:                                               ; preds = %96, %94
  %99 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 56), align 8, !tbaa !5
  %100 = icmp eq i32 %99, -2147483648
  br i1 %100, label %103, label %101

101:                                              ; preds = %98
  %102 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %99)
  br label %105

103:                                              ; preds = %98
  %104 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %105

105:                                              ; preds = %103, %101
  %106 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 60), align 4, !tbaa !5
  %107 = icmp eq i32 %106, -2147483648
  br i1 %107, label %110, label %108

108:                                              ; preds = %105
  %109 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %106)
  br label %112

110:                                              ; preds = %105
  %111 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %112

112:                                              ; preds = %110, %108
  %113 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 64), align 16, !tbaa !5
  %114 = icmp eq i32 %113, -2147483648
  br i1 %114, label %117, label %115

115:                                              ; preds = %112
  %116 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %113)
  br label %119

117:                                              ; preds = %112
  %118 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %119

119:                                              ; preds = %117, %115
  %120 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 68), align 4, !tbaa !5
  %121 = icmp eq i32 %120, -2147483648
  br i1 %121, label %124, label %122

122:                                              ; preds = %119
  %123 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %120)
  br label %126

124:                                              ; preds = %119
  %125 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %126

126:                                              ; preds = %124, %122
  %127 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 72), align 8, !tbaa !5
  %128 = icmp eq i32 %127, -2147483648
  br i1 %128, label %131, label %129

129:                                              ; preds = %126
  %130 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %127)
  br label %133

131:                                              ; preds = %126
  %132 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %133

133:                                              ; preds = %131, %129
  %134 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 76), align 4, !tbaa !5
  %135 = icmp eq i32 %134, -2147483648
  br i1 %135, label %138, label %136

136:                                              ; preds = %133
  %137 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %134)
  br label %140

138:                                              ; preds = %133
  %139 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %140

140:                                              ; preds = %138, %136
  %141 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 80), align 16, !tbaa !5
  %142 = icmp eq i32 %141, -2147483648
  br i1 %142, label %145, label %143

143:                                              ; preds = %140
  %144 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %141)
  br label %147

145:                                              ; preds = %140
  %146 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %147

147:                                              ; preds = %145, %143
  %148 = load i32, ptr getelementptr inbounds (i8, ptr @hashtable, i64 84), align 4, !tbaa !5
  %149 = icmp eq i32 %148, -2147483648
  br i1 %149, label %152, label %150

150:                                              ; preds = %147
  %151 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %148)
  br label %154

152:                                              ; preds = %147
  %153 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %154

154:                                              ; preds = %152, %150
  %155 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %156 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  ret void
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass