; 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: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #1

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

declare ptr @mChainCreate(...) #3

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

declare ptr @mornMapWrite(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

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

28:                                               ; preds = %4
  %29 = call ptr (...) @mChainCreate()
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.HandleObjectCreate, ptr %30, i32 0, i32 1
  store ptr %29, ptr %31, align 8, !tbaa !15
  br label %32

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

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %41 = load i32, ptr %11, align 4, !tbaa !18
  %42 = sext i32 %41 to i64
  %43 = sub i64 %42, 24
  %44 = trunc i64 %43 to i32
  store i32 %44, ptr %13, align 4, !tbaa !18
  %45 = load i32, ptr %13, align 4, !tbaa !18
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %47, label %85

47:                                               ; preds = %40
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Property, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %78

52:                                               ; preds = %47
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Property, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Property, ptr %56, i32 0, i32 3
  %58 = getelementptr inbounds [0 x i8], ptr %57, i64 0, i64 0
  %59 = load i32, ptr %13, align 4, !tbaa !18
  %60 = sext i32 %59 to i64
  %61 = call i32 @memcmp(ptr noundef %55, ptr noundef %58, i64 noundef %60) #6
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %77

63:                                               ; preds = %52
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Property, ptr %65, i32 0, i32 3
  %67 = getelementptr inbounds [0 x i8], ptr %66, i64 0, i64 0
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  call void %64(ptr noundef %67, ptr noundef %68)
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Property, ptr %69, i32 0, i32 3
  %71 = getelementptr inbounds [0 x i8], ptr %70, i64 0, i64 0
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Property, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !19
  %75 = load i32, ptr %13, align 4, !tbaa !18
  %76 = sext i32 %75 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %71, ptr align 1 %74, i64 %76, i1 false)
  br label %77

77:                                               ; preds = %63, %52
  br label %84

78:                                               ; preds = %47
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Property, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds [0 x i8], ptr %81, i64 0, i64 0
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  call void %79(ptr noundef %82, ptr noundef %83)
  br label %84

84:                                               ; preds = %78, %77
  br label %85

85:                                               ; preds = %84, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %95

86:                                               ; preds = %32
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.HandleObjectCreate, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !18
  %92 = call ptr @mornMapWrite(ptr noundef %89, ptr noundef %90, i32 noundef -1, ptr noundef null, i32 noundef %91)
  store ptr %92, ptr %12, align 8, !tbaa !5
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.Property, ptr %93, i32 0, i32 0
  store ptr null, ptr %94, align 8, !tbaa !19
  br label %95

95:                                               ; preds = %86, %85
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.Property, ptr %97, i32 0, i32 1
  store ptr %96, ptr %98, align 8, !tbaa !21
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.Property, ptr %100, i32 0, i32 2
  store ptr %99, ptr %101, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, 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"

; 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 @mChainCreate(...) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @m_PropertyFunction(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %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 %14, label %16

14:                                               ; preds = %4
  %15 = tail call ptr (...) @mChainCreate() #5
  store ptr %15, ptr %11, align 8, !tbaa !15
  br label %16

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

19:                                               ; preds = %16
  %20 = load i32, ptr %5, align 4, !tbaa !18
  %21 = add i32 %20, -24
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %35

23:                                               ; preds = %19
  %24 = load ptr, ptr %18, align 8, !tbaa !19
  %.not30 = icmp eq ptr %24, null
  %25 = getelementptr inbounds i8, ptr %18, i64 24
  br i1 %.not30, label %30, label %26

26:                                               ; preds = %23
  %27 = zext nneg i32 %21 to i64
  %bcmp = call i32 @bcmp(ptr nonnull %24, ptr nonnull %25, i64 %27)
  %.not31 = icmp eq i32 %bcmp, 0
  br i1 %.not31, label %35, label %28

28:                                               ; preds = %26
  call void %2(ptr noundef nonnull %25, ptr noundef %3) #5
  %29 = load ptr, ptr %18, align 8, !tbaa !19
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %25, ptr align 1 %29, i64 %27, i1 false)
  br label %35

30:                                               ; preds = %23
  call void %2(ptr noundef nonnull %25, ptr noundef %3) #5
  br label %35

31:                                               ; preds = %16
  %32 = load ptr, ptr %11, align 8, !tbaa !15
  %33 = load i32, ptr %5, align 4, !tbaa !18
  %34 = call ptr @mornMapWrite(ptr noundef %32, ptr noundef %1, i32 noundef -1, ptr noundef null, i32 noundef %33) #5
  store ptr null, ptr %34, align 8, !tbaa !19
  br label %35

35:                                               ; preds = %19, %26, %28, %30, %31
  %.0 = phi ptr [ %34, %31 ], [ %18, %30 ], [ %18, %28 ], [ %18, %26 ], [ %18, %19 ]
  %36 = getelementptr inbounds i8, ptr %.0, i64 8
  store ptr %2, ptr %36, align 8, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %.0, i64 16
  store ptr %3, ptr %37, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret void
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #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 = { nofree nounwind willreturn memory(argmem: read) }
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}
!21 = !{!20, !11, i64 8}
!22 = !{!20, !11, i64 16}


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