; LLVM IR from pmwkaa/monotone :: monotone/engine/storage (storage_mgr)

; 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.StorageMgr = type { %struct.List, i32, ptr }
%struct.List = type { ptr, ptr }
%struct.Storage = type { %struct.List, i32, i32, i64, i64, ptr, ptr, %struct.List }
%struct.Source = type { %struct.Uuid, %struct.Str, %struct.Str, %struct.Str, i8, i8, i8, i64, i64, %struct.Str, i64, %struct.Str, %struct.Str }
%struct.Uuid = type { i64, i64 }
%struct.Str = type { ptr, ptr, i8 }

; 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 @storage_mgr_show(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %6, align 1, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.StorageMgr, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !11
  call void @encode_map(ptr noundef %10, i32 noundef %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.StorageMgr, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct.List, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  store ptr %17, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %36, %3
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.StorageMgr, ptr %20, i32 0, i32 0
  %22 = icmp ne ptr %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %40

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 -56
  store ptr %26, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Storage, ptr %28, i32 0, i32 6
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %struct.Source, ptr %30, i32 0, i32 1
  call void @encode_string(ptr noundef %27, ptr noundef %31) #4
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i8, ptr %6, align 1, !tbaa !9, !range !19, !noundef !20
  %35 = trunc i8 %34 to i1
  call void @storage_show(ptr noundef %32, ptr noundef %33, i1 noundef zeroext %35) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %36

36:                                               ; preds = %24
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.List, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  store ptr %39, ptr %7, align 8, !tbaa !5
  br label %18, !llvm.loop !22

40:                                               ; preds = %23
  ret void
}

; Function Attrs: alwaysinline hot nounwind uwtable
declare hidden void @encode_map(ptr noundef, i32 noundef) #2

; Function Attrs: alwaysinline hot nounwind uwtable
declare hidden void @encode_string(ptr noundef, ptr noundef) #2

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @storage_show(ptr noundef, ptr noundef, i1 noundef zeroext) #3

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 = { alwaysinline hot 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 #3 = { hot inlinehint 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 #4 = { hot }
attributes #5 = { 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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !14, i64 16}
!12 = !{!"StorageMgr", !13, i64 0, !14, i64 16, !6, i64 24}
!13 = !{!"List", !6, i64 0, !6, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !6, i64 48}
!17 = !{!"Storage", !13, i64 0, !14, i64 16, !14, i64 20, !18, i64 24, !18, i64 32, !6, i64 40, !6, i64 48, !13, i64 56}
!18 = !{!"long", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!13, !6, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local void @storage_mgr_show(ptr noundef readonly %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !5
  tail call void @encode_map(ptr noundef %1, i32 noundef %5) #3
  %.011 = load ptr, ptr %0, align 8, !tbaa !12
  %.not12 = icmp eq ptr %.011, %0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.013 = phi ptr [ %.0, %.lr.ph ], [ %.011, %3 ]
  %6 = getelementptr inbounds i8, ptr %.013, i64 -56
  %7 = getelementptr inbounds i8, ptr %.013, i64 -8
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  tail call void @encode_string(ptr noundef %1, ptr noundef nonnull %9) #3
  tail call void @storage_show(ptr noundef nonnull %6, ptr noundef %1, i1 noundef zeroext %2) #3
  %.0 = load ptr, ptr %.013, align 8, !tbaa !12
  %.not = icmp eq ptr %.0, %0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16
}

; Function Attrs: alwaysinline hot nounwind uwtable
declare hidden void @encode_map(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline hot nounwind uwtable
declare hidden void @encode_string(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @storage_show(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

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 = { alwaysinline hot 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 = { hot inlinehint 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 #3 = { hot }

!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, !11, i64 16}
!6 = !{!"StorageMgr", !7, i64 0, !11, i64 16, !8, i64 24}
!7 = !{!"List", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!7, !8, i64 0}
!13 = !{!14, !8, i64 48}
!14 = !{!"Storage", !7, i64 0, !11, i64 16, !11, i64 20, !15, i64 24, !15, i64 32, !8, i64 40, !8, i64 48, !7, i64 56}
!15 = !{!"long", !9, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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