; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_universal)

; 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.HandleList = type { %struct.MList, i32, i32, i32, i32 }
%struct.MList = type { i32, ptr }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct.HandleObjectCreate = type { ptr, ptr, [8 x i64], i32, i64, ptr, i32 }
%struct.Property = type { ptr, ptr, ptr, [0 x 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare ptr @mornMapRead(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @m_PropertyRead(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %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
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.HandleList, ptr %16, i64 -1
  %18 = getelementptr inbounds %struct.HandleList, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.MList, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.MHandle, ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  store ptr %24, ptr %10, align 8, !tbaa !5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.HandleObjectCreate, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %91

30:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.HandleObjectCreate, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call ptr @mornMapRead(ptr noundef %33, ptr noundef %34, i32 noundef -1, ptr noundef null, ptr noundef %12)
  store ptr %35, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %30
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %90

39:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Property, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %48

44:                                               ; preds = %39
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Property, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  br label %52

48:                                               ; preds = %39
  %49 = load ptr, ptr %13, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Property, ptr %49, i32 0, i32 3
  %51 = getelementptr inbounds [0 x i8], ptr %50, i64 0, i64 0
  br label %52

52:                                               ; preds = %48, %44
  %53 = phi ptr [ %47, %44 ], [ %51, %48 ]
  store ptr %53, ptr %14, align 8, !tbaa !5
  %54 = load i32, ptr %12, align 4, !tbaa !18
  %55 = sext i32 %54 to i64
  %56 = sub i64 %55, 24
  %57 = trunc i64 %56 to i32
  store i32 %57, ptr %12, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %58 = load i32, ptr %12, align 4, !tbaa !18
  store i32 %58, ptr %15, align 4, !tbaa !18
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %80

61:                                               ; preds = %52
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i32, ptr %62, align 4, !tbaa !18
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %65, label %77

65:                                               ; preds = %61
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !18
  %68 = load i32, ptr %15, align 4, !tbaa !18
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %70, label %73

70:                                               ; preds = %65
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i32, ptr %71, align 4, !tbaa !18
  br label %75

73:                                               ; preds = %65
  %74 = load i32, ptr %15, align 4, !tbaa !18
  br label %75

75:                                               ; preds = %73, %70
  %76 = phi i32 [ %72, %70 ], [ %74, %73 ]
  store i32 %76, ptr %15, align 4, !tbaa !18
  br label %77

77:                                               ; preds = %75, %61
  %78 = load i32, ptr %12, align 4, !tbaa !18
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %78, ptr %79, align 4, !tbaa !18
  br label %80

80:                                               ; preds = %77, %52
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %88

83:                                               ; preds = %80
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = load i32, ptr %15, align 4, !tbaa !18
  %87 = sext i32 %86 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 1 %85, i64 %87, i1 false)
  br label %88

88:                                               ; preds = %83, %80
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %89, ptr %5, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %90

90:                                               ; preds = %88, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %91

91:                                               ; preds = %90, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %92 = load ptr, ptr %5, align 8
  ret ptr %92
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 8}
!10 = !{!"HandleList", !11, i64 0, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!11 = !{!"MList", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"MHandle", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16}
!15 = !{!16, !6, i64 8}
!16 = !{!"HandleObjectCreate", !6, i64 0, !6, i64 8, !7, i64 16, !12, i64 80, !17, i64 88, !6, i64 96, !12, i64 104}
!17 = !{!"long", !7, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"Property", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare ptr @mornMapRead(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @m_PropertyRead(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef writeonly %2, ptr noundef %3) local_unnamed_addr #3 {
  %5 = alloca i32, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 -24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = icmp eq ptr %12, null
  br i1 %13, label %30, label %14

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 0, ptr %5, align 4, !tbaa !18
  %15 = call ptr @mornMapRead(ptr noundef nonnull %12, ptr noundef %1, i32 noundef -1, ptr noundef null, ptr noundef nonnull %5) #5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %29, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %15, align 8, !tbaa !19
  %.not = icmp eq ptr %18, null
  %19 = getelementptr inbounds i8, ptr %15, i64 24
  %20 = select i1 %.not, ptr %19, ptr %18
  %21 = load i32, ptr %5, align 4, !tbaa !18
  %22 = add i32 %21, -24
  store i32 %22, ptr %5, align 4, !tbaa !18
  %.not28 = icmp eq ptr %3, null
  br i1 %.not28, label %26, label %23

23:                                               ; preds = %17
  %24 = load i32, ptr %3, align 4, !tbaa !18
  %25 = icmp sgt i32 %24, 0
  %. = call i32 @llvm.smin.i32(i32 %24, i32 %22)
  %.0 = select i1 %25, i32 %., i32 %22
  store i32 %22, ptr %3, align 4, !tbaa !18
  br label %26

26:                                               ; preds = %23, %17
  %.1 = phi i32 [ %.0, %23 ], [ %22, %17 ]
  %.not29 = icmp eq ptr %2, null
  br i1 %.not29, label %29, label %27

27:                                               ; preds = %26
  %28 = sext i32 %.1 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %2, ptr nonnull align 1 %20, i64 %28, i1 false)
  br label %29

29:                                               ; preds = %26, %27, %14
  %.020 = phi ptr [ null, %14 ], [ %20, %27 ], [ %20, %26 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %30

30:                                               ; preds = %4, %29
  %.121 = phi ptr [ %.020, %29 ], [ null, %4 ]
  ret ptr %.121
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 8}
!6 = !{!"HandleList", !7, i64 0, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28}
!7 = !{!"MList", !8, i64 0, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 16}
!14 = !{!"MHandle", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16}
!15 = !{!16, !11, i64 8}
!16 = !{!"HandleObjectCreate", !11, i64 0, !11, i64 8, !9, i64 16, !8, i64 80, !17, i64 88, !11, i64 96, !8, i64 104}
!17 = !{!"long", !9, i64 0}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !11, i64 0}
!20 = !{!"Property", !11, i64 0, !11, i64 8, !11, i64 16, !9, i64 24}


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