; LLVM IR from pmwkaa/monotone :: monotone/cloud/cloud (cloud_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.Cloud = type { i32, ptr, ptr, %struct.List }
%struct.List = type { ptr, ptr }
%struct.CloudMgr = type { %struct.List, i32 }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@__func__.cloud_mgr_drop = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__.cloud_mgr_drop = external hidden unnamed_addr constant [46 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: inlinehint nounwind uwtable
declare hidden void @cloud_free(ptr noundef) #1

; 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) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @cloud_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) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @cloud_mgr_drop(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call ptr @cloud_mgr_find(ptr noundef %10, ptr noundef %11)
  store ptr %12, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %28, label %15

15:                                               ; preds = %3
  %16 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %17 = trunc i8 %16 to i1
  br i1 %17, label %27, label %18

18:                                               ; preds = %15
  %19 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %20 = getelementptr inbounds %struct.Runtime, ptr %19, i32 0, i32 1
  %21 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %22 = getelementptr inbounds %struct.Runtime, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 @str_size(ptr noundef %23)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call ptr @str_of(ptr noundef %25)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %20, ptr noundef %22, ptr noundef @.str, ptr noundef @__func__.cloud_mgr_drop, i32 noundef 132, ptr noundef @.str.2, i32 noundef %24, ptr noundef %26) #7
  unreachable

27:                                               ; preds = %15
  store i32 1, ptr %8, align 4
  br label %58

28:                                               ; preds = %3
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Cloud, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %33, label %42

33:                                               ; preds = %28
  %34 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %35 = getelementptr inbounds %struct.Runtime, ptr %34, i32 0, i32 1
  %36 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %37 = getelementptr inbounds %struct.Runtime, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call i32 @str_size(ptr noundef %38)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call ptr @str_of(ptr noundef %40)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %35, ptr noundef %37, ptr noundef @.str, ptr noundef @__func__.cloud_mgr_drop, i32 noundef 138, ptr noundef @.str.3, i32 noundef %39, ptr noundef %41) #7
  unreachable

42:                                               ; preds = %28
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Cloud, ptr %43, i32 0, i32 3
  call void @list_unlink(ptr noundef %44)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.CloudMgr, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 8, !tbaa !17
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %46, align 8, !tbaa !17
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.CloudMgr, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !17
  %52 = icmp sge i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %42
  br label %55

54:                                               ; preds = %42
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str, i32 noundef 142, ptr noundef @__PRETTY_FUNCTION__.cloud_mgr_drop) #8
  unreachable

55:                                               ; preds = %53
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @cloud_free(ptr noundef %56)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  call void @cloud_mgr_save(ptr noundef %57)
  store i32 0, ptr %8, align 4
  br label %58

58:                                               ; preds = %55, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %59 = load i32, ptr %8, align 4
  switch i32 %59, label %61 [
    i32 0, label %60
    i32 1, label %60
  ]

60:                                               ; preds = %58, %58
  ret void

61:                                               ; preds = %58
  unreachable
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }
attributes #8 = { noreturn 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, !15, i64 0}
!14 = !{!"Cloud", !15, i64 0, !6, i64 8, !6, i64 16, !16, i64 24}
!15 = !{!"int", !7, i64 0}
!16 = !{!"List", !6, i64 0, !6, i64 8}
!17 = !{!18, !15, i64 16}
!18 = !{!"CloudMgr", !16, i64 0, !15, i64 16}


; 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 [82 x i8], align 1
@__func__.cloud_mgr_drop = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__.cloud_mgr_drop = external hidden unnamed_addr constant [46 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @cloud_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 #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @cloud_mgr_drop(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #2 {
  %4 = tail call ptr @cloud_mgr_find(ptr noundef %0, ptr noundef %1)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %11

5:                                                ; preds = %3
  br i1 %2, label %27, label %6

6:                                                ; preds = %5
  %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, ptr noundef nonnull @__func__.cloud_mgr_drop, i32 noundef 132, ptr noundef nonnull @.str.2, i32 noundef %9, ptr noundef %10) #5
  unreachable

11:                                               ; preds = %3
  %12 = load i32, ptr %4, align 8, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %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, ptr noundef nonnull @__func__.cloud_mgr_drop, i32 noundef 138, ptr noundef nonnull @.str.3, i32 noundef %17, ptr noundef %18) #5
  unreachable

19:                                               ; preds = %11
  %20 = getelementptr inbounds i8, ptr %4, i64 24
  tail call void @list_unlink(ptr noundef nonnull %20)
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %21, align 8, !tbaa !12
  %24 = icmp sgt i32 %22, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str, i32 noundef 142, ptr noundef nonnull @__PRETTY_FUNCTION__.cloud_mgr_drop) #6
  unreachable

26:                                               ; preds = %19
  tail call void @cloud_free(ptr noundef nonnull %4)
  tail call void @cloud_mgr_save(ptr noundef nonnull %0)
  br label %27

27:                                               ; preds = %5, %26
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 #5 = { noreturn }
attributes #6 = { noreturn 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, !7, i64 0}
!6 = !{!"Cloud", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"List", !10, i64 0, !10, i64 8}
!12 = !{!13, !7, i64 16}
!13 = !{!"CloudMgr", !11, i64 0, !7, i64 16}


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