; LLVM IR from ShahjalalShohag/code-library :: Data Structures/Persistent Trie.ll (Z6insertii)

; 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.node_t = type { i32, [2 x ptr] }

@last = external dso_local global ptr, align 8
@version = external dso_local global [100100 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6insertii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %9 = load ptr, ptr @last, align 8, !tbaa !9
  %10 = call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %9)
  store ptr %10, ptr @last, align 8, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [100100 x ptr], ptr @version, i64 0, i64 %12
  store ptr %10, ptr %13, align 8, !tbaa !9
  store ptr %10, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 14, ptr %6, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %37, %2
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp sge i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %40

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = ashr i32 %19, %20
  %22 = and i32 %21, 1
  store i32 %22, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.node_t, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x ptr], ptr %24, i64 0, i64 %26
  store ptr %27, ptr %8, align 8, !tbaa !9
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %29)
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %30, ptr %31, align 8, !tbaa !9
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  store ptr %33, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.node_t, ptr %35, i32 0, i32 0
  store i32 %34, ptr %36, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %37

37:                                               ; preds = %18
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = add nsw i32 %38, -1
  store i32 %39, ptr %6, align 4, !tbaa !5
  br label %14, !llvm.loop !13

40:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS6node_t", !6, i64 0, !7, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@last = external dso_local local_unnamed_addr global ptr, align 8
@version = external dso_local local_unnamed_addr global [100100 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6insertii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr @last, align 8, !tbaa !5
  %4 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  store ptr %4, ptr @last, align 8, !tbaa !5
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds [100100 x ptr], ptr @version, i64 0, i64 %5
  store ptr %4, ptr %6, align 8, !tbaa !5
  %7 = lshr i32 %0, 14
  %8 = and i32 %7, 1
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  %10 = zext nneg i32 %8 to i64
  %11 = getelementptr inbounds [2 x ptr], ptr %9, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
  store ptr %13, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %13, align 8, !tbaa !9
  %14 = lshr i32 %0, 13
  %15 = and i32 %14, 1
  %16 = getelementptr inbounds i8, ptr %13, i64 8
  %17 = zext nneg i32 %15 to i64
  %18 = getelementptr inbounds [2 x ptr], ptr %16, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %19)
  store ptr %20, ptr %18, align 8, !tbaa !5
  store i32 %1, ptr %20, align 8, !tbaa !9
  %21 = lshr i32 %0, 12
  %22 = and i32 %21, 1
  %23 = getelementptr inbounds i8, ptr %20, i64 8
  %24 = zext nneg i32 %22 to i64
  %25 = getelementptr inbounds [2 x ptr], ptr %23, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %26)
  store ptr %27, ptr %25, align 8, !tbaa !5
  store i32 %1, ptr %27, align 8, !tbaa !9
  %28 = lshr i32 %0, 11
  %29 = and i32 %28, 1
  %30 = getelementptr inbounds i8, ptr %27, i64 8
  %31 = zext nneg i32 %29 to i64
  %32 = getelementptr inbounds [2 x ptr], ptr %30, i64 0, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %33)
  store ptr %34, ptr %32, align 8, !tbaa !5
  store i32 %1, ptr %34, align 8, !tbaa !9
  %35 = lshr i32 %0, 10
  %36 = and i32 %35, 1
  %37 = getelementptr inbounds i8, ptr %34, i64 8
  %38 = zext nneg i32 %36 to i64
  %39 = getelementptr inbounds [2 x ptr], ptr %37, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %40)
  store ptr %41, ptr %39, align 8, !tbaa !5
  store i32 %1, ptr %41, align 8, !tbaa !9
  %42 = lshr i32 %0, 9
  %43 = and i32 %42, 1
  %44 = getelementptr inbounds i8, ptr %41, i64 8
  %45 = zext nneg i32 %43 to i64
  %46 = getelementptr inbounds [2 x ptr], ptr %44, i64 0, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %47)
  store ptr %48, ptr %46, align 8, !tbaa !5
  store i32 %1, ptr %48, align 8, !tbaa !9
  %49 = lshr i32 %0, 8
  %50 = and i32 %49, 1
  %51 = getelementptr inbounds i8, ptr %48, i64 8
  %52 = zext nneg i32 %50 to i64
  %53 = getelementptr inbounds [2 x ptr], ptr %51, i64 0, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %54)
  store ptr %55, ptr %53, align 8, !tbaa !5
  store i32 %1, ptr %55, align 8, !tbaa !9
  %56 = lshr i32 %0, 7
  %57 = and i32 %56, 1
  %58 = getelementptr inbounds i8, ptr %55, i64 8
  %59 = zext nneg i32 %57 to i64
  %60 = getelementptr inbounds [2 x ptr], ptr %58, i64 0, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %61)
  store ptr %62, ptr %60, align 8, !tbaa !5
  store i32 %1, ptr %62, align 8, !tbaa !9
  %63 = lshr i32 %0, 6
  %64 = and i32 %63, 1
  %65 = getelementptr inbounds i8, ptr %62, i64 8
  %66 = zext nneg i32 %64 to i64
  %67 = getelementptr inbounds [2 x ptr], ptr %65, i64 0, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %68)
  store ptr %69, ptr %67, align 8, !tbaa !5
  store i32 %1, ptr %69, align 8, !tbaa !9
  %70 = lshr i32 %0, 5
  %71 = and i32 %70, 1
  %72 = getelementptr inbounds i8, ptr %69, i64 8
  %73 = zext nneg i32 %71 to i64
  %74 = getelementptr inbounds [2 x ptr], ptr %72, i64 0, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %75)
  store ptr %76, ptr %74, align 8, !tbaa !5
  store i32 %1, ptr %76, align 8, !tbaa !9
  %77 = lshr i32 %0, 4
  %78 = and i32 %77, 1
  %79 = getelementptr inbounds i8, ptr %76, i64 8
  %80 = zext nneg i32 %78 to i64
  %81 = getelementptr inbounds [2 x ptr], ptr %79, i64 0, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %82)
  store ptr %83, ptr %81, align 8, !tbaa !5
  store i32 %1, ptr %83, align 8, !tbaa !9
  %84 = lshr i32 %0, 3
  %85 = and i32 %84, 1
  %86 = getelementptr inbounds i8, ptr %83, i64 8
  %87 = zext nneg i32 %85 to i64
  %88 = getelementptr inbounds [2 x ptr], ptr %86, i64 0, i64 %87
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %89)
  store ptr %90, ptr %88, align 8, !tbaa !5
  store i32 %1, ptr %90, align 8, !tbaa !9
  %91 = lshr i32 %0, 2
  %92 = and i32 %91, 1
  %93 = getelementptr inbounds i8, ptr %90, i64 8
  %94 = zext nneg i32 %92 to i64
  %95 = getelementptr inbounds [2 x ptr], ptr %93, i64 0, i64 %94
  %96 = load ptr, ptr %95, align 8, !tbaa !5
  %97 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %96)
  store ptr %97, ptr %95, align 8, !tbaa !5
  store i32 %1, ptr %97, align 8, !tbaa !9
  %98 = lshr i32 %0, 1
  %99 = and i32 %98, 1
  %100 = getelementptr inbounds i8, ptr %97, i64 8
  %101 = zext nneg i32 %99 to i64
  %102 = getelementptr inbounds [2 x ptr], ptr %100, i64 0, i64 %101
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %103)
  store ptr %104, ptr %102, align 8, !tbaa !5
  store i32 %1, ptr %104, align 8, !tbaa !9
  %105 = and i32 %0, 1
  %106 = getelementptr inbounds i8, ptr %104, i64 8
  %107 = zext nneg i32 %105 to i64
  %108 = getelementptr inbounds [2 x ptr], ptr %106, i64 0, i64 %107
  %109 = load ptr, ptr %108, align 8, !tbaa !5
  %110 = tail call noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24) %109)
  store ptr %110, ptr %108, align 8, !tbaa !5
  store i32 %1, ptr %110, align 8, !tbaa !9
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN6node_t5cloneEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

!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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS6node_t", !11, i64 0, !7, i64 8}
!11 = !{!"int", !7, i64 0}


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