; LLVM IR from DimitrisJim/leetcode_solutions :: C/Algorithms/Support (dict)

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

@Table_new.PRIMES = external hidden global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.Table_new = external hidden unnamed_addr constant [92 x i8], align 1

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

11:                                               ; preds = %3
  br label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 57, ptr noundef @__PRETTY_FUNCTION__.Table_new) #5
  unreachable

13:                                               ; preds = %11
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %22, %13
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [10 x i32], ptr @Table_new.PRIMES, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %14
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %8, align 4, !tbaa !5
  br label %14, !llvm.loop !11

25:                                               ; preds = %14
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [10 x i32], ptr @Table_new.PRIMES, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = mul i64 %31, 8
  %33 = add i64 40, %32
  %34 = call noalias ptr @malloc(i64 noundef %33) #6
  store ptr %34, ptr %7, align 8, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = sub nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10 x i32], ptr @Table_new.PRIMES, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.table, ptr %40, i32 0, i32 0
  store i32 %39, ptr %41, align 8, !tbaa !13
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %46

44:                                               ; preds = %25
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  br label %47

46:                                               ; preds = %25
  br label %47

47:                                               ; preds = %46, %44
  %48 = phi ptr [ %45, %44 ], [ @cmpatom, %46 ]
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.table, ptr %49, i32 0, i32 1
  store ptr %48, ptr %50, align 8, !tbaa !15
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %55

53:                                               ; preds = %47
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  br label %56

55:                                               ; preds = %47
  br label %56

56:                                               ; preds = %55, %53
  %57 = phi ptr [ %54, %53 ], [ @hashatom, %55 ]
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.table, ptr %58, i32 0, i32 2
  store ptr %57, ptr %59, align 8, !tbaa !16
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.table, ptr %60, i64 1
  %62 = load ptr, ptr %7, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.table, ptr %62, i32 0, i32 5
  store ptr %61, ptr %63, align 8, !tbaa !17
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %77, %56
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.table, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = icmp slt i32 %65, %68
  br i1 %69, label %70, label %80

70:                                               ; preds = %64
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.table, ptr %71, i32 0, i32 5
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds ptr, ptr %73, i64 %75
  store ptr null, ptr %76, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %70
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %8, align 4, !tbaa !5
  br label %64, !llvm.loop !18

80:                                               ; preds = %64
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.table, ptr %81, i32 0, i32 4
  store i32 0, ptr %82, align 4, !tbaa !19
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.table, ptr %83, i32 0, i32 3
  store i32 0, ptr %84, align 8, !tbaa !20
  %85 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret ptr %85
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @cmpatom(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @hashatom(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 allocsize(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 }
attributes #5 = { noreturn nounwind }
attributes #6 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"table", !6, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 28, !10, i64 32}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !10, i64 16}
!17 = !{!14, !10, i64 32}
!18 = distinct !{!18, !12}
!19 = !{!14, !6, i64 28}
!20 = !{!14, !6, i64 24}


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

@Table_new.PRIMES = external hidden local_unnamed_addr global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.Table_new = external hidden unnamed_addr constant [92 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Table_new(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp sgt i32 %0, -1
  br i1 %4, label %.preheader, label %5

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 57, ptr noundef nonnull @__PRETTY_FUNCTION__.Table_new) #3
  unreachable

.preheader:                                       ; preds = %3, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 1, %3 ]
  %6 = getelementptr inbounds [10 x i32], ptr @Table_new.PRIMES, i64 0, i64 %indvars.iv
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp slt i32 %7, %0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %8, label %.preheader, label %9, !llvm.loop !9

9:                                                ; preds = %.preheader
  %10 = shl i64 %indvars.iv, 32
  %sext = add i64 %10, -4294967296
  %11 = ashr exact i64 %sext, 32
  %12 = getelementptr inbounds [10 x i32], ptr @Table_new.PRIMES, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = shl nsw i64 %14, 3
  %16 = add nsw i64 %15, 40
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #4
  store i32 %13, ptr %17, align 8, !tbaa !11
  %18 = insertelement <2 x ptr> poison, ptr %1, i64 0
  %19 = insertelement <2 x ptr> %18, ptr %2, i64 1
  %20 = icmp eq <2 x ptr> %19, zeroinitializer
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  %22 = select <2 x i1> %20, <2 x ptr> <ptr @cmpatom, ptr @hashatom>, <2 x ptr> %19
  store <2 x ptr> %22, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %17, i64 40
  %24 = getelementptr inbounds i8, ptr %17, i64 32
  store ptr %23, ptr %24, align 8, !tbaa !15
  %25 = icmp sgt i32 %13, 0
  br i1 %25, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %9
  %wide.trip.count = zext nneg i32 %13 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %26 = icmp ult i32 %13, 4
  br i1 %26, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv26 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next27.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %27 = load ptr, ptr %24, align 8, !tbaa !15
  %28 = getelementptr inbounds ptr, ptr %27, i64 %indvars.iv26
  store ptr null, ptr %28, align 8, !tbaa !14
  %indvars.iv.next27 = or disjoint i64 %indvars.iv26, 1
  %29 = load ptr, ptr %24, align 8, !tbaa !15
  %30 = getelementptr inbounds ptr, ptr %29, i64 %indvars.iv.next27
  store ptr null, ptr %30, align 8, !tbaa !14
  %indvars.iv.next27.1 = or disjoint i64 %indvars.iv26, 2
  %31 = load ptr, ptr %24, align 8, !tbaa !15
  %32 = getelementptr inbounds ptr, ptr %31, i64 %indvars.iv.next27.1
  store ptr null, ptr %32, align 8, !tbaa !14
  %indvars.iv.next27.2 = or disjoint i64 %indvars.iv26, 3
  %33 = load ptr, ptr %24, align 8, !tbaa !15
  %34 = getelementptr inbounds ptr, ptr %33, i64 %indvars.iv.next27.2
  store ptr null, ptr %34, align 8, !tbaa !14
  %indvars.iv.next27.3 = add nuw nsw i64 %indvars.iv26, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv26.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next27.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv26.epil = phi i64 [ %indvars.iv.next27.epil, %.lr.ph.epil ], [ %indvars.iv26.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %35 = load ptr, ptr %24, align 8, !tbaa !15
  %36 = getelementptr inbounds ptr, ptr %35, i64 %indvars.iv26.epil
  store ptr null, ptr %36, align 8, !tbaa !14
  %indvars.iv.next27.epil = add nuw nsw i64 %indvars.iv26.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %9
  %37 = getelementptr inbounds i8, ptr %17, i64 28
  store i32 0, ptr %37, align 4, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %17, i64 24
  store i32 0, ptr %38, align 8, !tbaa !20
  ret ptr %17
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @cmpatom(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @hashatom(ptr noundef) #0

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 = { noreturn 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #3 = { noreturn nounwind }
attributes #4 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"table", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 28, !13, i64 32}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 32}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}
!19 = !{!12, !6, i64 28}
!20 = !{!12, !6, i64 24}


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