; 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.CloudMgr = type { %struct.List, i32 }
%struct.List = type { ptr, ptr }
%struct.Cloud = type { i32, ptr, ptr, %struct.List }
%struct.CloudConfig = type { %struct.Str, %struct.Str, %struct.Str, %struct.Str, %struct.Str, i8 }
%struct.Str = type { ptr, ptr, i8 }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.cloud_mgr_show = external hidden unnamed_addr constant [15 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: nounwind uwtable
declare dso_local ptr @cloud_mgr_find(ptr noundef, ptr noundef) #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, ...) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local void @cloud_mgr_show(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 ptr, align 8
  %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
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %44

12:                                               ; preds = %3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.CloudMgr, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  call void @encode_map(ptr noundef %13, i32 noundef %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.CloudMgr, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.List, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  store ptr %20, ptr %7, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %39, %12
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.CloudMgr, ptr %23, i32 0, i32 0
  %25 = icmp ne ptr %22, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %43

27:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 -24
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Cloud, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds %struct.CloudConfig, ptr %33, i32 0, i32 0
  call void @encode_string(ptr noundef %30, ptr noundef %34) #6
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Cloud, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  call void @cloud_config_write(ptr noundef %37, ptr noundef %38, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %39

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

43:                                               ; preds = %26
  br label %64

44:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call ptr @cloud_mgr_find(ptr noundef %45, ptr noundef %46)
  store ptr %47, ptr %9, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %59, label %50

50:                                               ; preds = %44
  %51 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %52 = getelementptr inbounds %struct.Runtime, ptr %51, i32 0, i32 1
  %53 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %54 = getelementptr inbounds %struct.Runtime, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call i32 @str_size(ptr noundef %55)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call ptr @str_of(ptr noundef %57)
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %52, ptr noundef %54, ptr noundef @.str, ptr noundef @__func__.cloud_mgr_show, i32 noundef 207, ptr noundef @.str.2, i32 noundef %56, ptr noundef %58) #8
  unreachable

59:                                               ; preds = %44
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Cloud, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  call void @cloud_config_write(ptr noundef %62, ptr noundef %63, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %64

64:                                               ; preds = %59, %43
  ret void
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cloud_config_write(ptr noundef, ptr noundef, i1 noundef zeroext) #4

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

%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
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.cloud_mgr_show = external hidden unnamed_addr constant [15 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: nounwind uwtable
declare dso_local ptr @cloud_mgr_find(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !5
  tail call void @encode_map(ptr noundef %2, i32 noundef %7) #5
  %.022 = load ptr, ptr %0, align 8, !tbaa !12
  %.not2123 = icmp eq ptr %.022, %0
  br i1 %.not2123, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.024 = phi ptr [ %.0, %.lr.ph ], [ %.022, %5 ]
  %8 = getelementptr inbounds i8, ptr %.024, i64 -8
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  tail call void @encode_string(ptr noundef %2, ptr noundef %9) #5
  %10 = load ptr, ptr %8, align 8, !tbaa !13
  tail call void @cloud_config_write(ptr noundef %10, ptr noundef %2, i1 noundef zeroext true)
  %.0 = load ptr, ptr %.024, align 8, !tbaa !12
  %.not21 = icmp eq ptr %.0, %0
  br i1 %.not21, label %.loopexit, label %.lr.ph, !llvm.loop !15

11:                                               ; preds = %3
  %12 = tail call ptr @cloud_mgr_find(ptr noundef %0, ptr noundef nonnull %1)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %18

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

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %12, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  tail call void @cloud_config_write(ptr noundef %20, ptr noundef %2, i1 noundef zeroext true)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %5, %18
  ret void
}

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #3 = { 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 = { 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 #5 = { hot }
attributes #6 = { 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 = !{!6, !11, i64 16}
!6 = !{!"CloudMgr", !7, i64 0, !11, i64 16}
!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 16}
!14 = !{!"Cloud", !11, i64 0, !8, i64 8, !8, i64 16, !7, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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