; 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: inlinehint nounwind uwtable
declare hidden void @storage_mgr_save(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @storage_mgr_rename_cloud(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.StorageMgr, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.List, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %7, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %38, %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.StorageMgr, ptr %16, i32 0, i32 0
  %18 = icmp ne ptr %15, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 -56
  store ptr %22, ptr %9, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Storage, ptr %23, i32 0, i32 6
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = getelementptr inbounds %struct.Source, ptr %25, i32 0, i32 3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call zeroext i1 @str_compare(ptr noundef %26, ptr noundef %27)
  br i1 %28, label %30, label %29

29:                                               ; preds = %20
  store i32 4, ptr %8, align 4
  br label %35

30:                                               ; preds = %20
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Storage, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  call void @source_set_cloud(ptr noundef %33, ptr noundef %34)
  store i32 0, ptr %8, align 4
  br label %35

35:                                               ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %36 = load i32, ptr %8, align 4
  switch i32 %36, label %44 [
    i32 0, label %37
    i32 4, label %38
  ]

37:                                               ; preds = %35
  br label %38

38:                                               ; preds = %37, %35
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.List, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  store ptr %41, ptr %7, align 8, !tbaa !5
  br label %14, !llvm.loop !17

42:                                               ; preds = %19
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @storage_mgr_save(ptr noundef %43)
  ret void

44:                                               ; preds = %35
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @str_compare(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @source_set_cloud(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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, !6, i64 0}
!10 = !{!"StorageMgr", !11, i64 0, !12, i64 16, !6, i64 24}
!11 = !{!"List", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 48}
!14 = !{!"Storage", !11, i64 0, !12, i64 16, !12, i64 20, !15, i64 24, !15, i64 32, !6, i64 40, !6, i64 48, !11, i64 56}
!15 = !{!"long", !7, i64 0}
!16 = !{!11, !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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: inlinehint nounwind uwtable
declare hidden void @storage_mgr_save(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @storage_mgr_rename_cloud(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %.011 = load ptr, ptr %0, align 8, !tbaa !5
  %.not12 = icmp eq ptr %.011, %0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %10, %3
  tail call void @storage_mgr_save(ptr noundef nonnull %0)
  ret void

.lr.ph:                                           ; preds = %3, %10
  %.013 = phi ptr [ %.0, %10 ], [ %.011, %3 ]
  %4 = getelementptr inbounds i8, ptr %.013, i64 -8
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %5, i64 64
  %7 = tail call zeroext i1 @str_compare(ptr noundef nonnull %6, ptr noundef %1)
  br i1 %7, label %8, label %10

8:                                                ; preds = %.lr.ph
  %9 = load ptr, ptr %4, align 8, !tbaa !10
  tail call void @source_set_cloud(ptr noundef %9, ptr noundef %2)
  br label %10

10:                                               ; preds = %.lr.ph, %8
  %.0 = load ptr, ptr %.013, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, %0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @str_compare(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @source_set_cloud(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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


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