; 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.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }
%struct.Storage = type { %struct.List, i32, i32, i64, i64, ptr, ptr, %struct.List }
%struct.List = type { ptr, ptr }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.storage_mgr_rename = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @storage_mgr_find(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_size(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @str_of(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @storage_mgr_save(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @str_compare_raw(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #5

; Function Attrs: nounwind uwtable
define dso_local void @storage_mgr_rename(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = zext i1 %3 to i8
  store i8 %12, ptr %8, align 1, !tbaa !9
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call zeroext i1 @str_compare_raw(ptr noundef %13, ptr noundef @.str, i32 noundef 4)
  %15 = xor i1 %14, true
  %16 = xor i1 %15, true
  %17 = zext i1 %16 to i32
  %18 = sext i32 %17 to i64
  %19 = call i64 @llvm.expect.i64(i64 %18, i64 0)
  %20 = icmp ne i64 %19, 0
  br i1 %20, label %21, label %30

21:                                               ; preds = %4
  %22 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %23 = getelementptr inbounds %struct.Runtime, ptr %22, i32 0, i32 1
  %24 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %25 = getelementptr inbounds %struct.Runtime, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call i32 @str_size(ptr noundef %26)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call ptr @str_of(ptr noundef %28)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %23, ptr noundef %25, ptr noundef @.str.1, ptr noundef @__func__.storage_mgr_rename, i32 noundef 336, ptr noundef @.str.10, i32 noundef %27, ptr noundef %29) #6
  unreachable

30:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call ptr @storage_mgr_find(ptr noundef %31, ptr noundef %32)
  store ptr %33, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %49, label %36

36:                                               ; preds = %30
  %37 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %38 = trunc i8 %37 to i1
  br i1 %38, label %48, label %39

39:                                               ; preds = %36
  %40 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %41 = getelementptr inbounds %struct.Runtime, ptr %40, i32 0, i32 1
  %42 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %43 = getelementptr inbounds %struct.Runtime, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call i32 @str_size(ptr noundef %44)
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = call ptr @str_of(ptr noundef %46)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %41, ptr noundef %43, ptr noundef @.str.1, ptr noundef @__func__.storage_mgr_rename, i32 noundef 343, ptr noundef @.str.4, i32 noundef %45, ptr noundef %47) #6
  unreachable

48:                                               ; preds = %36
  store i32 1, ptr %10, align 4
  br label %70

49:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = call ptr @storage_mgr_find(ptr noundef %50, ptr noundef %51)
  store ptr %52, ptr %11, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %64

55:                                               ; preds = %49
  %56 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %57 = getelementptr inbounds %struct.Runtime, ptr %56, i32 0, i32 1
  %58 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %59 = getelementptr inbounds %struct.Runtime, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i32 @str_size(ptr noundef %60)
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = call ptr @str_of(ptr noundef %62)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %57, ptr noundef %59, ptr noundef @.str.1, ptr noundef @__func__.storage_mgr_rename, i32 noundef 350, ptr noundef @.str.2, i32 noundef %61, ptr noundef %63) #6
  unreachable

64:                                               ; preds = %49
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Storage, ptr %65, i32 0, i32 6
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  call void @source_set_name(ptr noundef %67, ptr noundef %68)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  call void @storage_mgr_save(ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  store i32 0, ptr %10, align 4
  br label %70

70:                                               ; preds = %64, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %71 = load i32, ptr %10, align 4
  switch i32 %71, label %73 [
    i32 0, label %72
    i32 1, label %72
  ]

72:                                               ; preds = %70, %70
  ret void

73:                                               ; preds = %70
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 = { inlinehint noreturn 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 #5 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { noreturn }
attributes #7 = { 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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 48}
!14 = !{!"Storage", !15, i64 0, !16, i64 16, !16, i64 20, !17, i64 24, !17, i64 32, !6, i64 40, !6, i64 48, !15, i64 56}
!15 = !{!"List", !6, i64 0, !6, i64 8}
!16 = !{!"int", !7, i64 0}
!17 = !{!"long", !7, i64 0}


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

%struct.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.storage_mgr_rename = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @storage_mgr_find(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_size(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @str_of(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @storage_mgr_rename(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) local_unnamed_addr #2 {
  %5 = tail call zeroext i1 @str_compare_raw(ptr noundef %1, ptr noundef nonnull @.str, i32 noundef 4)
  br i1 %5, label %6, label %11, !prof !5

6:                                                ; preds = %4
  %7 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = tail call i32 @str_size(ptr noundef %1)
  %10 = tail call ptr @str_of(ptr noundef %1)
  tail call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.storage_mgr_rename, i32 noundef 336, ptr noundef nonnull @.str.10, i32 noundef %9, ptr noundef %10) #4
  unreachable

11:                                               ; preds = %4
  %12 = tail call ptr @storage_mgr_find(ptr noundef %0, ptr noundef %1)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %19

13:                                               ; preds = %11
  br i1 %3, label %29, label %14

14:                                               ; preds = %13
  %15 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = tail call i32 @str_size(ptr noundef %1)
  %18 = tail call ptr @str_of(ptr noundef %1)
  tail call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %16, ptr noundef nonnull %15, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.storage_mgr_rename, i32 noundef 343, ptr noundef nonnull @.str.4, i32 noundef %17, ptr noundef %18) #4
  unreachable

19:                                               ; preds = %11
  %20 = tail call ptr @storage_mgr_find(ptr noundef %0, ptr noundef %2)
  %.not16 = icmp eq ptr %20, null
  br i1 %.not16, label %26, label %21

21:                                               ; preds = %19
  %22 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = tail call i32 @str_size(ptr noundef %2)
  %25 = tail call ptr @str_of(ptr noundef %2)
  tail call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %23, ptr noundef nonnull %22, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.storage_mgr_rename, i32 noundef 350, ptr noundef nonnull @.str.2, i32 noundef %24, ptr noundef %25) #4
  unreachable

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %12, i64 48
  %28 = load ptr, ptr %27, align 8, !tbaa !6
  tail call void @source_set_name(ptr noundef %28, ptr noundef %2)
  tail call void @storage_mgr_save(ptr noundef %0)
  br label %29

29:                                               ; preds = %13, %26
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { inlinehint noreturn 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 = { noreturn }

!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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !9, i64 48}
!7 = !{!"Storage", !8, i64 0, !12, i64 16, !12, i64 20, !13, i64 24, !13, i64 32, !9, i64 40, !9, i64 48, !8, i64 56}
!8 = !{!"List", !9, i64 0, !9, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"long", !10, i64 0}


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