; LLVM IR from JessonYue/LeetCodeLearning :: Array/zhangjunwei/7.26-8.1/lru_cache.ll (Z14lRUCacheCreatei)

; 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.LRUCache = type { i32, i32, ptr, ptr, ptr }
%struct.node = type { i32, i32, ptr, ptr }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1
@__PRETTY_FUNCTION__._Z14lRUCacheCreatei = external hidden unnamed_addr constant [30 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: mustprogress nounwind uwtable
define dso_local noundef ptr @_Z14lRUCacheCreatei(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %9

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 55, ptr noundef @__PRETTY_FUNCTION__._Z14lRUCacheCreatei) #5
  unreachable

8:                                                ; No predecessors!
  br label %9

9:                                                ; preds = %8, %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %10 = call noalias ptr @malloc(i64 noundef 32) #7
  store ptr %10, ptr %3, align 8, !tbaa !9
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = mul i64 %12, 16
  %14 = call noalias ptr @malloc(i64 noundef %13) #7
  %15 = load ptr, ptr %3, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.LRUCache, ptr %15, i32 0, i32 2
  store ptr %14, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.LRUCache, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul i64 %21, 16
  call void @llvm.memset.p0.i64(ptr align 8 %19, i8 0, i64 %22, i1 false)
  %23 = call noalias ptr @malloc(i64 noundef 24) #7
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.LRUCache, ptr %24, i32 0, i32 3
  store ptr %23, ptr %25, align 8, !tbaa !13
  %26 = call noalias ptr @malloc(i64 noundef 24) #7
  %27 = load ptr, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.LRUCache, ptr %27, i32 0, i32 4
  store ptr %26, ptr %28, align 8, !tbaa !14
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.LRUCache, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 2
  store ptr null, ptr %32, align 8, !tbaa !15
  %33 = load ptr, ptr %3, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.LRUCache, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load ptr, ptr %3, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.LRUCache, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.node, ptr %38, i32 0, i32 3
  store ptr %35, ptr %39, align 8, !tbaa !17
  %40 = load ptr, ptr %3, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.LRUCache, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load ptr, ptr %3, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.LRUCache, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds %struct.node, ptr %45, i32 0, i32 2
  store ptr %42, ptr %46, align 8, !tbaa !15
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.LRUCache, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = getelementptr inbounds %struct.node, ptr %49, i32 0, i32 3
  store ptr null, ptr %50, align 8, !tbaa !17
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.LRUCache, ptr %51, i32 0, i32 0
  store i32 0, ptr %52, align 8, !tbaa !18
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = load ptr, ptr %3, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.LRUCache, ptr %54, i32 0, i32 1
  store i32 %53, ptr %55, align 4, !tbaa !19
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret ptr %56
}

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { noreturn nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS8LRUCache", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 16}
!14 = !{!12, !10, i64 24}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTS4node", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16}
!17 = !{!16, !10, i64 16}
!18 = !{!12, !6, i64 0}
!19 = !{!12, !6, i64 4}


; 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 [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1
@__PRETTY_FUNCTION__._Z14lRUCacheCreatei = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noalias noundef ptr @_Z14lRUCacheCreatei(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp sgt i32 %0, 0
  br i1 %2, label %4, label %3

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

4:                                                ; preds = %1
  %5 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #5
  %6 = zext nneg i32 %0 to i64
  %7 = shl nuw nsw i64 %6, 4
  %calloc = tail call ptr @calloc(i64 1, i64 %7)
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %calloc, ptr %8, align 8, !tbaa !5
  %9 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #5
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %9, ptr %10, align 8, !tbaa !11
  %11 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #5
  %12 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %11, ptr %12, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr null, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %11, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %9, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr null, ptr %16, align 8, !tbaa !15
  store i32 0, ptr %5, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %0, ptr %17, align 4, !tbaa !17
  ret ptr %5
}

; 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: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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, !10, i64 8}
!6 = !{!"_ZTS8LRUCache", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 24}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS4node", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!15 = !{!14, !10, i64 16}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass